OpenStack环境部署
一、环境部署
最小化安装
主机 | CPU | 存储 | 双网卡 |
---|---|---|---|
控制节点ct | 双核双线程-CPU虚拟化开启 | 内存8G硬盘:300G+1024G(CEPH块存储) | VMnet1(局域网)192.168.1.10 NAT-192.168.132.11 |
计算节点c1 | 双核双线程-CPU虚拟化开启 | 内存8G硬盘:300G+1024G(CEPH块存储) | VMnet1(局域网)192.168.1.11 NAT-192.168.132.12 |
计算节点c2 | 双核双线程-CPU虚拟化开启 | 内存8G硬盘:300G+1024G(CEPH块存储) | VMnet1(局域网)192.168.1.12 NAT-192.168.132.12 |
二、基础环境配置
1、修改添加NAT网卡配置
BOOTPROTO=static #修改网卡配置参数,修改为静态IP
ONBOOT=yes #开启设备开机启动
IPADDR=192.168.132.11 #添加字段,静态模式IP自定义
NETMASK=255.255.255.0 #添加字段,设置网段
GATEWAY=192.168.132.2 #添加字段,设置网关
DNS1=192.168.184.2 #添加字段,设置DNS服务器
IPV4_ROUTE_METRIC=90 #设置网卡优先级,默认100,越低优先级越高,防止出现两张网卡为了抢占优先级导致无法连接问题
systemctl restart network
2、关闭防火墙,修改主机名
systemctl stop firewalld
setenforce 0
hostnamectl set-hostname ct
su -
systemctl stop firewalld
setenforce 0
hostnamectl set-hostname c1
su -
systemctl stop firewalld
setenforce 0
hostnamectl set-hostname c2
su -
3、安装基础环境依赖包
yum -y install net-tools bash-completion vim gcc gcc-c++ make pcre pcre-devel expat-devel cmake bzip2 lrzsz
yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils 多安装几次否则会报错
4、VMnet1网卡配置参数(所有节点)
cd /etc/sysconfig/network-scripts/
vim ifcfg-ens34
#修改
BOOTPROTO=static
ONBOOT=yes
#末行添加
IPADDR=192.168.1.10 #根据网段,设置VMnet1网段的IP,自定义
NETMASK=255.255.255.0 #设置掩码
systemctl restart network #重启网卡
ifconfig #再次查看,是否修改完成
5、配置主机映射文件(所有节点)
echo '192.168.10.10 ct' >> /etc/hosts
echo '192.168.10.11 c1' >> /etc/hosts
echo '192.168.10.12 c2' >> /etc/hosts
6、三台节点做免交互(所有节点)
ssh-keygen -t rsa
#一路回车
ssh-copy-id ct
ssh-copy-id c1
ssh-copy-id c2
7、配置时间同步
echo 'nameserver 114.114.114.114' >> /etc/resolv.conf 所有节点
控制节点(192.168.1.10)
yum install chrony -y
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.1.0/24 #允许192.168.1.0/24网段的主机来同步时钟服务(控制节点)
server ct iburst #配置阿里云时钟服务器源,同步指向控制节点ct(2台计算节点)
#使用chronyc sources命令查询时间同步信息
systemctl enable chronyd
systemctl restart chronyd
chronyc sources
计算节点(俩台)
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 ct iburst #配置阿里云时钟服务器源,同步指向控制节点ct
systemctl enable chronyd.service
systemctl restart chronyd.service
chronyc sources
8、配置计划性任务 (所有节点)
crontab -e
*/2 * * * * /usr/bin/chronyc sources >>/var/log/chronyc.log
crontab -l
三、系统环境配置(控制节点)
1、安装、配置MariaDB
yum -y install mariadb mariadb-server python2-PyMySQL 多安装几次
yum -y install libibverbs
2、添加MySQL字配置文件
vim /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.1.10
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
#开机自启动、开启服务
systemctl enable mariadb
systemctl start mariadb
3、执行MariaDB 安装配置脚本
mysql_secure_installation
Enter current password for root (enter for none): #输入当前root密码,回车
OK, successfully used password, moving on...
Set root password? [Y/n] Y #是否需要更改root密码,Y确认
Remove anonymous users? [Y/n] Y #是否移除其他用户,Y确认移除
... Success!
Disallow root login remotely? [Y/n] n #是否不允许root用户远程登陆,输入n,允许root用户远程登陆
... skipping.
Remove test database and access to it? [Y/n] Y #是否删除test测试库,Y确认删除
Reload privilege tables now? [Y/n] Y #是否刷新规则,Y确认刷新
4、安装RabbitMQ
yum -y install rabbitmq-server
===配置服务,启动RabbitMQ服务,并设置其开机启动===
systemctl enable rabbitmq-server.service
systemctl start rabbitmq-server.service
===创建消息队列用户,用于controler和 计算节点连接rabbitmq的认证(关联)===
rabbitmqctl add_user openstack RABBIT_PASS
===配置openstack用户的操作权限(正则,配置读写权限)===
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
查看rabbitmq插件列表
rabbitmq-plugins list
开启rabbitmq的web管理界面的插件,端口为15672
rabbitmq-plugins enable rabbitmq_management
此时可查看25672和5672 两个端口(5672是Rabbitmq默认端口,25672是Rabbit的测试工具CLI的端口)
netstat -natp | grep 5672
5、安装memcached
yum install -y memcached python-memcached
#python-*模块在OpenStack中起到连接数据库的作用
vim /etc/sysconfig/memcached
PORT="11211" #memcached端口11211
USER="memcached" #用户memcached
MAXCONN="1024" #最大连接数1024
CACHESIZE="64" #字符集大小64位
OPTIONS="-l 127.0.0.1,::1,ct" #监听地址,127.0.0.1:本地地址,::是ipv6地址,ct是本地VMnet1地址
开启服务开机自启,启动服务
systemctl enable memcached
systemctl start memcached
netstat -nautp | grep 11211
6、安装etcd
etcd是一个分布式可靠的键值存储系统,数据库
yum -y install etcd
修改etcd配置文件
cd /etc/etcd/
vim etcd.conf
删除所有内容,复制粘贴以下内容并进行修改
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.1.10:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.1.10:2379"
ETCD_NAME="ct"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.1.10:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.10:2379"
ETCD_INITIAL_CLUSTER="ct=http://192.168.1.10:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_INITIAL_CLUSTER_STATE="new"
开启服务,检测端口
systemctl enable etcd.service
systemctl start etcd.service
netstat -anutp |grep 2379
netstat -anutp |grep 2380