使用Kolla部署Pike版本的OpenStack-多节点云平台

讲师MK:学习中遇到问题可以私信老师帮你解决

准备硬件环境

新创建3台虚拟机,分别作为controller节点,compute节点,storage节点。其中controller节点2张网卡,compute、storage节点各1张网卡。操作系统为centos7.5

注:controller节点 也作为安装结点

主机名 IP 角色 内存 网卡类型

xuegod63 192.168.1.63 controller节点 8G ens33和ens38都桥接

xuegod64 192.168.1.64 compute节点 4G ens33桥接

xuegod62 192.168.1.62 storage节点 4G ens33桥接

注:每个主机的ens33网卡作为内部管理openstack的网络和web界面的网络接口。 controller节点的ens38网卡作为 对外的 网络。 compute和storage一张即可,因为不需要tunnel网络,直接使用1个网卡。

实验拓扑图:

扫描二维码关注公众号,回复: 4184026 查看本文章

xuegod63再添加1个网卡:两个网卡都是桥接

准备xuegod62 存储结点环境

只用一个网卡,storage节点新加一块磁盘,作为cinder的lvm后端。内存使用4G

xuegod64 computer结点,内存改成4G,只用一个网卡

linux系统环境配置

3台机器开始做初始化配置,以一下步骤需要在每一台机器上操作

1、关闭Selinux和防火墙

[root@xuegod63 ~]# vim /etc/selinux/config

SELINUX=disabled

[root@xuegod63 ~]# reboot #如果原来的系统开着selinux,那么需要重启,才能关闭selinux

2、关闭Firewalld

[root@xuegod63 ~]# systemctl stop firewalld && systemctl disable firewalld && systemctl status firewalld

[root@xuegod62 ~]# systemctl stop firewalld && systemctl disable firewalld && systemctl status firewalld

[root@xuegod64 ~]# systemctl stop firewalld && systemctl disable firewalld && systemctl status firewalld

3、安装 Epel源

[root@xuegod63 ~]# mv /opt/CentOS-* /etc/yum.repos.d/ #这个在大家的机器上不需要执行。因为我的centos自带的yum源配置文件,被移走了

[root@xuegod63 ~]# yum install epel-release -y

[root@xuegod62 ~]# yum install epel-release -y

[root@xuegod64 ~]# yum install epel-release -y

4、配置 Hostname

[root@xuegod63 ~]# echo xuegod63.cn > /etc/hostname

[root@xuegod62 ~]# echo xuegod62.cn > /etc/hostname

[root@xuegod64 ~]# echo xuegod64.cn > /etc/hostname

5、配置/etc/hosts

[root@xuegod63 ~]# vim /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.63 xuegod63.cn xuegod63

192.168.1.64 xuegod64.cn xuegod64

192.168.1.62 xuegod62.cn xuegod62

[root@xuegod63 ~]# scp /etc/hosts 192.168.1.64:/etc/

[root@xuegod63 ~]# scp /etc/hosts 192.168.1.62:/etc/

注:hosts文件中的短主机名,给rabbitmq使用的。 rabbitmq服务会使用短主机域名

6、同步时间

[root@xuegod63 ~]# yum install ntp -y && systemctl enable ntpd.service && systemctl start ntpd.service

[root@xuegod62 ~]# yum install ntp -y && systemctl enable ntpd.service && systemctl start ntpd.service

[root@xuegod64 ~]# yum install ntp -y && systemctl enable ntpd.service && systemctl start ntpd.service

7、配置xuegod63上 pip 软件包源,方便快速下载python库(这一步很重要)

[root@xuegod63 ~]# mkdir ~/.pip

[root@xuegod63 ~]# vim /root/.pip/pip.conf #写入下以内容

[global]

index-url = http://mirrors.aliyun.com/pypi/simple/

[install]

trusted-host=mirrors.aliyun.com

6.1.2 配置xuegod63网卡信息

生成ens38的网卡配置文件

[root@xuegod63 ~]#cd /etc/sysconfig/network-scripts/

[root@xuegod63 network-scripts]# cp ifcfg-ens33 ifcfg-ens38

