1. 列出所有源
复制
代码语言:javascript复制# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 9,363
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 11,135
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 263
openstack-mitaka/7/x86_64 OpenStack Newton Repository 1,675
openstack-newton/7/x86_64 OpenStack Newton Repository 1,486
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 807
repolist: 24,729
2. 同步源(以openstack-newton为例)
复制
代码语言:javascript复制# yum install yum-utils -y #安装同步工具
# mkdir -p /opt/yum #同步目录
# reposync -d -r openstack-newton -p /opt/yum/ #开始同步,其他参数可以查看help
3. 创建本地源(生成元数据文件)
复制
代码语言:javascript复制# yum install createrepo -y #安装工具
# createrepo -v /opt/yum/openstack-newton/
4. 安装http服务,配置本地源
安装apache服务并设置开机自启
复制
代码语言:javascript复制# yum install httpd -y
# systemctl enable httpd.service
修改http默认目录
复制
代码语言:javascript复制# vim /etc/httpd/conf/httpd.conf
DocumentRoot "/opt/yum" #修改此处
#
# Relax access to content within /var/www.
#
<Directory "/opt"> #修改此处
AllowOverride None
# Allow open access:
Require all granted
# Further relax access to the default document root:
<Directory "/opt/yum/"> #修改此处
重启httpd
复制
代码语言:javascript复制# systemctl restart httpd.service