CentOS 7 Cobbler 配置 YUM仓库

通过Cobbler配置内网YUM仓库

上一篇Cobbler 安装中,配置好了Cobbler

下面来通过Cobbler来配置内网的YUM仓库

这里可以同步所有版本的yum源,增加内网的yum安装下载速度。

通过命令来增加仓库

[root@backup ~]#cobbler repo add --name=Centos6-UPDATES --mirror=http://mirrors.aliyun.com/centos/6/updates/x86_64/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos6-salt201611 --mirror=https://repo.saltstack.com/yum/redhat/6/x86_64/2016.11/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos7-Base --mirror= https://mirrors.aliyun.com/centos/7/os/x86_64/ --arch=x86_64 --breed=rsync
[root@backup ~]#cobbler repo add --name=Centos7-extras  --mirror=https://mirrors.aliyun.com/centos/7/extras/x86_64/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=epel6-x86_64-testing --mirror=http://mirrors.aliyun.com/epel/testing/6/x86_64/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos7-salt201707  --mirror=https://repo.saltstack.com/yum/redhat/7Server/x86_64/2017.7/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos6-Base --mirror=http://mirrors.aliyun.com/centos/6/os/x86_64/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=epel6-x86_64 --mirror=http://mirrors.aliyun.com/epel/6/x86_64/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos7-epel --mirror=https://mirrors.aliyun.com/epel/7Server/x86_64/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos6-webtatic --mirror=http://sp.repo.webtatic.com/yum/el6/x86_64/ --arch=x86_64 --breed=yum 
[root@backup ~]#cobbler repo add --name=Centos7-webtatic --mirror=https://sp.repo.webtatic.com/yum/el7/x86_64/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos6-percona  --mirror=http://repo.percona.com/release/6Server/os/x86_64/ --arch=x86_64 --breed=yum 
[root@backup ~]#cobbler repo add --name=Centos7-salt201611 --mirror=https://repo.saltstack.com/yum/redhat/7/x86_64/2016.11/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos7-zabbix3 --mirror=http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos6-extras  --mirror=http://mirrors.aliyun.com/centos/6/extras/x86_64/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos6-zabbix3 --mirror=http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/ --arch=x86_64 --breed=yum
[root@backup ~]#cobbler repo add --name=Centos7-percona --mirror=http://repo.percona.com/release/7Server/os/x86_64/ --arch=x86_64 --breed=yum
参数 说明
cobbler repo add 添加yum源
cobbler repo copy 复制
cobbler repo edit 修改
cobbler repo find 查找
cobbler repo list 列出已添加的yum源
cobbler repo remove 删除已添加的本地yum源
cobbler repo rename 重命名本地已添加的源
cobbler repo report 列出全部源的详细信息

查看刚刚添加的yum仓库

[root@cobbler ~]# cobbler repo list
   Centos6-Base
   Centos6-UPDATES
   Centos6-extras
   Centos6-percona
   Centos6-salt201611
   Centos6-webtatic
   Centos6-zabbix3
   Centos7-Base
   Centos7-epel
   Centos7-extras
   Centos7-percona
   Centos7-salt201611
   Centos7-salt201707
   Centos7-webtatic
   Centos7-zabbix3
   epel6-x86_64
   epel6-x86_64-testing

并没有结束,还需要把添加的这些,同步下来

这里就不全部同步了,指定一个同步

[root@cobbler ~]# cobbler reposync --only=Centos7-zabbix3
task started: 2018-09-28_104217_reposync
task started (id=Reposync, time=Fri Sep 28 10:42:17 2018)
hello, reposync
run, reposync, run!
creating: /var/www/cobbler/repo_mirror/Centos7-zabbix3/config.repo
creating: /var/www/cobbler/repo_mirror/Centos7-zabbix3/.origin/Centos7-zabbix3.repo
running: /usr/bin/reposync -l -n -d --config=/var/www/cobbler/repo_mirror/Centos7-zabbix3/.origin/Centos7-zabbix3.repo --repoid=Centos7-zabbix3 --download_path=/var/www/cobbler/repo_mirror -a x86_64
2.9 kB     00:00     
3.6 kB     00:00     
3.2 kB     00:00     
3.4 kB     00:00     
3.4 kB     00:00     
 88 kB   00:00     