[root@xuegod63 network-scripts]# vim ifcfg-ens38

TYPE="Ethernet"

BOOTPROTO="none"

NAME="ens38"

DEVICE="ens38"

ONBOOT="yes"

检查一下ens33网卡配置文件,发现在新添加网卡,重启系统后,启动协议变了,现在改回来。

[root@xuegod63 network-scripts]# vim ifcfg-ens33

改:BOOTPROTO="dhcp"

为:BOOTPROTO="none"

[root@xuegod63 network-scripts]# service network restart

查看网络:

[root@xuegod63 network-scripts]# ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 192.168.1.63 netmask 256.256.255.0 broadcast 192.168.1.255

。。。

ens38: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 #不用配置IP

inet6 fe80::20c:29ff:fe49:1fe2 prefixlen 64 scopeid 0x20<link>

6.1.3 在3台机器上安装基础包和docker服务

1、安装基础包和必要的一些系统工具,只在xuegod63上操作,因为xuegod63是部署节点,这些包是安装kolla-ansible必需要的。单纯的controller节点,只需要安装一个docker服务就可以了,因为controller需要的软件包,都在docker镜像中包括了,不需要再安装软件的。

注:xuegod63充当了两个角色: kolla-ansible 部署节点, 和 controller 节点

拓扑图如下:

[root@xuegod63 network-scripts]# yum install python-devel libffi-devel gcc openssl-devel git python-pip -y

[root@xuegod63 ~]# pip install -U pip #升级一下pip,不然后,后期安装会报警告

