openstack安装部署

Posted 遙遙背影暖暖流星

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openstack安装部署相关的知识,希望对你有一定的参考价值。

openstack的部署安装一

一、OpenStack 环境配置

配置

在这里插入代码片1、控制节点ct
CPU:双核双线程-CPU虚拟化开启
内存:8G	
硬盘:300G
双网卡:VM1-(局域网)192.168.99.21 NAT8-192.168.100.21
操作系统:Centos 7.61810-最小化安装

2、计算节点c1
CPU:双核双线程-CPU虚拟化开启
内存:8G	
硬盘:300G
双网卡:VM1(局域网)-192.168.99.22   NAT8-192.168.100.22
操作系统:Centos 7.61810-最小化安装

3、计算节点c2
CPU:双核双线程-CPU虚拟化开启
内存:8G	
硬盘:300G
双网卡:VM1(局域网)-192.168.99.23  NAT8-192.168.100.23
操作系统:Centos 7.61810-最小化安装
PS:最小内存6G

一、配置项目

基础环境配置
配置项**(所有节点)**:
1、主机名
2、防火墙、核心防护
3、配置Hosts
4、免交互
5、配置DNS
6、配置网卡
7、基础环境依赖包
8、时间同步+周期性计划任务

1、改名三台主机名

hostnamectl set-hostname ct
su

hostnamectl set-hostname c1
su

hostnamectl set-hostname c2
su

2、关闭防火墙

[root@ct ~]# systemctl stop firewalld
[root@ct ~]# systemctl disable firewalld
[root@ct ~]# setenforce 0
[root@ct ~]# vim /etc/sysconfig/selinux 
SELINUX=disabled

3、配置host文件

vmnet1对应

[root@ct ~]# vi /etc/hosts
192.168.99.21 ct
192.168.99.22 c1
192.168.99.23 c2

4、免交户

[root@ct ~]#  ssh-keygen -t rsa	
[root@ct ~]#  ssh-copy-id ct
[root@ct ~]#  ssh-copy-id c1
[root@ct ~]#  ssh-copy-id c2

5、配置NDS

[root@ct ~]# vim /etc/resolv.conf
nameserver 114.114.114.114

6、配置网卡

vmnet8网卡

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens32
UUID=ae9be78a-1b19-4245-8045-bc9a29590008
DEVICE=ens32
ONBOOT=yes
IPADDR=192.168.100.21
NETMASK=255.255.255.0
GATEWAY=192.168.100.254

IPV4_ROUTE_METRIC=90    #添加路由优先

vmnet1设置

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens34

DEVICE=ens34
ONBOOT=yes
IPADDR=192.168.99.21
NETMASK=255.255.255.0
GATEWAY=192.168.99.254


7、安装依赖环境

yum -y install net-tools bash-completion vim gcc gcc-c++ make pcre  pcre-devel expat-devel cmake  bzip2 lrzsz  expat C语言发开库
yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils
#OpenStack 的 train 版本仓库源安装 包,同时安装 OpenStack 客户端和 openstack-selinux 安装包,第二步安装假如个别没有安装上,多重复几次

8、时间同步

ct ->同步阿里云时钟服务器
c1、c2 -> 同步ct

主上

[root@ct ~]# yum install chrony -y
[root@ct ~]# vim /etc/chrony.conf 

#server 0.centos.pool.ntp.org iburst						###注释掉
#server 1.centos.pool.ntp.org iburst						###注释掉
#server 2.centos.pool.ntp.org iburst						###注释掉
#server 3.centos.pool.ntp.org iburst						###注释掉
server ntp6.aliyun.com iburst							###配置阿里云时钟服务器源
allow 192.168.99.0/24							        ###允许192.168.99.0/24网段的主机来同步时钟服务

[root@ct ~]# systemctl enable chronyd
[root@ct ~]# systemctl restart chronyd


两台c1和c2

[root@c1 ~]# yum install chrony -y
[root@c1 ~]# vi /etc/chrony.conf 
#server 0.centos.pool.ntp.org iburst						###注释掉
#server 1.centos.pool.ntp.org iburst						###注释掉
#server 2.centos.pool.ntp.org iburst						###注释掉
#server 3.centos.pool.ntp.org iburst						###注释掉
server ct iburst								        ###配置时钟服务器源