166 kB   00:00     
945 kB   00:00     
187 kB   00:00     
3.6 MB   00:00     
112 kB   00:01     
5.9 MB   00:03     
5.2 MB   00:03     
255 kB   00:01     
367 kB   00:01     
737 kB   00:02     
678 kB   00:02     
677 kB   00:02     
 13 kB   00:00     
646 kB   00:02     
267 kB   00:00     
2.0 MB   00:06     
2.0 MB   00:06     
7.5 kB   00:00     
7.1 kB   00:00     
7.1 kB   00:00     
2.7 MB   00:08     

received on stderr: 
running: createrepo  -c cache -s sha /var/www/cobbler/repo_mirror/Centos7-zabbix3
received on stdout: Spawning worker 0 with 14 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

received on stderr: 
running: chown -R root:apache /var/www/cobbler/repo_mirror/Centos7-zabbix3
received on stdout: 
received on stderr: 
running: chmod -R 755 /var/www/cobbler/repo_mirror/Centos7-zabbix3
received on stdout: 
received on stderr: 
*** TASK COMPLETE ***
[root@cobbler ~]# ls /var/www/cobbler/repo_mirror/Centos7-zabbix3/
cache                                 zabbix-java-gateway-3.4.14-1.el7.x86_64.rpm   zabbix-sender-3.4.14-1.el7.x86_64.rpm        zabbix-web-mysql-3.4.14-1.el7.noarch.rpm
config.repo                           zabbix-proxy-mysql-3.4.14-1.el7.x86_64.rpm    zabbix-server-mysql-3.4.14-1.el7.x86_64.rpm  zabbix-web-pgsql-3.4.14-1.el7.noarch.rpm
repodata                              zabbix-proxy-pgsql-3.4.14-1.el7.x86_64.rpm    zabbix-server-pgsql-3.4.14-1.el7.x86_64.rpm
zabbix-agent-3.4.14-1.el7.x86_64.rpm  zabbix-proxy-sqlite3-3.4.14-1.el7.x86_64.rpm  zabbix-web-3.4.14-1.el7.noarch.rpm
zabbix-get-3.4.14-1.el7.x86_64.rpm    zabbix-release-3.4-2.el7.noarch.rpm           zabbix-web-japanese-3.4.14-1.el7.noarch.rpm

这里看到已经同步下来了,其他的类似,如果相同步所有,则不增加--only参数即可

下面就可以通过访问http://10.0.0.200/cobbler/repo_mirror/Centos7-zabbix3/ 能看到

配置其他机器配置yum源

[root@cobbler yum.repos.d]# cat local.repo 
[zabbix-34]
name=local CentOS7 zabbix34
baseurl=http://10.0.0.200/cobbler/repo_mirror/Centos7-zabbix3/
enable=1
gpgcheck=0

测试

[root@cobbler yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                                                                                                                  | 3.6 kB  00:00:00     
epel                                                                                                                                                                  | 3.2 kB  00:00:00     
extras                                                                                                                                                                | 3.4 kB  00:00:00     
updates                                                                                                                                                               | 3.4 kB  00:00:00     
zabbix-34                                                                                                                                                             | 2.5 kB  00:00:00     
(1/8): epel/x86_64/updateinfo                                                                                                                                         | 945 kB  00:00:00     
(2/8): epel/x86_64/prestodelta                                                                                                                                        | 2.9 kB  00:00:00     
(3/8): epel/x86_64/primary                                                                                                                                            | 3.6 MB  00:00:00     
(4/8): zabbix-34/filelists_db                                                                                                                                         |  12 kB  00:00:00     
(5/8): zabbix-34/other_db                                                                                                                                             | 3.3 kB  00:00:00     
(6/8): zabbix-34/primary_db                                                                                                                                           |  11 kB  00:00:00     
(7/8): epel/x86_64/other                                                                                                                                              | 2.2 MB  00:00:00     
(8/8): epel/x86_64/filelists                                                                                                                                          |  10 MB  00:00:02     
epel                                                                                                                                                                             12692/12692
epel                                                                                                                                                                             12692/12692
epel                                                                                                                                                                             12692/12692
Metadata Cache Created

从上面可以看出来,zabbix-34 是没问题的了

至此,cobbler 的内网yum源配置完成。

原文地址:https://www.cnblogs.com/winstom/p/9717376.html