实战案例——Ansible部署高可用OpenStack平台

简介: 实战案例——Ansible部署高可用OpenStack平台

实战案例——Ansible部署高可用OpenStack平台

案例描述

1、了解高可用OpenStack平台架构

2、了解Ansible部署工具的使用

3、使用Ansible工具部署OpenStack平台


案例目标

1、部署架构

20201109084243186.png

Dashboard访问采用负载均衡方式,提供VIP地址,平台访问通过VIP地址进行访问,当其中一台控制节点异常时,别一台控制节点可以继续正常工作;MariaDB数据库采用集群式部署,控制节点间数据库相互进行同步。


2、节点规划

Ansible部署高可用OpenStack平台节点规划

IP地址 主机名 节点
172.30.14.10 controller01 控制节点1
172.30.14.11 controller02 控制节点2
172.30.14.12 compute01 计算节点1
172.30.14.13 compute02 计算节点2
192.168.1.109 server Ansible


3、解压提供的server_bak.zip,通过哦VMware Workstation软件打开server_bak虚拟机,其作为Ansible节点。手动最小化安装4台CentOS 7.2系统的服务器,作为OpensStack节点。

【前期准备】

20201109085459292.png

20201109090211201.png

实施步骤

1、基础环境配置

【IP地址配置】

server_bak节点的IP地址

