因为内网环境限制,多服务器软件版本统一,以及解决软件包相关依赖的需要,搭建本地yum源仓库时必要的。
下面是部署公司私有yum仓库时epel源的具体部署步骤:
1、部署环境:
[if !supportLists]· [endif]系统:Centos7.6 x4
[if !supportLists]· [endif]应用服务:Nginx、createrepo、reposync
[if !supportLists]· [endif]镜像源:https://mirrors.aliyun.com/repo/epel-7.repo
2、现在阿里云镜像源repo文件到本地:
[root@localhost ~] wget -O
/etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
3、安装Nginx服务,用于提供存放yum源:
参考文档《centos7安装nginx》
4、安装yum-utils提供reporsync服务:
[root@localhost ~] yum
install yum-utils -y
5、选择指定仓库标识作为本地yum源:我使用epel作为本地yum源,用/var/www/html作为yum仓库根目录
[root@localhost ~]# reposync -r epel -p/var/www/html/
命令执行完毕后,会将阿里云中的epel源同步到本地/var/www/html中;在/var/www/html中自动创建epel目录用于存放rpm包;第一次同步是时间可能较长,大概1W多个rpm包。
6、createrepo 命令创对/var/www/html/epel下的 rpm 包 创建为本地的 YUM 仓库,目的是为生成repodata目录并自动创建索引信息
[root@localhost ~]# createrepo -pdo
/var/www/html/epel/ /var/www/html/epel/#第一个目录是repodata存放目录,第二个目录是需要生成索引信息yum源仓库目录
7、验证本地yum源是否能正常使用:
登录其他内网其他服务器,备份系统repo文件至/etc/yum.repos.d/ repobak目录下,并编写repo文件:
vim /etc/yum.repos.d/epel-7.repo内容如下:
[epel]
name=local epel
baseurl=http://yum源服务器IP/epel
enabled=1
gpgcheck=0
8、执行yum clean all、yummakecache生成索引并测试
[root@localhost yum.repos.d]#
yum clean all && yummakecache