[root@c1 ~]# systemctl enable chronyd.service					###永久开启时间同步服务器
[root@c1 ~]# systemctl restart chronyd.service					###重启时间同步服务器

使用 chronyc sources 命令查询时间同步信息

[root@c1 ~]#  chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? ct                            0   7     0     -     +0ns[   +0ns] +/-    0ns

ct,ct1.ct2设置周期性任务

[root@ct ~]# crontab -e
*/2 * * * * /usr/bin/chronyc sources >>/var/log/chronyc.log  #每隔2分钟同步一次

二、系统环境配置

1、安装、配置MariaDB


[root@ct ~]# yum -y install mariadb mariadb-server python2-Pymysql

#此包用于openstack的控制端连接mysql所需要的模块,如果不安装,则无法连接数据库;此包只安装在控制端

[root@ct ~]# yum -y install libibverbs	


添加MySQL子配置文件,增加如下内容

[root@ct ~]# vim /etc/my.cnf.d/openstack.cnf

[mysqld]
bind-address = 192.168.99.21
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8

[mysqld]
bind-address = 192.168.100.20 #控制节点局域网地址
default-storage-engine = innodb #默认存储引擎
innodb_file_per_table = on #每张表独立表空间文件
max_connections = 4096 #最大连接数
collation-server = utf8_general_ci #默认字符集
character-set-server = utf8

#开启服务

[root@ct my.cnf.d]# systemctl enable mariadb
[root@ct my.cnf.d]# systemctl start mariadb

执行MariaDB 安全配置脚本

[root@ct network-scripts]# Enter current password for root (enter for none): 			#回车
OK, successfully used password, moving on...
..... 

Set root password? [Y/n] y!

Remove anonymous users? [Y/n] y
 ... Success!

Disallow root login remotely? [Y/n] n    #是否不允许root用户远程登陆#
 ... skipping.

Remove test database and access to it? [Y/n] y     #是否删除test测试库

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...
Thanks for using MariaDB!

2、安装RabbitMQ

所有创建虚拟机的指令,控制端都会发送到rabbitmq,node节点监听rabbitmq

[root@ct ~]# yum -y install rabbitmq-server
[root@ct ~]# systemctl enable rabbitmq-server.service
[root@ct ~]# systemctl start rabbitmq-server.service

创建消息队列用户,用于controler和 计算节点连接rabbitmq的认证(关联)

[root@ct ~]# rabbitmqctl add_user openstack RABBIT_PASS

配置openstack用户的操作权限(正则,配置读写权限)

