環境准備
2 network interfaces
8GB main memory
40GB disk space
1.修改hostname
hostnamectl set-hostname kolla
2.配置域名解析
echo '10.1.10.161 kolla' >> /etc/hosts
Install packages
1.安裝依賴
yum install python-devel libffi-devel gcc openssl-devel libselinux-python -y
2.安裝 pip,ansible
##如果無法安裝python-pip,先導入epel源
yum install epel-release -y
yum install python-pip ansible -y
pip install -U pip
安裝 docker-ce(CentOS 7 使用 yum 進行安裝)
# step 1: 安裝必要的一些系統工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加軟件源信息
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新並安裝Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
# Step 4: 開啟Docker服務
systemctl enable docker;systemctl restart docker
3.配置 docker 鏡像加速
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
systemctl daemon-reload;systemctl restart docker
4.安裝 kolla-ansible
pip install kolla-ansible
##ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall
##出現報錯不能卸載PyYAML,使用下面命令,忽略PyYAML錯誤
pip install kolla-ansible --ignore-installed PyYAML
mkdir -p /etc/kolla
chown $USER:$USER /etc/kolla
##Copy globals.yml and passwords.yml
cp -r /usr/share/kolla-ansible/etc_examples/kolla/* /etc/kolla
##Copy all-in-one and multinode inventory files
cp /usr/share/kolla-ansible/ansible/inventory/* .
Prepare initial configuration
1.Configure Ansible /etc/ansible/ansible.cfg
[defaults] host_key_checking=False pipelining=True forks=100
2.配置主機清單文件,根據部署場景,這里選擇 all-in-one 文件
[control] kolla [network] kolla [compute] kolla [storage] kolla [monitoring] kolla [deployment] kolla
3.對 /etc/kolla/passwords.yml 文件生成隨機密碼,或者修改為自定義密碼
kolla-genpwd vim /etc/kolla/passwords.yml ##admin密碼可以修改為自定義,在登錄dashboard會用到
keystone_admin_password: 1234qwer
4.配置 /etc/kolla/globals.yml 文件
kolla_base_distro: "centos" kolla_install_type: "source" openstack_release: "train" kolla_internal_vip_address: "10.1.10.161" network_interface: "ens32" neutron_external_interface: "ens34" enable_haproxy: "no" nova_compute_virt_type: "qemu"
5.配置 ssh 無密鑰登錄,授權節點
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub root@kolla
Deployment
##檢查主機連接
ansible -i all-in-one all -m ping
##檢查Bootstrap servers依賴
kolla-ansible -i ./all-in-one bootstrap-servers
##檢查配置
kolla-ansible -i ./all-in-one prechecks
##pull鏡像
kolla-ansible pull -i ./all-in-one
##執行部署
kolla-ansible -i ./all-in-one deploy
- 報錯1:
執行kolla-ansible -i ./all-in-one bootstrap-servers
TASK [baremetal : Generate /etc/hosts for all of the nodes] ********************************************************************************************************************************
fatal: [kolla]: FAILED! => {"msg": "The conditional check 'inventory_hostname not in groups['bifrost'] or 'ansible_' + hostvars[inventory_hostname]['api_interface'] in hostvars[inventory_hostname]' failed. The error was: error while evaluating conditional (inventory_hostname not in groups['bifrost'] or 'ansible_' + hostvars[inventory_hostname]['api_interface'] in hostvars[inventory_hostname]): 'ansible.vars.hostvars.HostVars object' has no attribute u'kolla'\n\nThe error appears to have been in '/usr/share/kolla-ansible/ansible/roles/baremetal/tasks/pre-install.yml': line 31, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Generate /etc/hosts for all of the nodes\n ^ here\n"}
to retry, use: --limit @/usr/share/kolla-ansible/ansible/kolla-host.retry
解決辦法:
yum upgrade -y
更新的軟件包如圖

- 報錯2:
執行kolla-ansible -i ./all-in-one prechecks
TASK [prechecks : Checking Docker version] *************************************************************************************************************************************************
fatal: [kolla]: FAILED! => {"msg": "The conditional check 'result is failed or result.stdout | regex_replace('.*(\\\\d+\\\\.\\\\d+\\\\.\\\\d+).*', '\\\\1') is version(docker_version_min, '<')' failed. The error was: template error while templating string: no test named 'version'. String: {% if result is failed or result.stdout | regex_replace('.*(\\\\d+\\\\.\\\\d+\\\\.\\\\d+).*', '\\\\1') is version(docker_version_min, '<') %} True {% else %} False {% endif %}"}
to retry, use: --limit @/usr/share/kolla-ansible/ansible/site.retry
解決辦法:
同上,更新軟件包后一並解決
- 報錯3:
執行kolla-ansible -i ./all-in-one prechecks
TASK [cinder : Checking LVM volume group exists for Cinder] ********************************************************************************************************************************
fatal: [kolla]: FAILED! => {"changed": false, "cmd": ["vgs", "cinder-volumes"], "delta": "0:00:00.023537", "end": "2019-12-27 16:37:44.519563", "failed_when_result": true, "msg": "non-zero return code", "rc": 5, "start": "2019-12-27 16:37:44.496026", "stderr": " Volume group \"cinder-volumes\" not found\n Cannot process volume group cinder-volumes", "stderr_lines": [" Volume group \"cinder-volumes\" not found", " Cannot process volume group cinder-volumes"], "stdout": "", "stdout_lines": []}
解決辦法:
報錯沒錯找到cinder-volumes卷
手動創建
pvcreate /dev/sdb
vgcreate cinder-volumes /dev/sdb
詳細方法參考:https://www.cnblogs.com/omgasw/p/12098312.html
Using OpenStack
1.安裝CLI客戶端
pip install python-openstackclient
2.生成環境腳本
kolla-ansible post-deploy . /etc/kolla/admin-openrc.sh
- 報錯4:
/usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.7) or chardet (2.2.1) doesn't match a supported version
pip uninstall urllib3 pip uninstall chardet pip install --upgrade requests
https://www.cnblogs.com/omgasw/p/12054988.html
- 報錯5:
ImportError: cannot import name decorate
sed -i '/^from decorator import decorate/s/from/#from/' /usr/lib/python2.7/site-packages/dogpile/cache/region.py
https://www.cnblogs.com/omgasw/p/12054817.html
3.使用腳本文件初始化運行環境
/usr/share/kolla-ansible/init-runonce


4.刪除部署的openstack環境
kolla-ansible destroy -i all-in-one --yes-i-really-really-mean-it
參考鏈接:
https://docs.openstack.org/kolla-ansible/latest/user/quickstart.html
