这里写目录标题
- 前言
- 系统环境需求
- 一、基础环境配置(所有节点)
- 1.1修改主机名,关闭防火墙、核心防护
- 1.2 安装基础环境依赖包
- 1.3 网卡配置
- 1.3.1 控制节点(ct)
- 1.3.2 计算节点(c1)
- 1.3.3 网络存储节点(c2)
- 1.4 配置host
- 1.5 免交互
- 1.6 控制节点ct时间同步配置
- 1.6.1 c1计算节点时间同步配置
- 1.6.2 c2计算节点时间同步配置
- 1.7 设置周期性任务
- 二、配置OpenStack平台基础服务(都是在控制节点上)
- 2.1 、安装、配置MariaDB
- 2.1.2、 添加MySQL子配置文件
- 2.1.3 、执行MariaDB 安全配置脚本
- 2.2 、 安装RabbitMQ
- 2.2.1创建消息队列用户,用于controler和node节点连接rabbitmq的认证
- 2.2.2 配置openstack用户的操作权限
- 2.2.3 查看rabbmq插件列表
- 2.3、安装memcached
- 2.3.1、 修改Memcached配置文件
- 2.3.2、安装etcd
前言
openstack有4个节点,分别为控制节点,网络节点,计算节点,存储节点,我这里把网络节点和存储节点合并,不合并浪费资源,我的电脑配置不够。控制节点和计算节点各一台虚拟机,网络节点和存储两个占一台叫网络存储节点
系统环境需求
主机名 | 内存 | 硬盘 | CPU | 双网卡 | 系统 |
控制节点/ct | 8G | 300G+300G | 双核双线程(cpu虚拟化开启) | VM1 :192.168.100.10 / NAT : 20.0.0.20 | Centos 7.6(1810)-最小化安装 |
计算节点/c1 | 8G | 300G+300G | 双核双线程(cpu虚拟化开启) | VM1 :192.168.100.12 / NAT : 20.0.0.22 | Centos 7.6(1810)-最小化安装 |
网络存储节点/c2 | 6G | 300G+300G | 双核双线程(cpu虚拟化开启) | VM1 :192.168.100.11 / NAT : 20.0.0.21 | Centos 7.6(1810)-最小化安装 |
这个是控制节点的系统配置
一、基础环境配置(所有节点)
我这里就用控制节点(ct)来举例
1.1修改主机名,关闭防火墙、核心防护
[root@server ~]# hostnamectl set-hostname ct
[root@server ~]# su
[root@ct ~]# systemctl stop firewalld
[root@ct ~]# systemctl disable firewalld
[root@ct ~]# setenforce 0
[root@ct ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
1.2 安装基础环境依赖包
[root@ct ~]# yum -y install net-tools bash-completion vim gcc gcc-c++ make pcre pcre-devel expat-devel cmake bzip2
[root@ct ~]# yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils
1.3 网卡配置
1.3.1 控制节点(ct)
[root@ct ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=20.0.0.20
NETMASK=255.255.255.0
GATEWAY=20.0.0.2
DNS=20.0.0.2
DEFROUTE=yes
IPV4_ROUTE_METRIC=90 ###调由优先级,NAT网卡优先
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=855cf20b-ba01-497f-8e24-f29fdc55750d
DEVICE=ens33
ONBOOT=YES
[root@ct ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens37
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=192.168.100.10
NETMASK=255.255.255.0
#GATEWAY=20.0.0.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
#UUID=855cf20b-ba01-497f-8e24-f29fdc55750d
DEVICE=ens37
ONBOOT=YES
[root@ct ~]# systemctl restart network #重启网卡
1.3.2 计算节点(c1)
[root@c1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=20.0.0.22
NETMASK=255.255.255.0
GATEWAY=20.0.0.2
DNS=20.0.0.2
DEFROUTE=yes
IPV4_ROUTE_METRIC=90
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=61d2cf6b-e0ff-4adf-99d7-f56990d81705
DEVICE=ens33
ONBOOT=YES
[root@c1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens37
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=192.168.100.12
NETMASK=255.255.255.0
#GATEWAY=20.0.0.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
#UUID=61d2cf6b-e0ff-4adf-99d7-f56990d81705
DEVICE=ens37
ONBOOT=YES
[root@c1 ~]# systemctl restart network #重启网卡
1.3.3 网络存储节点(c2)
[root@c2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=20.0.0.21
NETMASK=255.255.255.0
GATEWAY=20.0.0.2
DNS=20.0.0.2
DEFROUTE=yes
IPV4_ROUTE_METRIC=90 #nat优先级
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=d49e66a4-a7a7-42eb-ab20-deea944cedbf
DEVICE=ens33
ONBOOT=YES
[root@c2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens37
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPADDR=192.168.100.11
NETMASK=255.255.255.0
#GATEWAY=20.0.0.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
#UUID=d49e66a4-a7a7-42eb-ab20-deea944cedbf
DEVICE=ens37
ONBOOT=YES
[root@ct ~]# systemctl restart network #重启网卡
1.4 配置host
[root@ct ~]# vi /etc/hosts
192.168.100.10 ct
192.168.100.12 c1
192.168.100.11 c2
1.5 免交互
[root@ct ~]# ssh-keygen -t rsa
[root@ct ~]# ssh-copy-id ct
[root@ct ~]# ssh-copy-id c1
[root@ct ~]# ssh-copy-id c2
1.6 控制节点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.100.0/24
[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
===============================================================================
^* 203.107.6.88 2 8 377 202 +908us[+1165us] +/- 20ms
1.6.1 c1计算节点时间同步配置
[root@c1 ~]# vi /etc/chrony.conf
# 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
[root@ct ~]# systemctl enable chronyd
[root@ct ~]# 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 3 6 377 40 -210us[ -164us] +/- 21ms
1.6.2 c2计算节点时间同步配置
[root@c2 ~]# vi /etc/chrony.conf
# 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
[root@ct ~]# systemctl enable chronyd
[root@ct ~]# systemctl restart chronyd
##使用 chronyc sources 命令查询时间同步信息
[root@c2 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* ct 3 6 377 50 +6314ns[ +34us] +/- 21ms
1.7 设置周期性任务
[root@ct ~]# crontab -e ##每半小时执行一次时间同步的日志记录
*/30 * * * * /usr/bin/chronyc sources >> /var/log/chronyc.log
二、配置OpenStack平台基础服务(都是在控制节点上)
2.1 、安装、配置MariaDB
[root@ct ~]# yum -y install mariadb mariadb-server python2-PyMySQL
#此包用于openstack的控制端连接mysql所需要的模块,如果不安装,则无法连接数据库;
#此包只安装在控制端
[root@ct ~]# yum -y install libibverbs
2.1.2、 添加MySQL子配置文件
[root@ct ~]# vi /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.100.10 #控制节点局域网地址
default-storage-engine = innodb #默认存储引擎
innodb_file_per_table = on #每张表独立表空间文件(这是MySQL5.7和5.6的区别)
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
2.1.3 、执行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.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
2.2.1创建消息队列用户,用于controler和node节点连接rabbitmq的认证
[root@ct ~]# rabbitmqctl add_user openstack RABBIT_PASS
Creating user "openstack"
2.2.2 配置openstack用户的操作权限
[root@ct ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/"
2.2.3 查看rabbmq插件列表
[root@ct ~]# rabbitmq-plugins list
| 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_mqtt 3.6.16
[ ] rabbitmq_random_exchange 3.6.16
[ ] rabbitmq_recent_history_exchange 3.6.16
[ ] rabbitmq_sharding 3.6.16
[ ] rabbitmq_shovel 3.6.16
[ ] rabbitmq_shovel_management 3.6.16
[ ] rabbitmq_stomp 3.6.16
[ ] rabbitmq_top 3.6.16
[ ] rabbitmq_tracing 3.6.16
[ ] rabbitmq_trust_store 3.6.16
[ ] rabbitmq_web_dispatch 3.6.16
[ ] rabbitmq_web_mqtt 3.6.16
[ ] rabbitmq_web_mqtt_examples 3.6.16
[ ] rabbitmq_web_stomp 3.6.16
[ ] rabbitmq_web_stomp_examples 3.6.16
检查端口
5672是Rabbitmq默认端口
25672是Rabbit的测试工具CLI的端口
15672是rabbitmq的web管理界面的插件的端口
[root@ct ~]# ss -anpt | grep 5672
LISTEN 0 128 *:25672 *:* users:(("beam.smp",pid=9175,fd=46))
LISTEN 0 128 *:15672 *:* users:(("beam.smp",pid=9175,fd=56))
LISTEN 0 128 :::5672 :::* users:(("beam.smp",pid=9175,fd=55))
可访问20.0.0.20:15672
默认账号密码为guest,密码为123456
2.3、安装memcached
- 作用:
安装memcached是用于存储session信息;服务身份验证机制使用Memcached来缓存令牌 在登录openstack的dashboard时,会产生一些session信息,这些session信息会存放到memcached中
#python-*模块在OpenStack中起到连接数据库的作用
[root@ct ~]# yum install -y memcached python-memcached
2.3.1、 修改Memcached配置文件
[root@ct ~]# cat /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 memcachedan
[root@ct ~]# netstat -antp | grep 11211 ##查看端口状态
tcp 0 0 192.168.100:11211 0.0.0.0:* LISTEN 9172/memcached
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 9172/memcached
tcp6 0 0 ::1:11211 :::* LISTEN 9172/memcached
2.3.2、安装etcd
[root@ct ~]# yum -y install etcd
修改etcd配置文件
[root@ct ~]# cd /etc/etcd/
[root@ct etcd]# vim etcd.conf
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.100.10:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.100.10:2379"
ETCD_NAME="ct"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.100.10:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.100:2379
ETCD_INITIAL_CLUSTER="ct=http://192.168.100:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01" #集群唯一标识
ETCD_INITIAL_CLUSTER_STATE="new"
初始集群状态,new为静态,若为existing,则表示此ETCD服务将尝试加入已有的集群
若为DNS,则表示此集群将作为被加入的对象
[root@ct ~]# systemctl enable etcd.service ##开机自启动
[root@ct ~]# systemctl start etcd.service
[root@ct ~]# netstat -anutp |grep 2379 ##查看端口
[root@ct ~]# netstat -anutp |grep 2380