centos 7+——YUM仓库搭建+定时源更新+客户端配置

准备环境
1、首先找到对应源的镜像网站以下参考网站都可
http://mirrors.yun-idc.com 首都
http://mirrors.aliyun.com/ 阿里云
http://mirrors.163.com/ 网易
http://mirrors.sohu.com/ 搜狐

2、目录规划 mkdir –p /data/epel    (epel源包下载路径)
                    mkdir –p /data/yum    (centos源包下载路径)

3、httpd 、rsync  工具,rsync一般系统自带,httpd可能需要下载rpm包安装
输入命令 rpm –qa | grep httpd   rpm –qa | grep rsync来确认是否安装

4、准备好的epel.repo yum.repo 文件(附件)


服务器的搭建
1、以下以首都镜像网站为例部署epel源,根据centos系统版本进行下载,目前我们主要使用的是centos 7以上版本,所以下载7/
 
 
 

2、进入7/目录后获取URL地址


利用rsync同步到本地/data目录中
1、rsync -avrt --delete --no-iconv --bwlimit=1000  rsync://mirrors.yun-idc.com/epel/7/ /data/epel (–bwlimit 限制下载网速)

2、加入到自动化任务中每月更新一次
30 0 1 * * /usr/bin/rsync -avrt --delete --no-iconv --bwlimit=1000  rsync://mirrors.yun-idc.com/epel/7/ /data/epel

3、创建软连接apache的默认路径为/var/www/html,所以我们/data/下的软件包要想被识别就要放到/var/www/html目录下,此时创建软连接最方便

 1、 ln –s /data/epel /var/www/html/epel

chmod -R 555 /data

至此服务器端完成


客户端配置
1、cd /etc/yum.repos.d 下将原有文件备份到 /etc/yum.repos.d/back

2、将编写好的epel.repo 和yum.repo放到/etc/yum.repos.d/

3、yum clean all 清除缓存

4、yum makecache 建立缓存

5、yum repolist

6、yum install nginx 测试源的可用性

至此客户端配置完成


repo文件内容如下

[root@centos7 yum.repos.d]# cat epel.repo
[SRPMS]         - - - - - - - -  - - - - - – - - - - - - - - - - - - - - -  注释
name=epel     - - - - - - - -  - - - - - – - - - - - - - - - - - - - - -  源名称自定义
baseurl=http://10.5.15.22/epel/SRPMS  - - - - - - - - - - - - -源索引文件(repodata目录)的上级目录
enabled=1     - - - - - - - -  - - - - - – - - - - - - - - - - - - - - - - 启用
gpgcheck=0   - - - - - - - -  - - - - - – - - - - - - - - - - - - - - - 关闭秘钥检查
#
[aarch64]
name=epel
baseurl=http://10.5.15.22/epel/aarch64
enabled=1
gpgcheck=0
#
[ppc64]
name=epel
baseurl=http://10.5.15.22/epel/ppc64
enabled=1
gpgcheck=0
#
[x86_64]
name=epel
baseurl=http://10.5.15.22/epel/x86_64
enabled=1
gpgcheck=0
#
[ppc64le]
name=epel
baseurl=http://10.5.15.22/epel/ppc64le
enabled=1
gpgcheck=0


下面是安装centos源文件

