之前部署openstack一直都是分组件,写脚本,单独执行,费时费力,还容易出现异常,现在尝试了一下使用自动化工具部署openstack,觉得至少部署的速度飙升。希望感兴趣的可以尝试尝试,这里仅仅为了实验方便,就采用(all-in-one)模式。
① 这个是kolla-ansible的官方网站
https://docs.openstack.org/kolla-ansible/latest/user/quickstart.html
② 这个是ansible的官方网站。
http://docs.ansible.com/
③ 这个是docker的官方网站。
http://docs.ansible.com/
④ 我之前也做了docker的基础实验:
https://blog.csdn.net/qq_28513801/category_8592442.html
主机名 | IP | 网卡 |
---|---|---|
opensatck | 172.31.132.253 | eth0 |
第二块网卡 | eth1 | |
CentOS | 7.5 | |
OpenStack | stein |
[root@openstack ~]# hostnamectl set-hostname --static openstack
[root@openstack ~]# cat /etc/hosts
127.0.0.1 localhost
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.31.132.253 openstack
关闭防火墙,关闭selinux.
[root@openstack ~]# rm -rfv * /etc/yum.repos.d/*
[root@openstack ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@openstack ~]# yum install epel-release
[root@openstack ~]# yum install python-devel libffi-devel gcc openssl-devel libselinux-python -y
[root@openstack ~]# yum install python-pip ansible –y
[root@openstack ~]# pip install -U pip
① 安装 docker-ce
step 1: 安装必要的一些系统工具
# step 1: 安装必要的一些系统工具
[root@openstack ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
[root@openstack ~]# sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新并安装Docker-CE
[root@openstack ~]# sudo yum makecache fast
[root@openstack ~]# sudo yum -y install docker-ce
# Step 4: 开启Docker服务
[root@openstack ~]# systemctl enable docker;systemctl restart docker
[root@openstack ~]# mkdir -p /etc/docker
[root@openstack ~]# tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
[root@openstack ~]# systemctl daemon-reload
[root@openstack ~]# systemctl restart docker
pip install kolla-ansible==8.0.0 #这里版本严格使用8.0.0,否则会报异常错误
可以适当添加源
https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
例如:
pip install kolla-ansible==8.0.0 -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
如果安装过程出现报错,可以先忽略该模块,如果需要就在安装。
例如:
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
则可以先忽略:
pip install kolla-ansible --ignore-installed PyYAML -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
需要就在安装:
pip install XXXX==8.0.0
[root@openstack ~]# mkdir -p /etc/kolla
[root@openstack ~]# chown $USER:$USER /etc/kolla
[root@openstack ~]# cp -r /usr/share/kolla-ansible/etc_examples/kolla/* /etc/kolla/ ##Copy globals.yml and passwords.yml
[root@openstack ~]# cp /usr/share/kolla-ansible/ansible/inventory/* . ##Copy all-in-one and multinode inventory files
[defaults]
host_key_checking=False
pipelining=True
forks=100
[root@openstack ~]# vi all-in-one
# These initial groups are the only groups required to be modified. The
# additional groups are for more control of the environment.
[control]
localhost ansible_connection=local
[network]
localhost ansible_connection=local
[compute]
localhost ansible_connection=local
[storage]
localhost ansible_connection=local
[monitoring]
localhost ansible_connection=local
[deployment]
localhost ansible_connection=local
………………
下面不需要动
[root@openstack ~]# ssh-keygen
[root@openstack ~]# ssh-copy-id root@openstack
检查主机连接
[root@openstack ~]# ansible -i all-in-one all -m ping
localhost | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
[root@openstack ~]# kolla-genpwd
[root@openstack ~]#vim /etc/kolla/passwords.yml
keystone_admin_password: 1111111
kolla_base_distro: "centos"
kolla_install_type: "source"
openstack_release: "stein"
kolla_internal_vip_address: "172.31.132.247"
network_interface: "eth0"
neutron_external_interface: "eth1"
nova_compute_virt_type: "qemu"
keepalived_virtual_router_id: "7"
[root@openstack ~]# kolla-ansible bootstrap-servers ##Bootstrap servers依赖
[root@openstack ~]# kolla-ansible prechecks ##检查配置
[root@openstack ~]# kolla-ansible pull ##pull镜像
[root@openstack ~]# kolla-ansible deploy ##部署
如果部署出错:
[root@openstack ~]# kolla-ansible destroy ./all-in-one --yes-i-really-really-mean-it
1.安装CLI客户端
pip install python-openstackclient
2.生成环境脚本
kolla-ansible post-deploy . /etc/kolla/admin-openrc.sh