现在Openstack社区的安装部署方式已经开始推荐使用kolla进行部署了,记得年初还是推荐使用ansible方式,我的理解,kolla项目也是基于原来ansible的部署方式,原来ansible的部署方式支持baremetel和lxc容器两种方式进行部署,kolla的部署方式是完全基于docker和ansible两大工具实现。
具体kolla的原理和优势这里就不细讲,请参考官网资料。下面是参考官网的Kolla Deployment Guide做的all-in-one的实验。
物理主机网络配置:
物理主机: 192.168.170.200 192.168.1.200
物理网卡#135 192.168.170.0/24
物理网卡#136 192.168.1.0/24
kolla实验虚拟服务器(virtualbox),配置4CPU,8G内存:
虚拟机桥接地址:
桥接网卡135# enp0s3 192.168.170.201
桥接136# enp0s8 不设置静态地址
操作系统: ubuntu16
实验虚拟机网络配置:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# cat /etc/network/interfaces
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.170.201
netmask 255.255.255.0
gateway 192.168.170.254
dns-nameservers 192.168.170.253
# The provider network interface
auto enp0s8
iface enp0s8 inet manual
up ip link set dev enp0s8 up
down ip link set dev enp0s8 down
|
特别注意!作为neutron_external_interface的网卡enp0s8 ,不能配置静态地址,否则在部署到neutron的时候会出错!
第一次实验,根据官网的这个操作指导进行:
https://docs.openstack.org/kolla-ansible/latest/user/quickstart.html
简要步骤:
1. 安装pip:
1
2
3
|
apt-get update
apt-get
install
python-pip
pip
install
-U pip
|
2. 安装相关的依赖包:
1
|
apt-get
install
python-dev libffi-dev gcc libssl-dev python-selinux
|
3. 安装ansible,版本要求Ansible >2.0
1
|
pip
install
-U ansible 或者: apt-get
install
ansible
|
4.安装docker
1
|
curl -sSL https:
//get
.docker.io |
bash
|
检查docker版本,版本需要在范围 docker-engine>=1.10.0,!=1.13.0
1
|
docker --version
|
5. 修改docker配置文件
1
2
|
# Create the drop-in unit directory for docker.service
mkdir
-p
/etc/systemd/system/docker
.service.d
|
1
2
|
# Create the drop-in unit file
tee
/etc/systemd/system/docker
.service.d
/kolla
.conf <<-
'EOF'
|
1
2
3
|
[Service]
MountFlags=shared
EOF
|
重启docker:
1
2
3
|
# Run these commands to reload the daemon
systemctl daemon-reload
systemctl restart docker
|
6.安装ntp
1
|
apt-get
install
ntp
|
7. 关闭libvirt:
1
2
|
service libvirt-bin stop
update-rc.d libvirt-bin disable
|
8.安装kolla-ansible:
1
|
pip
install
kolla-ansible
|
9.拷贝 globals.yml and passwords.yml
1
|
cp
-r
/usr/local/share/kolla-ansible/etc_examples/kolla
/etc/kolla/
|
10.拷贝inventory files 到当前目录:
1
|
cp
/usr/local/share/kolla-ansible/ansible/inventory/
* .
|
11.拷贝 Kolla and Kolla-Ansible repositories
1
2
|
git clone https:
//github
.com
/openstack/kolla
git clone https:
//github
.com
/openstack/kolla-ansible
|
12.拷贝globals.yml and passwords.yml到etc/kolla目录
1
|
cp
-r kolla-ansible
/etc/kolla
/etc/kolla/
|
13.拷贝inventory files 到当前目录:
1
|
cp
kolla-ansible
/ansible/inventory/
* .
|
14. 修改文件 /etc/kolla/globals.yml,编辑网络接口参数:
1
2
3
|
network_interface:
"enp0s3"
neutron_external_interface:
"enp0s8"
kolla_internal_vip_address:
"192.168.170.210"
|
openstack_release:"4.0.0" #注意这里是一个坑,默认安装这个参数的值是“auto”,实际安装的时候报错说找不到相应的5.0.0版本,查阅了相关的文档,4.0.0对应的是pike(P版),那么5.0.0版本应该对应Q版,截止到2017年10月应该还在开发测试阶段。
15.生成passwords
1
|
kolla-genpwd
|
16.生成playbook 。
1
|
kolla-ansible -i <<inventory
file
>> bootstrap-servers
|
其中<<inventory file>> 替换为inventory文件,这里我们使用all-in-one,即所有组件安装在一个节点: /home/ywb/kolla-ansible/ansible/inventory/all-in-one
1
|
kolla-ansible -i
/home/ywb/kolla-ansible/ansible/inventory/all-in-one
bootstrap-servers
|
碰到问题:安装过程中碰到重启docker失败,经过网上查找原因,解决方法如下:
假如又碰到 Error starting daemon: error initializing graphdriver: /var/lib/docker contains several valid graphdrivers: overlay2, aufs; Please cleanup or explicitly choose storage driver (-s <DRIVER>),若你確定你 container 的資料都在 /var/lib/docker/aufs 內,可以移除 /var/lib/docker/overlay2 資料夾,再 launch daemon 一次應該就可以了!
17. 如果是物理机上部署,确认支持kvm的kernel是不是打开:
1
|
egrep
-c
'(vmx|svm)'
/proc/cpuinfo
|
如果是虚拟机上实验部署,执行下面的命令使用qemu:
1
2
3
4
5
6
|
mkdir
-p
/etc/kolla/config/nova
cat
<< EOF >
/etc/kolla/config/nova/nova-compute
.conf
[libvirt]
virt_type = qemu
cpu_mode = none
EOF
|
17.构建container images
编辑文件: /etc/systemd/system/docker.service.d/kolla.conf
1
2
3
4
5
6
|
[Service]
MountFlags=shared
ExecStart=
ExecStart=/usr/bin/docker daemon \
-H fd:// \
--mtu 1400
|
重启docker:
1
2
|
systemctl daemon-reload
systemctl restart docker
|
18. 部署前的检查:
1
|
kolla-ansible prechecks -i
/home/ywb/kolla-ansible/ansible/inventory/all-in-one
|
碰到问题:检查到rabbitq的时候,要求地址能够解析,在/etc/hosts中增加对主机两个网卡地址 192.168.170.201 和 192.168.1.201地址的解析
19. 部署 OpenStack:
1
|
kolla-ansible deploy -i
/home/ywb/kolla-ansible/ansible/inventory/all-in-one
|
碰到问题:Tag 5.0.0 not found in repository docker.io/kolla/centos-binary-fluentd
解决方法:在 /etc/kolla/globals.yml 中,将 openstack_release 参数改为: "4.0.0"
(前面参数说明已经讲到这个问题)
另外,可以使用阿里云的docker容器加速器,使用方法:
需要登录阿里云,在容器Hub服务的控制台,左侧的加速器帮助页面就会显示为你独立分配的加速地址。具体使用方法可以在网上查。我的阿里云加速器地址:https://h4ez0olj.mirror.aliyuncs.com
在/etc/systemd/system/docker.service.d/kolla.conf文件中,修改参数
1
2
3
|
ExecStart=/usr/bin/docker daemon \
-H fd:// \
--mtu 1400
|
后面增加 --registry-mirror 参数,修改后如下:
1
2
3
|
ExecStart=/usr/bin/docker daemon --registry-mirror=https://h4ez0olj.mirror.aliyuncs.com \
-H fd:// \
--mtu 1400
|
然后重启服务:
1
2
|
systemctl daemon-reload
systemctl restart docker
|
等待几个小时之后,安装部署完成,检查docker镜像:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
root@kolla:
/home/ywb
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kolla
/centos-binary-nova-compute
4.0.0 35da27fc5586 7 months ago 1.233 GB
kolla
/centos-binary-nova-ssh
4.0.0 3b0f5591ecc8 7 months ago 723.1 MB
kolla
/centos-binary-nova-placement-api
4.0.0 8a16c227e835 7 months ago 755.4 MB
kolla
/centos-binary-nova-conductor
4.0.0 65a844b9889e 7 months ago 703.4 MB
kolla
/centos-binary-nova-api
4.0.0 d90b06229654 7 months ago 755.3 MB
kolla
/centos-binary-nova-consoleauth
4.0.0 487d0b6926d3 7 months ago 703.6 MB
kolla
/centos-binary-nova-scheduler
4.0.0 92bdcfc854ac 7 months ago 703.4 MB
kolla
/centos-binary-nova-novncproxy
4.0.0 7f246ab0d8f5 7 months ago 704.1 MB
kolla
/centos-binary-kolla-toolbox
4.0.0 d771b993a59b 7 months ago 730.5 MB
kolla
/centos-binary-keystone
4.0.0 9b0c48681973 7 months ago 677.1 MB
kolla
/centos-binary-glance-registry
4.0.0 68da81d330c4 7 months ago 757.2 MB
kolla
/centos-binary-haproxy
4.0.0 420fb3e8ce55 7 months ago 438.9 MB
kolla
/centos-binary-cron
4.0.0 74a89fe112f0 7 months ago 417.8 MB
kolla
/centos-binary-openvswitch-db-server
4.0.0 37f21379cad8 7 months ago 439.6 MB
kolla
/centos-binary-glance-api
4.0.0 bc61de7fba03 7 months ago 816 MB
kolla
/centos-binary-fluentd
4.0.0 5b98e39f1285 7 months ago 720.4 MB
kolla
/centos-binary-nova-libvirt
4.0.0 b21c5bacfbcf 7 months ago 966.2 MB
kolla
/centos-binary-openvswitch-vswitchd
4.0.0 b047dd6e83cd 7 months ago 439.6 MB
kolla
/centos-binary-memcached
4.0.0 927246be7bd2 7 months ago 418.4 MB
kolla
/centos-binary-rabbitmq
4.0.0 c9e9af5a39b9 7 months ago 477.5 MB
kolla
/centos-binary-mariadb
4.0.0 7c9305397257 7 months ago 807.8 MB
kolla
/centos-binary-keepalived
4.0.0 b8fb9f966ac4 7 months ago 423.3 MB
root@kolla:
/home/ywb
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kolla
/centos-binary-neutron-server
4.0.0 8dedaf87d819 7 months ago 727.2 MB
kolla
/centos-binary-nova-compute
4.0.0 35da27fc5586 7 months ago 1.233 GB
kolla
/centos-binary-neutron-openvswitch-agent
4.0.0 d276dcdfcbb6 7 months ago 726.5 MB
kolla
/centos-binary-neutron-metadata-agent
4.0.0 e1c0bf5f7745 7 months ago 703.3 MB
kolla
/centos-binary-heat-api
4.0.0 66332a0e6ad4 7 months ago 643.7 MB
kolla
/centos-binary-neutron-dhcp-agent
4.0.0 445442cd0f01 7 months ago 703.3 MB
kolla
/centos-binary-neutron-l3-agent
4.0.0 445442cd0f01 7 months ago 703.3 MB
kolla
/centos-binary-heat-api-cfn
4.0.0 ce92766d3ff1 7 months ago 643.7 MB
kolla
/centos-binary-nova-ssh
4.0.0 3b0f5591ecc8 7 months ago 723.1 MB
kolla
/centos-binary-nova-placement-api
4.0.0 8a16c227e835 7 months ago 755.4 MB
kolla
/centos-binary-nova-conductor
4.0.0 65a844b9889e 7 months ago 703.4 MB
kolla
/centos-binary-nova-api
4.0.0 d90b06229654 7 months ago 755.3 MB
kolla
/centos-binary-nova-consoleauth
4.0.0 487d0b6926d3 7 months ago 703.6 MB
kolla
/centos-binary-nova-scheduler
4.0.0 92bdcfc854ac 7 months ago 703.4 MB
kolla
/centos-binary-nova-novncproxy
4.0.0 7f246ab0d8f5 7 months ago 704.1 MB
kolla
/centos-binary-kolla-toolbox
4.0.0 d771b993a59b 7 months ago 730.5 MB
kolla
/centos-binary-keystone
4.0.0 9b0c48681973 7 months ago 677.1 MB
kolla
/centos-binary-glance-registry
4.0.0 68da81d330c4 7 months ago 757.2 MB
kolla
/centos-binary-horizon
4.0.0 dc5a666631eb 7 months ago 862.8 MB
kolla
/centos-binary-haproxy
4.0.0 420fb3e8ce55 7 months ago 438.9 MB
kolla
/centos-binary-cron
4.0.0 74a89fe112f0 7 months ago 417.8 MB
kolla
/centos-binary-openvswitch-db-server
4.0.0 37f21379cad8 7 months ago 439.6 MB
kolla
/centos-binary-heat-engine
4.0.0 ab9138c4719c 7 months ago 643.7 MB
kolla
/centos-binary-glance-api
4.0.0 bc61de7fba03 7 months ago 816 MB
kolla
/centos-binary-fluentd
4.0.0 5b98e39f1285 7 months ago 720.4 MB
kolla
/centos-binary-nova-libvirt
4.0.0 b21c5bacfbcf 7 months ago 966.2 MB
kolla
/centos-binary-openvswitch-vswitchd
4.0.0 b047dd6e83cd 7 months ago 439.6 MB
kolla
/centos-binary-memcached
4.0.0 927246be7bd2 7 months ago 418.4 MB
kolla
/centos-binary-rabbitmq
4.0.0 c9e9af5a39b9 7 months ago 477.5 MB
kolla
/centos-binary-mariadb
4.0.0 7c9305397257 7 months ago 807.8 MB
kolla
/centos-binary-keepalived
4.0.0 b8fb9f966ac4 7 months ago 423.3 MB
root@kolla:
/home/ywb
# docker images|wc
32 254 3738
root@kolla:
/home/ywb
# docker ps |wc
32 322 5726
|
可以看到一共下载安装了32个镜像。
整个安装过程最关键的是/etc/kolla/global.yml配置文件,以及kolla-ansible/ansible/inventory/all-in-one 配置文件。
global.yml配置文件配置所有的环境变量,强烈建议通读一遍配置文件。
kolla-ansible/ansible/inventory/all-in-one 配置文件定义了每一个openstack组件部署在具体哪一台服务器,定义了整个云环境的部署结构,强烈建议通读检查一遍。
本文转自yuweibing51CTO博客,原文链接:http://blog.51cto.com/yuweibing/1976882 ,如需转载请自行联系原作者