openstack环境部署

一.环境规划

主机名内存硬盘网卡系统
ct8300nat:192.168.106.200,vm1:192.168.100.200centos 7.6
c18300nat:192.168.106.210,vm1:192.168.100.210centos 7.6
c28300nat:192.168.106.220,vm1:192.168.100.220centos 7.6

二.基础环境配置

1.修改主机名与网卡

按照环境规划修改主机名

[root@ct ~]# hostnamectl set-hostname ct
[root@ct ~]# su

[root@c1 ~]# hostnamectl set-hostname c1
[root@c1 ~]# su

[root@c2 ~]# hostnamectl set-hostname c2
[root@c2 ~]# su

修改配置文件

[root@ct ~]# cd /etc/sysconfig/network-scripts/
[root@ct network-scripts]# cp ifcfg-ens33 ifcfg-ens37

[root@ct network-scripts]# vi ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=192.168.106.200
NETMASK=255.255.255.0
GATEWAY=192.168.106.2
DNS=192.168.106.2
IPV4_ROUTE_METRIC=90        ###调由优先级,NAT网卡优先
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=ens33
DEVICE=ens33
ONBOOT=yes


[root@ct network-scripts]# vi ifcfg-ens37
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=192.168.100.200
NETMASK=255.255.255.0
#GATEWAY=192.168.100.2  ##内网注释掉
#DNS=192.168.100.2   ##内网
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=ens37
DEVICE=ens37
ONBOOT=yes

2.配置Hosts文件,关闭防火墙与核心防护

[root@ct ~]# vi /etc/hosts  ##配置hosts
//添加局域网IP
192.168.100.210 ct
192.168.100.220 c1
192.168.100.230 c2

[root@ct ~]# systemctl stop firewalld  ##关闭防火墙与核心防护
[root@ct ~]# systemctl disable firewalld
[root@ct ~]# setenforce 0
[root@ct ~]# vim /etc/sysconfig/selinux
SELINUX=disabled		//修改

3.做免交互

非对称密钥,每台都要做

[root@ct ~]#  ssh-keygen -t rsa		//一直回车  
[root@ct ~]#  ssh-copy-id ct		//输入yes与密码
[root@ct ~]#  ssh-copy-id c1		//输入yes与密码
[root@ct ~]#  ssh-copy-id c2		//输入yes与密码

[root@ct ~]# vi /etc/resolv.conf  ##配置DNS(所以节点)
nameserver 114.114.114.114

4.安装基础环境依赖包

yum -y install net-tools bash-completion vim gcc gcc-c++ make pcre  pcre-devel expat-devel cmake  bzip2 
yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils

5.时间同步与周期性计划任务

ct同步阿里云,c1与c2同步ct

时间节点ct时间同步配置

[root@ct ~]# yum install chrony -y
[root@ct ~]# vim /etc/chrony.conf 
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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 ntp1.aliyun.com iburst			//注释及修改

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2

# Allow NTP client access from local network.
#allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.
#local stratum 10

# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking


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

