本地环境:centos 7.6(1810)单网卡桥接
先安装一些基础包
yum install -y wget vim
备份
mkdir /root/yumbak
cd /etc/yum.repos.d
mv -v * /etc/yum.repos.d
1.阿里centos yum源
wget http://mirrors.aliyun.com/repo/Centos-7.repo
2.阿里openstack-rocky yum源
链接: 阿里openstack yum源.
vim /etc/yum.repos.d/openstack-rocky.repo
[openstack]
name=openstack
baseurl=https://mirrors.aliyun.com/centos/7/cloud/x86_64/openstack-rocky/
gpgcheck=0
failovermethod=priority ####(有多个url可供选择时,yum选择的次序,详情见http://www.t086.com/article/5015)
enabled=1
3.阿里qemu的源
因为在安装过程中会报错qemu版本过低,所以还需要配置qemu的源
/etc/yum.repos.d/CentOS-qemu.repo
[centos-qemu]
name=qemu
baseurl=https://mirrors.aliyun.com/centos/7/virt/x86_64/kvm-common/
gpgcheck=0
enabled=1
yum clean all && yum makecache
//如果有一个失败一般再执行一次就好了
yum repolist
//记得关闭防火墙和selinux如下
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
yum install -y yum-utils createrepo //第一个提供reposync功能,第二个创建本地yum连接时用
reposync -r base
reposync -r extras
reposync -r updates
reposync -r centos-qemu
reposync -r openstack
//默认下载目录在/root下
//在/root目录下,也就是你下载到的yum源根目录
cd base
createrepo ./
cd ../extras
createrepo ./
cd ../updates
createrepo ./
cd ../centos-qemu
createrepo ./
cd ../openstack
createrepo ./
yum install -y httpd
vi /etc/httpd/conf/httpd.conf
119 改为DocumentRoot "/root"
124 改为
131 改为
//删除欢迎主页
welcome.conf
//启动fuw
systemctl start httpd
systemctl enable httpd
移除或备份自带yum源,见本教程第一步
写本地仓库yum地址
vi ftp.repo
[base]
name=CentOS-base
failovermethod=priority
baseurl=http://192.168.2.9/base
gpgcheck=0
#released updates
[updates]
name=CentOS-updates
failovermethod=priority
baseurl=http://192.168.2.9/updates
gpgcheck=1
#additional packages that may be useful
[extras]
name=CentOS-extras
failovermethod=priority
baseurl=http://192.168.2.9/extras
gpgcheck=0
#additional packages that extend functionality of existing packages
#[centosplus]
#name=CentOS-centosplus
#failovermethod=priority
#baseurl=http://192.168.2.9/centosplus
#gpgcheck=1
#enabled=0
#contrib - packages by Centos Users
#[contrib]
#name=CentOS-contrib
#failovermethod=priority
#baseurl=http://192.168.2.9./contrib
#gpgcheck=0
#enabled=0
[centos-qemu-ev]
name=qemu
baseurl=http://192.168.2.9/centos-qemu-ev
gpgcheck=0
enabled=1
[openstack]
name=openstack
baseurl=http://192.168.2.9/openstack
gpgcheck=0
failovermethod=priority
enabled=1
试试效果:
[root@compute ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
base CentOS-base 10,097
centos-qemu-ev qemu 87
extras CentOS-extras 341
openstack openstack 2,741
updates CentOS-updates 1,787
repolist: 15,053