主机名 | 内存 | 硬盘 | 网卡 | 系统 |
---|---|---|---|---|
ct | 8 | 300G | NAT:192.168.153.10 VM:192.168.128.10 | Centos7.6(最小化安装) |
C1 | 8 | 300G | NAT:192.168.153.20 VM:192.168.128.20 | Centos7.6(最小化安装) |
C2 | 8 | 300G | NAT:192.168.153.30 VM:192.168.128.30 | Centos7.6(最小化安装) |
hostnamectl set-hostname ct
su -
hostnamectl set-hostname c1
su -
hostnamectl set-hostname c2
su -
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
cd /etc/yum.repos.d/
mkdir repo.bak
mv *.repo repo.bak/
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #配置在线源
yum -y install net-tools bash-completion vim gcc gcc-c++ make pcre pcre-devel expat-devel cmake bzip2 lrzsz
此步骤需重复执行,确保每个组件都是最新版本
net-tools:ifconfig命令行工具
bash-completion:辅助自动补全工具
vim:vim工具
gcc gcc-c++:编译环境
make:编译器
pcre pcre-devel:是一个Perl库,包括 perl 兼容的正则表达式库
expat-devel:Expat库,Expat是一个面向流的xml解析器
cmake:CMake是一个跨平台的编译工具,CMkae目前主要使用场景是作为make的上层工具,产生可移植的makefile文件
lrzsz:可使用rz、sz命令上传、下载数据
yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils
OpenStack 的 train 版本仓库源安装包,同时安装 OpenStack 客户端和 openstack-selinux 安装包
cd /etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-eth1
vim /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=static
IPV4_ROUTE_METRIC=90 #调由优先级,NAT网卡优先
IPADDR=192.168.153.10
NETMASK=255.255.255.0
GATEWAY=192.168.153.2
vim /etc/sysconfig/network-scripts/ifcfg-eth1
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.128.10
NETMASK=255.255.255.0
#GATEWAY=192.168.128.2
systemctl restart network #重启网卡
echo '192.168.128.10 ct' >> /etc/hosts
echo '192.168.128.20 c1' >> /etc/hosts
echo '192.168.128.30 c2' >> /etc/hosts
注:以上为局域网IP
ssh-keygen -t rsa
ssh-copy-id ct
ssh-copy-id c1
ssh-copy-id c2
echo 'nameserver 114.114.144.144' >> /etc/resolv.conf
ct 同步阿里云时钟服务器、c1和c2 同步ct
控制节点ct
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.128.0/24 #允许192.168.128.0/24网段的主机来同步时钟服务
systemctl enable chronyd
systemctl restart chronyd
计算节点c1、c2
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 #配置阿里云时钟服务器源,同步指向控制节点ct
systemctl enable chronyd.service
systemctl restart chronyd.service
chronyc sources
crontab -e
*/2 * * * * /usr/bin/chronyc sources >> /var/log/chronyc.log
#配置计划任务,每隔2分钟同步一次
crontab -l
yum -y install mariadb mariadb-server python2-PyMySQL
此包用于openstack的控制端连接mysql所需要的模块,如果不安装,则无法连接数据库(只安装在控制端)
yum -y install libibverbs
vim /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.128.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
[mysqld]
bind-address = 192.168.128.10 #控制节点局域网地址
default-storage-engine = innodb #默认存储引擎
innodb_file_per_table = on #每张表独立表空间文件
max_connections = 4096 #最大连接数
collation-server = utf8_general_ci #默认字符集
character-set-server = utf8
执行MariaDB 安全配置脚本
mysql_secure_installation
Enter current password for root (enter for none): #回车
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确认刷新
所有创建虚拟机的指令,控制端都会发送到rabbitmq,node节点监听rabbitmq,启动RabbitMQ服务,并设置其开机启动
yum -y install rabbitmq-server
systemctl enable rabbitmq-server.service
systemctl start rabbitmq-server.service
创建消息队列用户,用于controler和 计算节点连接rabbitmq的认证(关联)
rabbitmqctl add_user openstack RABBIT_PASS
配置openstack用户的操作权限(正则,配置读写权限)
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
可查看25672和5672 两个端口(5672是Rabbitmq默认端口,25672是Rabbit的测试工具CLI的端口)
netstat -natp | grep 25672
netstat -natp | grep 5672
查看rabbitmq插件列表
rabbitmq-plugins list
开启rabbitmq的web管理界面的插件,端口为15672
rabbitmq-plugins enable rabbitmq_management
ss -natp | grep 5672
可访问192.168.153.10:15672
默认账号密码均为guest
安装memcached是用于存储session信息;服务身份验证机制(keystone)使用Memcached来缓存令牌 在登录openstack的dashboard时,会产生一些session信息,这些session信息会存放到memcached中
yum install -y memcached python-memcached #python-memcached模块在OpenStack中起到连接数据库的作用
修改Memcached配置文件
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
yum -y install etcd
cd /etc/etcd
vim etcd.conf
ETCD_DATA_DIR="/var/lib/etcd/default.etcd" #数据目录位置
ETCD_LISTEN_PEER_URLS="http://192.168.128.10:2380" #2380端口,集群之间通讯,域名为无效值
ETCD_LISTEN_CLIENT_URLS="http://192.168.128.10:2379" #2379端口,集群内部的通讯端口
ETCD_NAME="ct" #集群中节点标识
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.128.10:2380" #该节点成员的URL地址,2380端口:用于集群之间通讯。
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.128.10:2379"
ETCD_INITIAL_CLUSTER="ct=http://192.168.128.10:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01" #集群唯一标识
ETCD_INITIAL_CLUSTER_STATE="new" #初始集群状态,new为静态,若为existing,则表示此ETCD服务将尝试加入已有的集群
若为DNS,则表示此集群将作为被加入的对象
systemctl enable etcd.service
systemctl start etcd.service
netstat -anutp |grep 2379
netstat -anutp |grep 2380
yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils