[nexus] 应用实践之YUM仓库
YUM 是RHEL分支的包管理工具,是一个RPM系统的自动更新和软件包安装/卸载器。它可以自动计算依赖和找出想要安装的软件包。数据中心服务器有一定规模数量时系统管理员一般搭建一个私有YUM仓库,来解决网络加速、网络策略配置(数据中心内的服务器通常为安全会配置网络策略--不能上外网)等问题。
从业多年,也见过不少使用定时任务使用rsync去同步网易、中科大、阿里云等这些国内镜像源。本文基于nexus来配置一个YUM私有仓库案例。
为YUM创建Blob Store
创建本地 YUM Registry
按下图创建并配置YUM 仓库
对应配置参考以下表:
选项 | 值 |
---|---|
Name | yum-private |
Online | checked |
Repodata Depth | 2 |
Layout Policy | Strict |
Blob store | yum-private |
Deployment policy | Allow redeploy |
创建远端 YUM Registry
配置参考以下表:
选项 | 值 |
---|---|
Name | yum-proxy |
Online | checked |
Remote storage | http://mirrors.163.com/centos/ |
Blob store | yum-proxy |
Deployment policy | Allow redeploy |
创建 YUM Registry Group
配置参考以下表:
选项 | 值 |
---|---|
Name | yum |
Online | checked |
Remote storage | http://mirrors.163.com/centos/ |
Blob store | yum-group |
Group | yum-private、yum-proxy |
RHEL/CentOS系统使用 YUM Registry Mirror
以上操作完成后,则 YUM Registry Mirror 已经部署完毕, 对外只需要提供 yum-group的URL即可:http://IP:8081/repository/yum/
往内网操作系统中YUM源使用以下内容:
[nexus]
name=Nexus Repository
baseurl=http://IP:8081/repository/yum/$releasever/os/$basearch/
enabled=1
gpgcheck=0
Tips: 实际生产中可以使用Nginx等反向代理来使用域名来提供服务。比如域名为
demo.com
,对外提供业务URL可以是:http://repo.demo.com/yum
构建缓存
# yum makecache fast
安装软件包
# yum makecache fast
Loaded plugins: fastestmirror
Determining fastest mirrors
nexus | 1.8 kB 00:00:00
(1/2): nexus/7/x86_64/group_gz | 155 kB 00:00:00
(2/2): nexus/7/x86_64/primary | 2.9 MB 00:00:00
nexus 10072/10072
Metadata Cache Created
[root@common yum.repos.d]# yum -y install net-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================================================================================================================================
Installing:
net-tools x86_64 2.0-0.25.20131004git.el7 nexus 306 k
Transaction Summary
====================================================================================================================================================================================================================================================================================================
Install 1 Package
Total download size: 306 k
Installed size: 917 k
Downloading packages:
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm | 306 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
Verifying : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
Installed:
net-tools.x86_64 0:2.0-0.25.20131004git.el7
Complete!
返回Nexus系统管理页面上,可以看到已存储的YUM数据