自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构  

欢迎加QQ群:1026880196 进行交流学习

 环境说明:

1. 满足一台电脑一个网卡的环境进行模拟测试,由于配置较低,这里只涉及常规测试,不做更深入开展。

2.如果你是物理机,可以准备2个物理网卡,一个作为管理网接口,一个作为浮动网接口(实例上外网的需要,这里需要交换机支持dhcp功能,可以自动获取ip地址)。

3.根据环境需要注意一下参数修改: 

nova_compute_virt_type: "kvm"                      

vim /etc/kolla/config/nova/nova-compute.conf

[libvirt]
inject_password=true
cpu_mode=host-passthrough
virt_type = kvm 

1. PC台式电脑硬件配置

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

2. 虚拟软件配置

#虚拟机下载 VMware-workstation-full-16.1.0-17198959.exe  百度网盘: 链接:https://pan.baidu.com/s/1RlgNja260HZtRffN_vc9EA     提取码:2021 

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

 3. 虚拟机网卡信息

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

 自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

4. 节点信息   # 单台融合控制/计算/存储

sstack   CPU:4核  内存:16GB 系统盘SSD 200GB*1   数据盘SSD 300GB*1   管理网:ens33 192.168.1.30/24   浮动网:ens34 dhcp  ( BOOTPROTO=dhcp )

5. 系统安装配置   #镜像下载 https://mirrors.ustc.edu.cn/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso

1.  系统版本
CentOS-7-x86_64-Minimal-2009.iso(CentOS 7.9 64位)

2.  语言
英文=标准安装

3.  分区
/boot  1000M    /swap 4096M    其余/

6. 网卡信息

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

7.  系统基本环境

1. 安装常用软件包
yum install gcc vim wget net-tools ntpdate git -y

2. 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
firewall-cmd --state

3. 关闭selinux
sed -i '/^SELINUX=.*/c SELINUX=disabled' /etc/selinux/config
sed -i 's/^SELINUXTYPE=.*/SELINUXTYPE=disabled/g' /etc/selinux/config
grep --color=auto '^SELINUX' /etc/selinux/config
setenforce 0

4. 主机名:
echo "
192.168.1.30 sstack">>/etc/hosts

5. ssh免密验证
ssh-keygen
ssh-copy-id root@sstack6. 修改ssh
sed -i 's/#ClientAliveInterval 0/ClientAliveInterval 60/g' /etc/ssh/sshd_config
sed -i 's/#ClientAliveCountMax 3/ClientAliveCountMax 60/g' /etc/ssh/sshd_config
systemctl daemon-reload && systemctl restart sshd && systemctl status sshd

7. 使用中国科技大学源
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
-i.bak \
/etc/yum.repos.d/CentOS-Base.repo

8. 配置docker源
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo

9. 安装epel源
yum makecache
yum install -y epel-release

10. 使用豆瓣pypi源
mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
EOF

11. 安装安装python-pip
yum install python-pip -y
pip install --upgrade "pip < 21.0"
pip install pbr

12. 升级系统软件包
yum update -y

13. 重启系统
reboot

8.  时间同步

1.  安装chrony服务
yum -y install chrony

2.  配置chrony文件
cp /etc/chrony.conf{,.bak}
echo "
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp6.aliyun.com iburst
stratumweight 0
driftfile /var/lib/chrony/drift
rtcsync
makestep 10 3
bindcmdaddress 127.0.0.1
bindcmdaddress ::1
keyfile /etc/chrony.keys
commandkey 1
generatecommandkey
noclientlog
logchange 0.5
logdir /var/log/chrony
">/etc/chrony.conf

3.  启动服务
systemctl enable chronyd && systemctl restart chronyd && systemctl status chronyd

4.  chrony同步源
chronyc sources -v
ntpdate ntp1.aliyun.com
hwclock -w

5.  配置定时任务
crontab -e
0 */1 * * * ntpdate ntp1.aliyun.com > /dev/null 2>&1; /sbin/hwclock -w
0 */1 * * * ntpdate ntp2.aliyun.com > /dev/null 2>&1; /sbin/hwclock -w

9. 安装配置

1.  安装依赖软件包
yum install python2-devel libffi-devel openssl-devel libselinux-python -y
yum remove docker docker-common docker-selinux docker-engine -y
yum install yum-utils device-mapper-persistent-data lvm2  -y

2.  安装ansible
yum install -y  "ansible < 2.9.19"

3.  配置ansible.cfg文件
sed -i 's/#host_key_checking = False/host_key_checking = True/g' /etc/ansible/ansible.cfg
sed -i 's/#pipelining = False/pipelining = True/g' /etc/ansible/ansible.cfg
sed -i 's/#forks          = 5/forks          = 100/g' /etc/ansible/ansible.cfg

4.   安装 kolla-ansible
pip install kolla-ansible==9.3.1 --ignore-installed PyYAML

5.  安装docker-ce
yum install docker-ce -y

6.   kolla-ansible配置文件到当前环境
mkdir -p /etc/kolla
chown $USER:$USER /etc/kolla
cp -r /usr/share/kolla-ansible/etc_examples/kolla/* /etc/kolla
cp /usr/share/kolla-ansible/ansible/inventory/* .

7.  修改docker配置文件配置国内阿里云地址,docker推送地址
mkdir /etc/docker/
cat >> /etc/docker/daemon.json << EOF
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
]
}
EOF


8.  开启 Docker 的共享挂载功能
mkdir -p /etc/systemd/system/docker.service.d
cat >> /etc/systemd/system/docker.service.d/kolla.conf << EOF
[Service]
MountFlags=shared
EOF

9.  设置docker服务启动
systemctl daemon-reload && systemctl enable docker && systemctl restart docker&& systemctl status docker 

 10. 文件配置

1.  配置清单
vim /root/all-in-one

修改如下:
[control]
sstack

[network]
sstack

[compute]
sstack

[storage]
sstack

[monitoring]
sstack

[deployment]
sstack

2.  配置globals.yml文件,开启需要的文件
vim /etc/kolla/globals.yml

修改如下:
kolla_base_distro: "centos"
kolla_install_type: "source"
openstack_release: "train"
node_custom_config: "/etc/kolla/config"
kolla_internal_vip_address: "192.168.1.29"
#docker_registry: "xxx123.zixuanyun.com:4000"
docker_namespace: "kolla"
network_interface: "ens33"
neutron_external_interface: "ens34"
neutron_plugin_agent: "openvswitch"
neutron_tenant_network_types: "vxlan,vlan,flat"
keepalived_virtual_router_id: "58"
openstack_logging_debug: "True"
enable_ceph: "yes"
enable_ceph_dashboard: "{{ enable_ceph | bool }}"
enable_chrony: "yes"
enable_cinder: "yes"
enable_cinder_backup: "yes"
enable_ceph_dashboard: "{{ enable_ceph | bool }}"
enable_heat: "no"
enable_neutron_provider_networks: "yes"
enable_nova_ssh: "yes"
glance_backend_ceph: "yes"
cinder_backend_ceph: "{{ enable_ceph }}"
cinder_backup_driver: "ceph"
nova_backend_ceph: "{{ enable_ceph }}"
nova_compute_virt_type: "qemu"
nova_console: "novnc"


3.   生成随机密码
kolla-genpwd

4.  修改界面登陆密码为123456
sed -i 's/^keystone_admin_password.*/keystone_admin_password: 123456/' /etc/kolla/passwords.yml

5.  准备后端存储
#格式化
mkfs.ext4  /dev/sdb

数据盘准备ceph的标签
parted /dev/sdb -s -- mklabel gpt mkpart KOLLA_CEPH_OSD_BOOTSTRAP_BS_FOO1 1 -1

6.  设置nova配置文件
mkdir /etc/kolla/config
mkdir /etc/kolla/config/nova
cat >> /etc/kolla/config/nova/nova-compute.conf << EOF
[libvirt]
virt_type = qemu
cpu_mode = none
EOF

7.  创建虚拟机界面禁止默认创建新卷.
mkdir /etc/kolla/config/horizon/
cat >> /etc/kolla/config/horizon/custom_local_settings << EOF
LAUNCH_INSTANCE_DEFAULTS = {'create_volume': False,}
EOF

8.  创建ceph.conf
cat >> /etc/kolla/config/ceph.conf << EOF
[global]
osd pool default size = 1
osd pool default min size = 1
mon_clock_drift_allowed = 2
osd_pool_default_pg_num = 8
osd_pool_default_pgp_num = 8
mon clock drift warn backoff = 30
EOF

11.  开始安装