[root@centos7 yum.repos.d]# cat yum.repo
[os]
name=centos
baseurl= http://10.5.15.22/yum//os/x86_64
enabled=1
gpgcheck=0
#
[atomic]
name=centos
baseurl= http://10.5.15.22/yum/atomic/x86_64
enabled=1
gpgcheck=0
#
[centosplus]
name=centos
baseurl= http://10.5.15.22/yum/centosplus/x86_64
enabled=1
gpgcheck=0
#
[cloud]
name=centos
baseurl= http://10.5.15.22/yum/cloud/x86_64/openstack-newton
enabled=1
gpgcheck=0
#
[cloud]
name=centos
baseurl= http://10.5.15.22/yum/cloud/x86_64/openstack-ocata
enabled=1
gpgcheck=0
#
[cloud]
name=centos
baseurl= http://10.5.15.22/yum/cloud/x86_64/openstack-pike
enabled=1
gpgcheck=0
#
[cloud]
name=centos
baseurl= http://10.5.15.22/yum/cloud/x86_64/openstack-queens
enabled=1
gpgcheck=0
#
[configmanagement]
name=centos
baseurl= http://10.5.15.22/yum/configmanagement/x86_64/yum4
enabled=1
gpgcheck=0
#
[cr]
name=centos
baseurl= http://10.5.15.22/yum/cr/x86_64
enabled=1
gpgcheck=0
#
[dotnet]
name=centos
baseurl= http://10.5.15.22/yum/dotnet/x86_64
enabled=1
gpgcheck=0
#
[extras]
name=centos
baseurl= http://10.5.15.22/yum/extras/x86_64
enabled=1
gpgcheck=0
#
[fasttrack]
name=centos
baseurl= http://10.5.15.22/yum/fasttrack/x86_64
enabled=1
gpgcheck=0
#
[nvf]
name=centos
baseurl= http://10.5.15.22/yum/nfv/x86_64/fdio
enabled=1
gpgcheck=0
#
[opstools]
name=centos
baseurl= http://10.5.15.22/yum/opstools/x86_64
enabled=1
gpgcheck=0
#
[opstools]
name=centos
baseurl= http://10.5.15.22/yum/opstools/x86_64
enabled=1
gpgcheck=0
#
[os]
name=centos
baseurl= http://10.5.15.22/yum/os/x86_64
enabled=1
gpgcheck=0
#
[os]
name=centos
baseurl= http://10.5.15.22/yum/os/x86_64
enabled=1
gpgcheck=0
#
[paas]
name=centos
baseurl= http://10.5.15.22/yum/paas/x86_64/openshift-origin
enabled=1
gpgcheck=0
#
[paas]
name=centos
baseurl= http://10.5.15.22/yum/paas/x86_64/openshift-origin13
enabled=1
gpgcheck=0
#
[paas]
name=centos
baseurl= http://10.5.15.22/yum/paas/x86_64/openshift-origin14
enabled=1
gpgcheck=0
#
[paas]
name=centos
baseurl= http://10.5.15.22/yum/paas/x86_64/openshift-origin15
enabled=1
gpgcheck=0
#
[paas]
name=centos
baseurl= http://10.5.15.22/yum/paas/x86_64/openshift-origin36
enabled=1
gpgcheck=0
#
[paas]
name=centos
baseurl= http://10.5.15.22/yum/paas/x86_64/openshift-origin37
enabled=1
gpgcheck=0
#
[rt]
name=centos
baseurl= http://10.5.15.22/yum/rt/x86_64
enabled=1
gpgcheck=0
#
[sclo]
name=centos
baseurl= http://10.5.15.22/yum/sclo/x86_64/rh
enabled=1
gpgcheck=0
#
[sclo]
name=centos
baseurl= http://10.5.15.22/yum/sclo/x86_64/sclo
enabled=1
gpgcheck=0
#
[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/ceph-hammer
enabled=1
gpgcheck=0
#
[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/ceph-jewel
enabled=1
gpgcheck=0
#
[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/ceph-luminous
enabled=1
gpgcheck=0
#
[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/gluster-3.6
enabled=1
gpgcheck=0
#[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/gluster-3.7
enabled=1
gpgcheck=0
#
[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/gluster-3.8
enabled=1
gpgcheck=0
#
[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/gluster-3.9
enabled=1
gpgcheck=0
#
[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/gluster-3.10
enabled=1
gpgcheck=0
#
[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/gluster-3.12
enabled=1
gpgcheck=0
#
[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/gluster-3.13
enabled=1
gpgcheck=0
#
[storage]
name=centos
baseurl= http://10.5.15.22/yum/storage/x86_64/gluster-4.0
enabled=1
gpgcheck=0
#
[updates]
name=centos
baseurl= http://10.5.15.22/yum/updates/x86_64
enabled=1
gpgcheck=0
#
[virt]
name=centos
baseurl= http://10.5.15.22/yum/virt/x86_64/kubernetes19
enabled=1
gpgcheck=0
#
[virt]
name=centos
baseurl= http://10.5.15.22/yum/virt/x86_64/kvm-commom
enabled=1
gpgcheck=0
#
[virt]
name=centos
baseurl= http://10.5.15.22/yum/virt/x86_64/libvirt-latest
enabled=1
gpgcheck=0
#
[virt]
name=centos
baseurl= http://10.5.15.22/yum/virt/x86_64/ovirt-4.1
enabled=1
gpgcheck=0
#
[virt]
name=centos
baseurl= http://10.5.15.22/yum/virt/x86_64/ovirt-4.2
enabled=1
gpgcheck=0
#
[virt]
name=centos
baseurl= http://10.5.15.22/yum/virt/x86_64/xen-46
enabled=1
gpgcheck=0
#[virt]
name=centos
baseurl= http://10.5.15.22/yum/virt/x86_64/xen-48
enabled=1
gpgcheck=0
#
[virt]
name=centos
baseurl= http://10.5.15.22/yum/virt/x86_64/xen
enabled=1
gpgcheck=0

猜你喜欢

转载自blog.csdn.net/yongyong169/article/details/79729117