有两种方案,方案一方案二。 方案一:适合openstack对应版本的项目还在维护,即在mirrors站中还有相关在线yum源的情况下。 1、本地yum搭建环境准备 --最小化安装CentOS7.2系统(CentOS-7-x86_64-Minimal-1511.iso) --IPADDR=123.45.67.111/24 1.1 关闭防火墙、关闭SELinux

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

1.2 安装基本软件

yum -y install vim createrepo httpd

1.3 备份CentOS-Base.repo文件

mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/backup 

1.4 重建repo文件

echo '[ocata]
name=CentOS-Ocata
baseurl=https://mirrors.aliyun.com/centos/7/cloud/x86_64/openstack-ocata/
enable=1
gpgcheck=0

[ocata-extras]
name=CentOS-Ocata-extras
baseurl=https://mirrors.aliyun.com/centos/7/extras/x86_64/
enable=1
gpgcheck=0

[centos7]
name=Centos-7
baseurl=https://mirrors.aliyun.com/centos/7/os/x86_64/
enable=1
gpgcheck=0
'>/etc/yum.repos.d/CentOS-Base.repo

1.5 更新系统及重启

yum clean all
yum makecache
yum -y update
reboot

1.6 加载远端软件包(共12G,我下载用时大约20分钟)

cd /var/www/
reposync --repoid=ocata
reposync --repoid=ocata-extras
reposync --repoid=centos7

1.7 生成repodata

createrepo /var/www/ocata/
createrepo /var/www/ocata-extras/
createrepo /var/www/centos7/

1.8 配置httpd服务

vim /etc/httpd/conf/httpd.conf
119行将DocumentRoot "/var/www/html"改为DocumentRoot "/var/www/"
131行将<Directory "/var/www/html">改为<Directory "/var/www/">

1.9 启动httpd并开机启动

systemctl start httpd
systemctl enable httpd

1.10 验证httpd服务 浏览器地址栏输入http://123.45.67.111/ocata 验证 2、重建本地repo文件以使用yum源 2.1 备份本地CentOS-Base.repo文件

mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/backup 

2.2 重建repo文件

echo '[ocata]
name=CentOS-Ocata
baseurl=http://123.45.67.111/ocata/
enable=1
gpgcheck=0

[ocata-extras]
name=CentOS-Ocata-extras
baseurl=http://123.45.67.111/ocata-extras/
enable=1
gpgcheck=0

[centos7]
name=Centos-7
baseurl=http://123.45.67.111/centos7/
enable=1
gpgcheck=0
'>/etc/yum.repos.d/CentOS-Base.repo

2.3 测试yum配置及生成缓存文件

yum clean all
yum makecache
yum repolist all

方案二 适用于企业内部自己开发、搭建、维护或者openstack对应版本的项目已经不再维护(即在mirrors站中已经没有了相关在线yum源的情况)。 1、本地yum搭建环境准备 --最小化安装CentOS7.2系统(CentOS-7-x86_64-Minimal-1511.iso) --IPADDR=123.45.67.111/24 1.1 关闭防火墙、关闭SELinux

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

1.2 安装基本软件

yum -y install vim createrepo httpd wget vim-enhanced

1.3 替换国内yum源并更新系统

mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/{*.repo,backup}
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
rm -rf /var/cache/yum
yum makecache
yum -y update

1.4 通过winscp将openstack-queen.tar.gz包文件复制进/var/www/html/目录下并解压缩

tar -zxvf openstack-queen.tar.gz

1.4 生成repodata

createrepo /var/www/html/openstack-queens/

1.5 启动httpd并开机启动

systemctl start httpd
systemctl enable httpd

1.6 生成repo文件

echo '[openstack-queens]
name=openstack-queens
baseurl=http://123.45.67.111/openstack-queens/
enable=1
gpgcheck=0
'>/etc/yum.repos.d/openstack-queens.repo

1.7 测试本地yum源

rm -rf /var/cache/yum
yum makecache
yum repolist all