[root@server ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.30.14.20  netmask 255.255.255.0  broadcast 172.30.14.255
        inet6 fe80::20c:29ff:fe7e:4486  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:7e:44:86  txqueuelen 1000  (Ethernet)
        RX packets 391  bytes 29646 (28.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 138  bytes 14205 (13.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.117  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::20c:29ff:fe7e:4490  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:7e:44:90  txqueuelen 1000  (Ethernet)
        RX packets 152  bytes 14224 (13.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 28  bytes 2602 (2.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.1.0.253  netmask 255.255.255.0  broadcast 10.1.0.255
        inet6 fe80::20c:29ff:fe7e:449a  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:7e:44:9a  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 888 (888.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@server ~]# ping -c 5 baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148: icmp_seq=1 ttl=49 time=26.6 ms
64 bytes from 220.181.38.148: icmp_seq=2 ttl=49 time=26.4 ms
64 bytes from 220.181.38.148: icmp_seq=3 ttl=49 time=27.0 ms
64 bytes from 220.181.38.148: icmp_seq=4 ttl=49 time=26.7 ms
64 bytes from 220.181.38.148: icmp_seq=5 ttl=49 time=27.0 ms
--- baidu.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4051ms
rtt min/avg/max/mdev = 26.433/26.782/27.084/0.275 ms
[root@server ~]# 


controller01节点IP地址

[root@controller01 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:19:55:0d brd ff:ff:ff:ff:ff:ff
    inet 172.30.14.10/24 brd 172.30.14.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe19:550d/64 scope link 
       valid_lft forever preferred_lft forever
[root@controller01 ~]# 


controller02节点的IP地址

[root@controller02 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:93:a2:40 brd ff:ff:ff:ff:ff:ff
    inet 172.30.14.11/24 brd 172.30.14.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe93:a240/64 scope link 
       valid_lft forever preferred_lft forever
[root@controller02 ~]# 


compute01节点的IP地址

[root@compute01 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:60:aa:8e brd ff:ff:ff:ff:ff:ff
    inet 172.30.14.12/24 brd 172.30.14.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe60:aa8e/64 scope link 
       valid_lft forever preferred_lft forever
[root@compute01 ~]# 

compute02节点的IP地址

[root@compute02 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:87:88:b4 brd ff:ff:ff:ff:ff:ff
    inet 172.30.14.13/24 brd 172.30.14.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe87:88b4/64 scope link 
       valid_lft forever preferred_lft forever
[root@compute02 ~]# 

2、Ansible安装OpenStack平台

【修改Ansible环境配置】

[root@server ~]# cd /opt/xd-cloud-simple/
[root@server xd-cloud-simple]# ll
total 44
-rwxr-xr-x 1 root root 5964 Sep 28  2019 add_compute_node.sh
-rwxr-xr-x 1 root root 1648 Oct 18 22:31 configuration.cfg
-rwxr-xr-x 1 root root  158 Jun 30  2017 hosts
-rwxr-xr-x 1 root root    0 Jun 20  2017 hosts_ansible
-rwxr-xr-x 1 root root 9740 Sep 27  2019 install.sh
drwxr-xr-x 5 root root 4096 Oct 19 15:52 module
-rwxr-xr-x 1 root root  173 Jun 19  2017 passwd
-rwxr-xr-x 1 root root 1512 Sep 28  2019 roach.sh
-rwxr-xr-x 1 root root  201 Sep 27  2019 test.sh
[root@server xd-cloud-simple]# 

编辑configuration.cfg 环境配置文件,根据实际地址和参数进行修改变量。

[root@server xd-cloud-simple]# vim configuration.cfg

# Xiandian Cloud Platform Installation Script
# taicai.
#-----------------------------------------------
#    Basic Authentication  
#-----------------------------------------------
REGION_NAME=xiandian
DOMAIN_NAME=domain
MGMT_NET_CIDR=172.30.14.0/24
DATA_NET_CIDR=172.30.14.0/24
#-----------------------------------------------
#    System Config
#    Controller Node 
#-----------------------------------------------
CON_IS_HA=yes
CON_VIP_IP=172.30.14.100
CON_HOST_NAME=controller01,controller02
CON_MGMT_DEV_NAME=eth0
CON_MGMT_DEV_IP=172.30.14.10,172.30.14.11
CON_DATA_DEV_NAME=eth0
CON_DATA_DEV_IP=172.30.14.10,172.30.14.11
#-----------------------------------------------
#    Compute Node
#-----------------------------------------------
COM_MGMT_DEV_NAME=eth0
COM_MGMT_DEV_IP=172.30.14.12,172.30.14.13
COM_HOST_NAME=compute01,compute02
COM_DATA_DEV_NAME=eth0
COM_DATA_DEV_IP=172.30.14.12,172.30.14.13
COM_PRI_DEV_NAME=eth1
COM_EXT_DEV_NAME=eth1
NEUTRON_MIN_VLAN_NAME=114
NEUTRON_MAX_VLAN_NAME=120
#-----------------------------------------------
#    Storage Node
#-----------------------------------------------
#STORAGE_MGMT_DEV_NAME=enp9s0
#STORAGE_MGMT_DEV_IP=10.0.1.1,10.0.1.2,10.0.1.3,10.0.1.4
#STORAGE_HOST_NAME=node-1,node-2,node-3,node-4
#STORAGE_DISK_NAME="/dev/sda  /dev/sdb"
#STORAGE_DATA_DEV_NAME=enp10s0
#STORAGE_DATA_DEV_IP=10.0.1.1,10.0.1.2,10.0.1.3,10.0.1.4
#-----------------------------------------------
#    yum repo config
#-----------------------------------------------
NAME1=centos7
URL1=ftp://172.30.14.20/centos7.2/
NAME2=iaas
URL2=ftp://172.30.14.20/iaas/iaas-repo/
ALL_SERVER_ROOT_PASSWORD=000000

在Ansible脚本目录下执行test.sh脚本,清空原始文件。

[root@server xd-cloud-simple]# ./test.sh 
removed ‘/root/.ssh/id_rsa’
removed ‘/root/.ssh/id_rsa.pub’
removed ‘/root/.ssh/known_hosts’
removed ‘/root/.ssh/authorized_keys’
removed directory: ‘/root/.ssh’
[root@server xd-cloud-simple]# 

【一键安装平台】

[root@server xd-cloud-simple]# ./install.s

20201109102807709.png

【查询登录名、密码】

[root@server module]# pwd
/opt/xd-cloud-simple/module
[root@server module]# cat passwd 
OPENSTACK_SERVICE_NAME_PASS=tINfSr5aTz7kgukAfIF7
OPENSTACK_SERVICE_PASS=rilgrqK6eEJilk3HSUDs
OPENSTACK_METADATA_KEY_PASS=4gvjRuWQy2F6zbPIZ1OR
OPENSTACK_KEYSTONE_TOKEN_PASS=L2qIYZaKQPWgvrwEqYM1
DATABASE_PASS=RyEgk2voacCHVzzZRXCv
ADMINISTRATOR_NAME=admin
ADMINISTRATOR_PASS=cAUk6Pv9WZKTw5a3x2Lg
REGION_NAME=xiandian
DOMAIN_NAME=domain
MGMT_NET_CIDR=172.30.14.0/24
DATA_NET_CIDR=172.30.14.0/24
NEUTRON_MIN_VLAN_NAME=114
NEUTRON_MAX_VLAN_NAME=120
NAME1=centos7
URL1=ftp://172.30.14.20/centos7.2/
NAME2=iaas
URL2=ftp://172.30.14.20/iaas/iaas-repo/
ALL_SERVER_ROOT_PASSWORD=000000
CONTROLLER_VIP_IP=172.30.14.100
CONTROLLER_NUM=2
CONTROLLER_VIP_IP=172.30.14.100
CONTROLLER_NODE1_IP=172.30.14.10
CONTROLLER_NODE1_NAME=controller01
CONTROLLER_NODE2_IP=172.30.14.11
CONTROLLER_NODE2_NAME=controller02
COMPUTE_NUM=2
COMPUTE_NODE1_IP=172.30.14.12
COMPUTE_NODE1_NAME=compute01
COMPUTE_NODE2_IP=172.30.14.13
COMPUTE_NODE2_NAME=compute02
MGMT_DEV_NAME=br-mgmt
DATA_DEV_NAME=br-storage
PRI_DEV_NAME=br-prv
EXT_DEV_NAME=br-ex
CON_MGMT_DEV_NAME_1=eth0
CON_MGMT_DEV_IP_NODE_1=172.30.14.10
CON_MGMT_DEV_IP_NODE_2=172.30.14.11
CON_DATA_DEV_NAME_1=eth0
CON_DATA_DEV_IP_NODE_1=172.30.14.10
CON_DATA_DEV_IP_NODE_2=172.30.14.11
COM_MGMT_DEV_NAME_1=eth0
COM_MGMT_DEV_IP_NODE_1=172.30.14.12
COM_MGMT_DEV_IP_NODE_2=172.30.14.13
COM_DATA_DEV_NAME_1=eth0
COM_DATA_DEV_IP_NODE_1=172.30.14.12
COM_DATA_DEV_IP_NODE_2=172.30.14.13
COM_PRI_DEV_NAME_1=eth1
COM_EXT_DEV_NAME_1=eth1
[root@server module]# 

20201109103526559.png

20201109103628160.png

202011091041370.png

【查看控制节点1的地址】

[root@controller01 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
    link/ether 00:0c:29:19:55:0d brd ff:ff:ff:ff:ff:ff
    inet6 fe80::20c:29ff:fe19:550d/64 scope link 
       valid_lft forever preferred_lft forever
3: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN 
    link/ether 1a:81:15:8f:e0:50 brd ff:ff:ff:ff:ff:ff
4: br-mgmt: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 
    link/ether 00:0c:29:19:55:0d brd ff:ff:ff:ff:ff:ff
    inet 172.30.14.10/24 brd 172.30.14.255 scope global br-mgmt
       valid_lft forever preferred_lft forever
    inet 172.30.14.100/32 scope global br-mgmt
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe19:550d/64 scope link 
       valid_lft forever preferred_lft forever
5: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN 
    link/ether 5a:69:a0:d2:76:49 brd ff:ff:ff:ff:ff:ff
[root@controller01 ~]# 

【查看控制节点2的地址】

[root@controller02 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
    link/ether 00:0c:29:93:a2:40 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::20c:29ff:fe93:a240/64 scope link 
       valid_lft forever preferred_lft forever
3: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN 
    link/ether be:e0:c3:ba:35:3a brd ff:ff:ff:ff:ff:ff
4: br-mgmt: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 
    link/ether 00:0c:29:93:a2:40 brd ff:ff:ff:ff:ff:ff
    inet 172.30.14.11/24 brd 172.30.14.255 scope global br-mgmt
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe93:a240/64 scope link 
       valid_lft forever preferred_lft forever
5: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN 
    link/ether 26:9b:7b:4f:e3:44 brd ff:ff:ff:ff:ff:ff
[root@controller02 ~]# 

当controller01节点异常时或者关闭,VIP将自动切换至controller02节点,实现HA控制节点HA服务。

现在,关闭controller01,查看web界面是否还能正常访问。

[root@controller01 ~]# shutdown -h now

【controller01节点异常或者关闭后,controller02节点的IP地址变化情况】

[root@controller02 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
    link/ether 00:0c:29:93:a2:40 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::20c:29ff:fe93:a240/64 scope link 
       valid_lft forever preferred_lft forever
3: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN 
    link/ether be:e0:c3:ba:35:3a brd ff:ff:ff:ff:ff:ff
4: br-mgmt: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 
    link/ether 00:0c:29:93:a2:40 brd ff:ff:ff:ff:ff:ff
    inet 172.30.14.11/24 brd 172.30.14.255 scope global br-mgmt
       valid_lft forever preferred_lft forever
    inet 172.30.14.100/32 scope global br-mgmt
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe93:a240/64 scope link 
       valid_lft forever preferred_lft forever
5: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN 
    link/ether 26:9b:7b:4f:e3:44 brd ff:ff:ff:ff:ff:ff

【从新登录dashboard,查看是否能够正常访问

20201109104720471.png

相关文章
|
3月前
|
消息中间件 缓存 Shell
跟我一起来学OpenStack部署
跟我一起来学OpenStack部署
277 0
|
4月前
|
存储 数据安全/隐私保护 Docker
Kolla-ansible部署openStack
Kolla-ansible部署openStack
407 11
|
3月前
|
存储 Linux 云计算
OpenStack云计算平台搭建
OpenStack 是一个开源的云平台管理项目,通过多个核心组件实现公有云、私有云和混合云的构建与管理。自2010年由NASA和Rackspace联合发起以来,已有众多企业和个人参与开发。OpenStack 简化了云部署流程,支持计算、存储和网络资源的高效管理,并兼容多种虚拟化技术和容器。最新版本为Xena,广泛应用于各行各业,如思科、英特尔等公司。
283 0
|
6月前
|
Linux 网络安全 数据库
openstack 部署单节点
在CentOS 7系统上,配置了一台拥有4核CPU、8GB内存和300GB磁盘的服务器,安装了OpenStack Trian版本。安装完成后,获取了OpenStack管理控制台的登录凭证(admin用户和密码),可访问IP地址192.168.200.249/dashboard进行登录。如果遇到问题,可能需要重新安装以确保纯净环境。
310 0
|
6月前
|
存储 边缘计算 监控
探索未来科技趋势:虚拟化技术与云计算平台OpenStack的概念与实践
在迅猛发展的信息技术时代,企业和组织对于高效、可扩展的计算资源需求日益增长。虚拟化技术和云计算平台OpenStack应运而生,为企业提供了一种灵活、可靠的解决方案。本文将深入探讨虚拟化技术与OpenStack的概念和实践,展示它们在现代科技领域中的重要性和应用前景。
227 3
|
6月前
|
存储 Ubuntu KVM
Ubuntu部署OpenStack踩坑指南:还要看系统版本?
Ubuntu部署OpenStack踩坑指南:还要看系统版本?
Ubuntu部署OpenStack踩坑指南:还要看系统版本?
|
6月前
|
存储 人工智能 调度
虚拟化技术与云计算平台 OpenStack:解锁数字化时代的无限潜能
在数字化时代,虚拟化技术和云计算平台已经成为企业和组织加速创新、提高效率的关键工具。本文将介绍虚拟化技术和OpenStack云计算平台的基本概念,探讨其在实践中的应用,以及它们如何协同作用,为企业带来无限的潜能与机会。
|
8天前
|
运维 应用服务中间件 网络安全
自动化运维的新篇章:使用Ansible进行服务器配置管理
【10月更文挑战第34天】在现代IT基础设施的快速迭代中,自动化运维成为提升效率、确保一致性的关键手段。本文将通过介绍Ansible工具的使用,展示如何实现高效的服务器配置管理。从基础安装到高级应用,我们将一步步揭开自动化运维的神秘面纱,让你轻松掌握这一技术,为你的运维工作带来革命性的变化。
|
4天前
|
运维 应用服务中间件 Linux
自动化运维的利器:Ansible在配置管理中的应用
【10月更文挑战第39天】本文旨在通过深入浅出的方式,向读者展示如何利用Ansible这一强大的自动化工具来优化日常的运维工作。我们将从基础概念讲起,逐步深入到实战操作,不仅涵盖Ansible的核心功能,还会分享一些高级技巧和最佳实践。无论你是初学者还是有经验的运维人员,这篇文章都会为你提供有价值的信息,帮助你提升工作效率。
|
7天前
|
运维 Ubuntu 应用服务中间件
自动化运维工具Ansible的实战应用
【10月更文挑战第36天】在现代IT基础设施管理中,自动化运维已成为提升效率、减少人为错误的关键手段。本文通过介绍Ansible这一流行的自动化工具,旨在揭示其在简化日常运维任务中的实际应用价值。文章将围绕Ansible的核心概念、安装配置以及具体使用案例展开,帮助读者构建起自动化运维的初步认识,并激发对更深入内容的学习兴趣。
27 4