linux系统使用之本地yum源搭建

我们在部署一些集群时用国外yum源,经常会很慢导致等待时间太久,所以常使用到本地yum源安装。

这里以centos7平台的openstack源为例:

1.首先下载官方repo

[root@test yum.repos.d]# yum install https://rdoproject.org/repos/rdo-release.rpm

下载完成后,/etc/yum.repos.d里面会产生3个文件

[root@test yum.repos.d]# ls

rdo-qemu-ev.repo rdo-release.repo rdo-testing.repo

2.开始搭建我的本地yum服务器

  • 安装httpd

[root@test yum.repos.d]# yum install httpd

新建安装包存放目录,待会将同步下来的包放这个目录

[root@test yum.repos.d]# mkdir /var/www/html/newton

[root@test yum.repos.d]# cd /vaw/www/html/newton

[root@test yum.repos.d]# yum repolist 

——列出你所有的仓库

前面是repo id不包含x86_64

这里我只需要同步openstack-newton、rdo-qemu-ev这两个软件库,指定要下载的仓库id,会通过网络全部下载到当前目录。

[root@test yum.repos.d]# reposync --repoid=openstack-newton

[root@test yum.repos.d]# reposync --repoid=rdo-qemu-ev

  • 同步完后

这时查看 /vaw/www/html/newton里面已经有很多包了,但只有软件包,没有repodate清单,所以需要自己重新createrepo来创建清单

[root@test yum.repos.d]# createrepo /var/www/html/newton/

然后启动httpd服务,其他机器通过httpd服务来访问yum源

[root@test yum.repos.d]# service httpd restart

本地yum源repo配置如下:

[root@test yum.repos.d]# vim /etc/yum.repos.d/openstack.repo

[openstack]

name=openstack

baseurl=http://ip/newton

enabled=1

gpgcheck=0

     最后执行

[root@test yum.repos.d]# yum makecache

如果其他节点需要添加该yum源,只要在yum.repos.d目录添加以上配置文件和执行最后的命令即可,这样的本地源大大节省了软件安装的时间。

猜你喜欢

转载自blog.csdn.net/RJ0024/article/details/85338374