自動化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 = 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
2. 檢查ansible -i all-in-one all -m ping
kolla-ansible -i ./all-in-one prechecks
3. 執行部署 kolla-ansible -i ./all-in-one deploy
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