1.  引导各节点依赖
kolla-ansible -i ./all-in-one bootstrap-servers
自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

2. 检查ansible -i all-in-one all -m ping 
自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

kolla-ansible -i ./all-in-one prechecks
自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

3. 执行部署 kolla-ansible -i ./all-in-one deploy
自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP
#大约需要等待1个多小时完成安装。

 自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

4.  部署完成后生成rc文件
kolla-ansible -i ./all-in-one  post-deploy
自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP
5. 拷贝admin-openrc.sh文件
cp /etc/kolla/admin-openrc.sh  ./
chmod +x admin-openrc.sh
source admin-openrc.sh

6.  安装openstack 包
cd /etc/yum.repos.d/
yum install centos-release-openstack-train  -y
yum makecache fast
yum install python-openstackclient -y
cd

7. 编辑初始化脚本
vim /usr/share/kolla-ansible/init-runonce

EXT_NET_CIDR=${EXT_NET_CIDR:-'192.168.1.0/24'}
EXT_NET_RANGE=${EXT_NET_RANGE:-'start=192.168.1.110,end=192.168.1.150'}
EXT_NET_GATEWAY=${EXT_NET_GATEWAY:-'192.168.1.1'}

8. 执行#这里需要执行pip install kolla-ansible==9.3.1 --ignore-installed PyYAML 不然报错依赖
pip install kolla-ansible==9.3.1 --ignore-installed PyYAML
sh /usr/share/kolla-ansible/init-runonce

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

13. 打开浏览器访问openstack-dashboard控制台
http://192.168.1.29/ admin 123456

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

#安全组允许所有协议通过

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

 13. 镜像上传

1. 镜像下载
mkdir /root/qcow2
cd /root/qcow2
#百度云盘

链接:https://pan.baidu.com/s/1WK_VbWb-f9boOL2-QahIng
提取码:2021

#linux 默认22端口 root cloud5566@MM123
#windows 默认56221端口 administrator cloud5566@MM123

#其它镜像 需要开通会员才能上传大于4G的文件...........

2. 格式转换
yum -y install qemu-img
qemu-img convert CentOS6.8_x86_64bit.qcow2 CentOS6.8_x86_64bit.raw
qemu-img convert Debian_Buster_10.2.0_64bit.qcow2 Debian_Buster_10.2.0_64bit.raw
qemu-img convert Ubuntu_Server_18.04.4_LTS_64bit.qcow2 Ubuntu_Server_18.04.4_LTS_64bit.raw
qemu-img convert Windows_Server_2012_R2_S_CN_64bit.qcow2 Windows_Server_2012_R2_S_CN_64bit.raw


3. 镜像上传
source /root/admin-openrc.sh
openstack image create "CentOS 6.8 64位" --file CentOS6.8_x86_64bit.raw --disk-format raw --container-format bare --property hw_qemu_guest_agent=yes --property os_type=linux --public

openstack image create "Debian_Buster_10.2.0 64位" --file Debian_Buster_10.2.0_64bit.raw --disk-format raw --container-format bare --property hw_qemu_guest_agent=yes --property os_type=linux --public

openstack image create "Ubuntu Server 18.04.4 LTS 64位" --file Ubuntu_Server_18.04.4_LTS_64bit.raw --disk-format raw --container-format bare --property hw_qemu_guest_agent=yes --property os_type=linux --public

openstack image create "Windows Server 2012 R2 中文标准版64位" --file Windows_Server_2012_R2_S_CN_64bit.raw --disk-format raw --container-format bare --property hw_qemu_guest_agent=yes --property os_admin_user=Administrator --property hw_cpu_max_sockets=2 --property os_type=windows --public


4. 查看镜像是否成功
openstack image list

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

14. 创建实例测试

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

 自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

 自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

 自动化kolla-ansible部署centos7.9+openstack-train-超融合单机架构-LMLPHP

15. 卸载openstack环境

1.卸载openstack
kolla-ansible destroy -i /root/all-in-one --include-images --yes-i-really-really-mean-it

2.所有节点重启系统
reboot

3.所有节点硬盘格式化
dmsetup remove_all
mkfs.ext4  /dev/sdb

4.所有节点重新打ceph标签
parted /dev/sdb -s -- mklabel gpt mkpart KOLLA_CEPH_OSD_BOOTSTRAP_BS_FOO1 1 -1
04-22 03:03