文章目录
- 一.环境规划
- 二.基础环境配置
- 1.修改主机名与网卡
- 2.配置Hosts文件,关闭防火墙与核心防护
- 3.做免交互
- 4.安装基础环境依赖包
- 5.时间同步与周期性计划任务
- 三.系统环境配置
- 1.安装、配置MariaDB
- 2.安装RabbitMQ
- 3.安装memcached
一.环境规划
主机名 | 内存 | 硬盘 | 网卡 | 系统 |
ct | 8 | 300 | nat:192.168.100.128,vm1:192.168.50.51 | centos 7.6 |
c1 | 8 | 300 | nat:192.168.100.129,vm1:192.168.50.52 | centos 7.6 |
c2 | 8 | 300 | nat:192.168.100.130,vm1:192.168.50.53 | centos 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
按照环境规划修改网卡
添加网卡一个为nat,一个为vm1
修改配置文件(下文之演示一台)
[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.100.128
NETMASK=255.255.255.0
GATEWAY=192.168.100.2
DNS=192.168.100.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.50.51
NETMASK=255.255.255.0
GATEWAY=192.168.50.2
DNS=192.168.50.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文件,关闭防火墙与核心防护
- 配置hosts
[root@ct ~]# vi /etc/hosts
//添加局域网IP
192.168.50.51 ct
192.168.50.52 c1
192.168.50.53 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与密码
- 配置DNS(所以节点)
[root@ct ~]# vi /etc/resolv.conf
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
===============================================================================
^* 120.25.115.20 2 9 377 22 -1510us[-1696us] +/- 18ms
//设置周期性计划任务
[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.50.51 //控制节点局域网地址
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.100.128:15672,密码账号均为guest
登录后页面
3.安装memcached
作用
安装memcached是用于存储session信息;服务身份验证机制使用Memcached来缓存令牌 在登录openstack的dashboard时,会产生一些session信息,这些session信息会存放到memcached中
//安装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
//安装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.50.51:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.50.51:2379"
#ETCD_MAX_SNAPSHOTS="5"
#ETCD_MAX_WALS="5"
ETCD_NAME="ct"
#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.50.51:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.50.51:2379"
#ETCD_DISCOVERY=""
#ETCD_DISCOVERY_FALLBACK="proxy"
#ETCD_DISCOVERY_PROXY=""
#ETCD_DISCOVERY_SRV=""
ETCD_INITIAL_CLUSTER="ct=http://192.168.50.51:2380"
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