[root@ct ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"

#可查看25672和5672 两个端口(5672是Rabbitmq默认端口,25672是Rabbit的测试工具CLI的端口)
● 选择配置:
● 查看rabbitmq插件列表

[root@ct ~]# rabbitmq-plugins list

 Configured: E = explicitly enabled; e = implicitly enabled
 | Status:   * = running on rabbit@ct
 |/
[  ] amqp_client                       3.6.16
[  ] cowboy                            1.0.4
[  ] cowlib                            1.0.2
[  ] rabbitmq_amqp1_0                  3.6.16
[  ] rabbitmq_auth_backend_ldap        3.6.16
[  ] rabbitmq_auth_mechanism_ssl       3.6.16
[  ] rabbitmq_consistent_hash_exchange 3.6.16
[  ] rabbitmq_event_exchange           3.6.16
[  ] rabbitmq_federation               3.6.16
[  ] rabbitmq_federation_management    3.6.16
[  ] rabbitmq_jms_topic_exchange       3.6.16
[  ] rabbitmq_management               3.6.16
[  ] rabbitmq_management_agent         3.6.16
[  ] rabbitmq_management_visualiser    3.6.16


开启rabbitmq的web管理界面的插件,端口为15672

[root@ct ~]# rabbitmq-plugins enable rabbitmq_management
[root@ct network-scripts]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
  amqp_client
  cowlib
  cowboy
  rabbitmq_web_dispatch
  rabbitmq_management_agent
  rabbitmq_management

Applying plugin configuration to rabbit@ct... started 6 plugins.

检查端口(25672 5672 15672)

[root@ct network-scripts]#  ss -natp | grep 5672
LISTEN     0      128          *:25672                    *:*                   users:(("beam.smp",pid=22541,fd=46))
LISTEN     0      128          *:15672                    *:*                   users:(("beam.smp",pid=22541,fd=57))
TIME-WAIT  0      0      192.168.99.21:53584              192.168.99.21:25672    
LISTEN     0      128         :::5672                    :::*                   users:(("beam.smp",pid=22541,fd=55))

可访问192.168.100.21:15672
默认账号密码均为guest

3、安装memcached

作用:
安装memcached是用于存储session信息;服务身份验证机制(keystone)使用Memcached来缓存令牌 在登录openstack的dashboard时,会产生一些session信息,这些session信息会存放到memcached中

安装Memcached

[root@ct ~]# yum install -y memcached python-memcached
#python-*模块在OpenStack中起到连接数据库的作用

修改Memcached配置文件
vim /etc/sysconfig/memcached

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1,::1,ct"

[root@ct ~]# systemctl enable memcached
[root@ct ~]# systemctl start memcached
[root@ct ~]# netstat -nautp | grep 11211
[root@ct network-scripts]# netstat -nautp | grep 11211
tcp        0      0 192.168.99.21:11211     0.0.0.0:*               LISTEN      23920/memcached
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      23920/memcached
tcp6       0      0 ::1:11211               :::*                    LISTEN      23920/memcached


安装etcd

 yum -y install etcd

cd /etc/etcd/

vim etcd.conf

[root@ct etcd]# cat etcd.conf |grep -v "^#"
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"		//数据目录位置
ETCD_LISTEN_PEER_URLS="http://192.168.99.21:2380"		//监听其他etcd member的url(2380端口,集群之间通讯,域名为无效值)
ETCD_LISTEN_CLIENT_URLS="http://192.168.99.21:2379"		//对外提供服务的地址(2379端口,集群内部的通讯端口)
ETCD_NAME="ct"		//集群中节点标识(名称)
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.99.21:2380"		//该节点成员的URL地址,2380端口:用于集群之间通讯。
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.99.21:2379"
ETCD_INITIAL_CLUSTER="ct=http://192.168.99.21:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"			//集群唯一标识
ETCD_INITIAL_CLUSTER_STATE="new"		//初始集群状态,new为静态,若为existing,则表示此ETCD服务将尝试加入已有的集群
若为DNS,则表示此集群将作为被加入的对象



#数据目录位置
#监听其他etcd member的url(2380端口,集群之间通讯,域名为无效值)
#对外提供服务的地址(2379端口,集群内部的通讯端口)
#集群中节点标识(名称)
#该节点成员的URL地址,2380端口:用于集群之间通讯。

开启服务

[root@ct ~]# systemctl enable etcd.service
[root@ct ~]# systemctl start etcd.service
[root@ct log]# systemctl start etcd.service
[root@ct log]# netstat -anutp |grep 2379
tcp        0      0 192.168.99.21:2379      0.0.0.0:*               LISTEN      25190/etcd
tcp        0      0 192.168.99.21:51642     192.168.99.21:2379      ESTABLISHED 25190/etcd
tcp        0      0 192.168.99.21:2379      192.168.99.21:51642     ESTABLISHED 25190/etcd
[root@ct log]# netstat -anutp |grep 2380
tcp        0      0 192.168.99.21:2380      0.0.0.0:*               LISTEN      25190/etcd


C1、C2安装OpenStack组件

yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils

openstack启动顺序
①先控制节点再计算结算关闭顺序
②先关计算节点,再关控制节点

以上是关于openstack安装部署的主要内容,如果未能解决你的问题,请参考以下文章

OpenStack——自动安装部署

OpenStack——自动安装部署

packstack部署openstacky要多久

openstack安装部署

openstack安装部署

openstack-ocata部署安装