[root@xuegod63 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2

[root@xuegod63 ~]# yum install ansible #安装ansible

2、添加docker yum源并安装docker

关闭libvirtd服务:

[root@xuegod63 ~]# systemctl stop libvirtd.service && systemctl disable libvirtd.service && systemctl status libvirtd.service

[root@xuegod62 ~]# systemctl stop libvirtd.service && systemctl disable libvirtd.service && systemctl status libvirtd.service

[root@xuegod64 ~]# systemctl stop libvirtd.service && systemctl disable libvirtd.service && systemctl status libvirtd.service

如果有的话,卸载旧的Docker,否则可能会不兼容:

[root@xuegod63 ~]# yum remove docker docker-io docker-selinux python-docker-py

[root@xuegod62 ~]# yum remove docker docker-io docker-selinux python-docker-py

[root@xuegod64 ~]# yum remove docker docker-io docker-selinux python-docker-py

因为咱们centos默认安装的是docker版本,而kolla使用的是docker-ce版本。

添加docker-ce yum源配置文件并安装docker

[root@xuegod63 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

[root@xuegod62 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

[root@xuegod64 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

更新并安装 Docker-CE社区版本

[root@xuegod63 ~]# yum -y install docker-ce

[root@xuegod62 ~]# yum -y install docker-ce

[root@xuegod64 ~]# yum -y install docker-ce

开启Docker服务

[root@xuegod63 ~]# systemctl start docker && systemctl enable docker && systemctl status docker

[root@xuegod62 ~]# systemctl start docker && systemctl enable docker && systemctl status docker

[root@xuegod64 ~]# systemctl start docker && systemctl enable docker && systemctl status docker

3、设置3台服务器的docker volume卷挂载方式和docker镜像加速器

[root@xuegod63 ~]# mkdir /etc/systemd/system/docker.service.d

[root@xuegod63 ~]# tee /etc/systemd/system/docker.service.d/kolla.conf << 'EOF'

[Service]

MountFlags=shared

EOF

设置 docker 镜像加速器
[root@xuegod63 ~]# vim /etc/docker/daemon.json

{

"registry-mirrors": ["https://e9yneuy4.mirror.aliyuncs.com"]

}

注:如果需要使用自己的本地私有仓库,写成如下:

{

"registry-mirrors": ["https://e9yneuy4.mirror.aliyuncs.com"]

  "insecure-registries": ["192.168.1.63:4000"]

}

重启相关服务

[root@xuegod63 ~]# systemctl daemon-reload

[root@xuegod63 ~]# systemctl enable docker && systemctl restart docker && systemctl status docker

 
xuegod62设置 volume 挂载方式

[root@xuegod62 ~]# mkdir /etc/systemd/system/docker.service.d

[root@xuegod62 ~]# tee /etc/systemd/system/docker.service.d/kolla.conf << 'EOF'

[Service]

MountFlags=shared

EOF

设置 docker 镜像加速器
[root@xuegod62 ~]# vim /etc/docker/daemon.json

{

"registry-mirrors": ["https://e9yneuy4.mirror.aliyuncs.com"]

}

重启相关服务

[root@xuegod62 ~]# systemctl daemon-reload

[root@xuegod62 ~]# systemctl enable docker && systemctl restart docker && systemctl status docker

xuegod64设置 volume 挂载方式

[root@xuegod64 ~]# mkdir /etc/systemd/system/docker.service.d

[root@xuegod64 ~]# tee /etc/systemd/system/docker.service.d/kolla.conf << 'EOF'

[Service]

MountFlags=shared

EOF

设置 docker 镜像加速器
[root@xuegod64 ~]# vim /etc/docker/daemon.json

{

"registry-mirrors": ["https://e9yneuy4.mirror.aliyuncs.com"]

}

重启相关服务

[root@xuegod64 ~]# systemctl daemon-reload

[root@xuegod64 ~]# systemctl enable docker && systemctl restart docker && systemctl status docker

6.1.4 xuegod62 storage配置cinder存储信息

[root@xuegod62 ~]# ls /dev/sdb

/dev/sdb

[root@xuegod62 ~]# pvcreate /dev/sdb

Physical volume "/dev/sdb" successfully created.

[root@xuegod62 ~]# vgcreate cinder-volumes /dev/sdb #创建一个名字为cinder-volumes的卷组,给后期cinder使用

Volume group "cinder-volumes" successfully created

[root@xuegod62 ~]# systemctl enable lvm2-lvmetad.service

[root@xuegod62 ~]# vgs

VG #PV #LV #SN Attr VSize VFree

cinder-volumes 1 0 0 wz--n- <20.00g <20.00g

到此3台机器的基础软件包环境已经安装好。

6.2 安装kolla-ansible

1、安装kolla-ansible

注:kolla-ansible可以实现使用ansible自动安装docker

[root@xuegod63 ~]# pip install kolla-ansible

注:官方推荐部署环境使用pip install kolla-ansible 方式来安装kolla-ansible

https://docs.openstack.org/kolla-ansible/latest/user/quickstart.html #官方安装手册

2、复制kolla-ansible的相关配置文件

[root@xuegod63 ~]# cp -r /usr/share/kolla-ansible/etc_examples/kolla /etc/

[root@xuegod63 ~]# cp /usr/share/kolla-ansible/ansible/inventory/* /etc/kolla/

[root@xuegod63 kolla-ansible]# ls /etc/kolla/

all-in-one globals.yml multinode passwords.yml

注:all-in-one #安装单节点openstack的ansible自动安装配置文件,就是ansible主机清单文件

multinode #安装多节点openstack的ansible自动安装配置文件,就是ansible主机清单文件

globals.yml #部署openstack的自定义配置文件

passwords.yml #openstack中各个服务的密码

4、修改虚拟机类型为qemu

注:如果是在虚拟机里装kolla,希望可以在虚拟机中再启动虚拟机,那么你需要把virt_type=qemu,默认是kvm。如果vmware开了“虚拟化Intel VT”功能,就不用写这个了。

[root@xuegod63 kolla-ansible]# mkdir -p /etc/kolla/config/nova

[root@xuegod63 kolla-ansible]# cat << EOF > /etc/kolla/config/nova/nova-compute.conf

[libvirt]

virt_type=qemu

cpu_mode = none

EOF

6.3 自定义kolla-ansible安装openstack的相关配置文件

1、自动生成openstack各服务的密码文件

[root@xuegod63 kolla-ansible]# kolla-genpwd

[root@xuegod63 ~]# vim /etc/kolla/passwords.yml

改:162 keystone_admin_password: HsPbEQHxTqmewKYNoRPpIOyQNdEYpHy36OX67TG3

为:keystone_admin_password: 123456

注:这是登录Dashboard,admin使用的密码,你可以根据自己需要进行修改。

2、编辑 /etc/kolla/globals.yml 自定义openstack中部署事项

[root@xuegod63 ~]# vim /etc/kolla/globals.yml #配置openstack安装中的参数

改:15 #kolla_base_distro: "centos" #选择下载的镜像为基于centos版本的镜像

为: kolla_base_distro: "centos"

改:18 #kolla_install_type: "binary" #去了前面的#号,使用yum安装二进制包安装,源码安装,指的是使用git clone源码安装

为:18 kolla_install_type: "binary"

改:21 #openstack_release: ""

为:openstack_release: "pike" #指定安装pike版本的openstack,后期下载的openstack相关的docker镜像的tag标记也都为pike

改:24 #node_custom_config: "/etc/kolla/config" #配置文件的位置

为:24 node_custom_config: "/etc/kolla/config" #去了前面的#号,因为我对nova节点做了自定义。如:我自定义virt_type 虚拟化类型为qemu,默认是kvm。

改:31 kolla_internal_vip_address: "10.10.10.254"

为:31 kolla_internal_vip_address: "192.168.1.63" # 我们没有启用高可用,所以这里的IP可以和ens33一样,也可以独立写一个和ens33同网段的IP。

注:如果配置了高可用,这里要使用一个没被占用的IP。这个IP是搭建HA高可用的浮动IP。 此IP将由keepalived管理以提供高可用性,应设置为和network_interface ens33 同一个网段的地址。

改:85 #network_interface: "eth0"

为: network_interface: "ens33"    #设置OpenStack所以节点内部通信使用的网络接口。这是openstack内部多个管理类型网络的默认接口。这里我们以ens33作为内部通信网络

改: 把前面的#号去了

89 #kolla_external_vip_interface: "{{ network_interface }}"

90 #api_interface: "{{ network_interface }}"

91 #storage_interface: "{{ network_interface }}"

92 #cluster_interface: "{{ network_interface }}"

93 #tunnel_interface: "{{ network_interface }}"

94 #dns_interface: "{{ network_interface }}"

为:

89 kolla_external_vip_interface: "{{ network_interface }}"

90 api_interface: "{{ network_interface }}"

91 storage_interface: "{{ network_interface }}"

92 cluster_interface: "{{ network_interface }}"

93 tunnel_interface: "{{ network_interface }}"

94 dns_interface: "{{ network_interface }}"

注:这样所有内部通信网络都走network_interface ,即ens33

 
改:100 #neutron_external_interface: "eth1"
为:100 neutron_external_interface: "ens38"  # ens38作为外部网络,所需的第二个接口专用于Neutron外部(或公共)网络,可以是vlan或flat,取决于网络的创建方式。 此接口应在没有IP地址的情况下处于活动 如果不是,云主机实例将无法访问外部网络。 所以ens38不能有IP,只要网卡启动着,就可以了。

改:150 #enable_cinder: "no"

为:150 enable_cinder: "yes" #删除最前面的#号,并改no为yes。 启用cinder

改:155 #enable_cinder_backend_lvm: "no"

为:155 enable_cinder_backend_lvm: "yes" #删除最前面的#号,并改no为yes。cinder后端用lvm

改:167 #enable_haproxy: "yes"

为:167 enable_haproxy: "no" #删除最前面的#号,并改yes为no。关闭高可用

改:319 #cinder_volume_group: "cinder-volumes"

为:319 cinder_volume_group: "cinder-volumes" #取消前面的#号,这个卷组的名字是我们在xuegod62上创建的

6.4 开始基于kolla-ansible安装openstack私有云

6.4.1 生成SSH Key,并授信本节点:

[root@xuegod63 ~]# ssh-keygen

[root@xuegod63 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@xuegod63

[root@xuegod63 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@xuegod62

[root@xuegod63 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@xuegod64

注:ssh-copy-id 复制公钥时,后面要写主机名,不要写IP。因为后期ansible自动安装节点,主机清单中写的是主机名不是IP。

6.4.2 配置multinode多结点清单文件

[root@xuegod63 ~]# vim /etc/kolla/multinode #修改成以下红色标记内容

# These initial groups are the only groups required to be modified. The

# additional groups are for more control of the environment.

[control]

# These hostname must be resolvable from your deployment host

xuegod63

# The above can also be specified as follows:

#control[01:03] ansible_user=kolla

# The network nodes are where your l3-agent and loadbalancers will run

# This can be the same as a host in the control group

[network]

xuegod63

# inner-compute is the groups of compute nodes which do not have

# external reachability

[inner-compute]

# external-compute is the groups of compute nodes which can reach

# outside

[external-compute]

xuegod64

[compute:children]

inner-compute

external-compute

[monitoring]

xuegod63

# When compute nodes and control nodes use different interfaces,

# you need to comment out "api_interface" and other interfaces from the global

s.yml

# and specify like below:

#compute01 neutron_external_interface=eth0 api_interface=em1 storage_interface

=em1 tunnel_interface=em1

[storage]

xuegod62

[deployment]

xuegod63

注:配置下面的内容不需要修改。里面的内容很好理解,表示一个控制节点 controller,网络节点也安装到控制节点,一个计算节点 compute ,一个存储节点 storage,后面的部分不用修改

6.4.3 开始部署OpenStack

1、对主机进行预部署检查:

[root@xuegod63 kolla]# kolla-ansible -i /etc/kolla/multinode prechecks

报错:

fatal: [xuegod62]: FAILED! => {"changed": false, "cmd": ["/usr/bin/python", "-c", "import docker; print docker.__version__"],

。。。

, "ImportError: No module named docker"], "stdout": "", "stdout_lines": []}

解决:在xuegod62和xuegod64上执行:

[root@xuegod64 ~]# pip uninstall docker

[root@xuegod64 ~]# pip uninstall docker-py

[root@xuegod64 ~]# pip install -U docker --ignore-installed requests

[root@xuegod63 ~]# kolla-ansible -i /etc/kolla/multinode prechecks #再执行,出现以下界面说明检测没有问题。

2、最后进入实际的OpenStack部署

[root@xuegod63 ~]# kolla-ansible -i /etc/kolla/multinode deploy #因为此时边下载各种openstack相关的镜像并部署docker实例,会比较慢。等待30分钟左右。就可以了。我配置了docker镜像加速结点,所以也会比较快

会先安装xuegod63.

查看xuegod63上的网络连接:

[root@xuegod63 kolla-ansible]# netstat -antup

tcp 0 32 192.168.1.63:33052 116.62.81.173:443 LAST_ACK -

tcp 0 32 192.168.1.63:33116 116.62.81.173:443 LAST_ACK -

[root@xuegod63 kolla-ansible]# docker images #查看下载的镜像

[root@xuegod63 kolla-ansible]# docker ps #查看正在运行的docker实例

报错总结:

如果安装中运行docker实例报错。

解决:

[root@xuegod63 ~]# kolla-ansible -i /etc/kolla/multinode deploy #重新执行一下就可以了

到此安装成功。

3、验证部署

[root@xuegod63 ~]# kolla-ansible post-deploy -i /etc/kolla/multinode

这样就创建 /etc/kolla/admin-openrc.sh 文件

[root@xuegod63 kolla]# ll /etc/kolla/admin-openrc.sh

-rw-r--r-- 1 root root 323 8月 10 17:58 /etc/kolla/admin-openrc.sh

[root@xuegod63 kolla]# cat /etc/kolla/admin-openrc.sh ##查看openstack登录帐号

export OS_PROJECT_DOMAIN_NAME=Default

export OS_USER_DOMAIN_NAME=Default

export OS_PROJECT_NAME=admin

export OS_TENANT_NAME=admin

export OS_USERNAME=admin

export OS_PASSWORD=123456 #帐号和密码

4、测试:http://192.168.1.63 访问成功。

下节课给大家讲OpenStack使用方法!喜欢的同学可以关注老师,持续更新中!

猜你喜欢

转载自blog.51cto.com/xuegod/2320392