1、设置主机名
hostnamectl set-hostname template
2、设置 hosts
cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
openstack
192.168.59.20 controller
192.168.59.31 compute01
192.168.59.32 compute02
cpeh-public
192.168.59.11 ceph01
192.168.59.12 ceph02
192.168.59.13 ceph03
ceph-cluster
20.168.59.11 ceph01-cluster
20.168.59.12 ceph02-cluster
20.168.59.13 ceph03-cluster
yum
192.168.59.250 yum01
3、配置 IP 地址并且关闭 NetworkMnanager
各主机第一块网卡按规划用作 Provider IP (使用 NAT 网络,可出外网)
cat < /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV6INIT=no
NAME=ens33
DEVICE=ens33
ONBOOT=yes
ip 地址,不同主机修改成不同 IP
IPADDR=192.168.59.251
NETMASK=255.255.255.0
GATEWAY=192.168.59.2
DNS1=223.5.5.5
EOF
systemctl restart network
systemctl stop NetworkManager && systemctl disable NetworkManager
3、关闭防火墙和 selinux
systemctl stop firewalld && systemctl disable firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
上述 sed 命令用于将/etc/selinux/config 文件中的 SELINUX=enforcing 替换成 SELINUX=disabled
4、设置内核参数及文件句柄等资源限制参数
cat <> /etc/sysctl.conf
default 1
net.ipv4.tcp_syncookies = 1
default 0
net.ipv4.tcp_tw_reuse = 1
default 0
net.ipv4.tcp_tw_recycle = 1
default 60
net.ipv4.tcp_fin_timeout = 30
default 256
net.ipv4.tcp_max_syn_backlog = 4096
default 32768 60999
net.ipv4.ip_local_port_range = 1024 65535
default 129=8
net.core.somaxconn = 32768
EOF
sysctl -p
cat <> /etc/security/limits.conf
- hard nofile 655360
- soft nofile 655360
- hard nproc 655360
- soft nproc 655360
- soft core 655360
- hard core 655360
EOF
sed -i 's/4096/unlimited/g' /etc/security/limits.d/20-nproc.conf
cat /etc/security/limits.d/20-nproc.conf
- soft nproc unlimited
root soft nproc unlimited
5、设置 CPU 嵌套虚拟化,让虚拟机中再支持虚拟化
cat /sys/module/kvm_amd/parameters/nested
vim /etc/modprobe.d/kvm_amd.conf
options kvm_amd nested=1
modprobe -r kvm_amd
modprobe kvm_amd
cat /sys/module/kvm_amd/parameters/nested
2、从阿里云下载 yum 配置文件
cd /etc/yum.repos.d && mkdir backup && mv *.repo backup/
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum -y install centos-release-openstack-train
添加 ceph-nautilus 源
vim /etc/yum.repos.d/ceph.repo
[ceph]
name=Ceph packages for $basearch
baseurl=http://mirrors.aliyun.com/ceph/rpm-nautilus/el7/x86_64
enabled=1
gpgcheck=0
[ceph-noarch]
name=Ceph noarch packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-nautilus/el7/noarch
enabled=1
gpgcheck=0
[ceph-source]
name=Ceph source packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-nautilus/el7/SRPMS
enabled=1
gpgcheck=0
3、安装相关软件包
yum -y install createrepo yum-utils httpd reposync
systemctl enable httpd && systemctl start httpd
4、创建仓库目录
mkdir -p /var/www/html/yumrepos
4、根据 CentOS-Base.repo 同步阿里云软件包到本地
reposync -p /var/www/html/yumrepos/
如果只想同步 CentOS-Base.repo 中指定块[section]中的 rpm 包,可以指定名称同步
reposync -n --repoid=base --repoid=updates -p /var/www/html/yumrepos/
reposync -n --repoid=ceph --repoid=ceph-noarch -p /var/www/html/yumrepos/
reposync -n --repoid=centos-openstack-train -p /var/www/html/yumrepos/
reposync -n --repoid=centos-qemu-ev -p /var/www/html/yumrepos/
reposync -n --repoid=zabbix -p /var/www/html/yumrepos/
说明:以上仓库必须同步到本地
此处再以 zabbix 离线源为例
安装 zabbix-4.0 的 yum 源配置文件
rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
安装好 zabbix-release-4.0-2.el7.noarch.rpm 会在/etc/yum.repos.d/ 下生成 zabbix.repo 文件
cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
只同步[zabbix]块中的 rpm 包到本地
reposync -n --repoid=zabbix -p /var/www/html/yumrepos/
5、使用 createrepo 命令创建本地 yum 源,即为存放于本地特定位置的众多 rpm 包建立索引,描述各包所需依赖信息,并形成元数据
进到 /var/www/html/yumrepos/ 目录下的每一个目录执行 createrepo . 命令
cd /var/www/html/yumrepos/base
createrepo .
6、定期更新
reposync -n --repoid=base -p /var/www/html/yumrepos/
cd /var/www/html/yumrepos/base
createrepo --update . // 或者使用命令 createrepo --update /var/www/html/yumrepos/base
按上述方法,将 openstack 所依赖的 rpm 包全部下载到本地