//使用chronyc sources命令查询时间同步信息
[root@ct ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 120.25.115.20                 2   9   377    22  -1510us[-1696us] +/-   18ms

//设置周期性计划任务
[root@ct ~]# crontab -e
*/30 * * * * /usr/bin/chrony sources >> /var/log/chronyc.log

c1与c2节点同步ct(步骤相同)

[root@c1 ~]# yum install chrony -y
[root@c1 ~]# vim /etc/chrony.conf 
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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			//注释及修改

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2

# Allow NTP client access from local network.
#allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.
#local stratum 10

# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking


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

//使用chronyc sources命令查询时间同步信息
[root@c1 ~]#  chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? ct                            0   9     0     -     +0ns[   +0ns] +/-    0ns


//设置周期性计划任务
[root@c1 ~]# crontab -e
*/30 * * * * /usr/bin/chrony sources >> /var/log/chronyc.log

三.系统环境配置

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.100.200			//控制节点局域网地址
default-storage-engine = innodb 		//默认存储引擎 
innodb_file_per_table = on 				//每张表独立表空间文件
max_connections = 4096 					//最大连接数 
collation-server = utf8_general_ci 		//默认字符集 
character-set-server = utf8

//开启自启动、开启服务
[root@ct ~]# systemctl enable mariadb
[root@ct ~]# systemctl start mariadb

//执行MariaDB安全配置脚本
[root@ct my.cnf.d]# mysql_secure_installation
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
 ... skipping.
Remove test database and access to it? [Y/n] Y 
Reload privilege tables now? [Y/n] Y 	

2.安装RabbitMQ

所有创建虚拟机的指令,控制端都会发送到rabbitmq,其他节点监听rabbitmq
[root@ct ~]# yum -y install rabbitmq-server

//配置服务,启动RabbitMQ服务,并设置其开机启动。
[root@ct ~]# systemctl enable rabbitmq-server.service
[root@ct ~]# systemctl start rabbitmq-server.service

//创建消息队列用户,用于controler和node节点连接rabbitmq的认证
[root@ct ~]# rabbitmqctl add_user openstack RABBIT_PASS
Creating user "openstack"

//配置openstack用户的操作权限(正则,配置读写权限)
[root@ct ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/"

//可查看25672和5672 两个端口(5672是Rabbitmq默认端口,25672是Rabbit的测试工具CLI的端口)

//选择配置
查看rabbitmq插件列表
[root@ct ~]# rabbitmq-plugins list

开启rabbitmq的web管理界面的插件,端口为15672
[root@ct ~]# rabbitmq-plugins enable rabbitmq_management

检查端口
[root@ct ~]# ss -antp | grep 5672
LISTEN     0      128          *:25672                    *:*                   users:(("beam.smp",pid=7887,fd=46))
LISTEN     0      128          *:15672                    *:*                   users:(("beam.smp",pid=7887,fd=57))
LISTEN     0      128       [::]:5672                  [::]:*                   users:(("beam.smp",pid=7887,fd=55

可访问192.168.106.200:15672,密码账号均为guest

3.安装memcached

作用

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

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

//修改memcached配置文件
[root@ct ~]# vi /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

4.安装etcd

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

//修改etcd配置文件
[root@ct ~]# cat /etc/etcd/etcd.conf
#[Member]
#ETCD_CORS=""
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"  ##数据目录位置
#ETCD_WAL_DIR=""
ETCD_LISTEN_PEER_URLS="http://192.168.100.200:2380"  ##改ip 
ETCD_LISTEN_CLIENT_URLS="http://192.168.100.200:2379"##改ip
#ETCD_MAX_SNAPSHOTS="5"
#ETCD_MAX_WALS="5"
ETCD_NAME="ct"  ##改成控制节点hosts名称
#ETCD_SNAPSHOT_COUNT="100000"
#ETCD_HEARTBEAT_INTERVAL="100"
#ETCD_ELECTION_TIMEOUT="1000"
#ETCD_QUOTA_BACKEND_BYTES="0"
#ETCD_MAX_REQUEST_BYTES="1572864"
#ETCD_GRPC_KEEPALIVE_MIN_TIME="5s"
#ETCD_GRPC_KEEPALIVE_INTERVAL="2h0m0s"
#ETCD_GRPC_KEEPALIVE_TIMEOUT="20s"
#
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.100.200:2380"##改ip
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.100.200:2379"##改ip
#ETCD_DISCOVERY=""
#ETCD_DISCOVERY_FALLBACK="proxy"
#ETCD_DISCOVERY_PROXY=""
#ETCD_DISCOVERY_SRV=""
ETCD_INITIAL_CLUSTER="ct=http://192.168.100.200:2380"##改ip
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-1" ##取消注释 ,节点名称
ETCD_INITIAL_CLUSTER_STATE="new"  ##取消注释
#ETCD_STRICT_RECONFIG_CHECK="true"
#ETCD_ENABLE_V2="true"
#
#[Proxy]
#ETCD_PROXY="off"
#ETCD_PROXY_FAILURE_WAIT="5000"
#ETCD_PROXY_REFRESH_INTERVAL="30000"
#ETCD_PROXY_DIAL_TIMEOUT="1000"
#ETCD_PROXY_WRITE_TIMEOUT="5000"
#ETCD_PROXY_READ_TIMEOUT="0"
#
#[Security]
#ETCD_CERT_FILE=""
#ETCD_KEY_FILE=""
#ETCD_CLIENT_CERT_AUTH="false"
#ETCD_TRUSTED_CA_FILE=""
#ETCD_AUTO_TLS="false"
#ETCD_PEER_CERT_FILE=""
#ETCD_PEER_KEY_FILE=""
#ETCD_PEER_CLIENT_CERT_AUTH="false"
#ETCD_PEER_TRUSTED_CA_FILE=""
#ETCD_PEER_AUTO_TLS="false"
#
#[Logging]
#ETCD_DEBUG="false"
#ETCD_LOG_PACKAGE_LEVELS=""
#ETCD_LOG_OUTPUT="default"
#
#[Unsafe]
#ETCD_FORCE_NEW_CLUSTER="false"
#
#[Version]
#ETCD_VERSION="false"
#ETCD_AUTO_COMPACTION_RETENTION="0"
#
#[Profiling]
#ETCD_ENABLE_PPROF="false"
#ETCD_METRICS="basic"
#
#[Auth]
#ETCD_AUTH_TOKEN="simple"
//数据目录位置
//监听其他etcd member的url(2380端口,集群之间通讯,域名为无效值)
//对外提供服务的地址(2379端口,集群内部的通讯端口)
//集群中节点标识(名称)
//该节点成员的URL地址,2380端口:用于集群之间通讯。


#开机自启动、开启服务,检测端口
[root@ct ~]# systemctl enable etcd.service
[root@ct ~]# systemctl start etcd.service
[root@ct ~]# netstat -anutp |grep 2379
[root@ct ~]# netstat -anutp |grep 2380
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值