自動化kolla-ansible部署centos7.9+openstack-train-超融合單機架構


自動化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台式電腦硬件配置

 

2. 虛擬軟件配置

#虛擬機下載 VMware-workstation-full-16.1.0-17198959.exe  百度網盤: 鏈接:https://pan.baidu.com/s/1RlgNja260HZtRffN_vc9EA     提取碼:2021 

 

 3. 虛擬機網卡信息

 

 

 

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. 網卡信息

 

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 = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
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_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

2. 檢查ansible -i all-in-one all -m ping 

kolla-ansible -i ./all-in-one prechecks

3. 執行部署 kolla-ansible -i ./all-in-one deploy
#大約需要等待1個多小時完成安裝。

 

4.  部署完成后生成rc文件
kolla-ansible -i ./all-in-one  post-deploy

 

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

 

13. 打開瀏覽器訪問openstack-dashboard控制台
http://192.168.1.29/ admin 123456

 

 

 

 

#安全組允許所有協議通過

 

 

 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

 

14. 創建實例測試

 

 

 

 

 

 

 

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM