Skip to main content

2.OpenStack基础安装

提示:

该文档还未完成,配置仅供参考,可能缺少某些步骤,如需完整安装,请看官方文档

(文档未完成,占位)

环境设置

OS系统版本:rockylinux8

OpenStack版本:V版本

主机设置

配置网络

#安装network工具包
yum install -y vim network-scripts
systemctl start network && systemctl enable network

#关闭NetworkManager
systemctl stop NetworkManager && systemctl disable NetworkManager
systemctl status NetworkManager network

#开启网卡开机自启
Edit the /etc/sysconfig/network-scripts/ifcfg-INTERFACE_NAME file to contain the following:
vim /etc/sysconfig/network-scripts/ifcfg-enp7s0
#Do not change the HWADDR and UUID keys.
DEVICE=INTERFACE_NAME
TYPE=Ethernet
ONBOOT="yes" #更改成yes即可
BOOTPROTO="none"

配置主机名和DNS

hostnamectl set-hostname CA-S2101
#加入解析,改成自己主机名
echo "127.0.0.1 ca-s2101 CA-S2101 ca-s2101.lan CA-S2101.LAN" >> /etc/hosts

关闭防火墙和SELinux

#firewall
systemctl stop firewalld && systemctl disable firewalld

#关闭防火墙,openstack内部有自己的防火墙和安全策略,所以关闭主机的防火墙和selinux,不然会出问题
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
getenforce

#关闭SELinux后,需要重启服务器
reboot

openstack-selinux 软件包可以自动设置SELinux规则,但是网上给的教程和Rockylinux论坛给的方案都是关闭SELinux,所以此处关闭SELinux。

安装OpenStack源

#enable the PowerTools repository
yum install centos-release-openstack-victoria -y

#yum install centos-release-openstack-yoga -y
yum config-manager --set-enabled powertools -y

#Upgrade the packages on all nodes:
yum upgrade -y

#RHEL and CentOS enable SELinux by default. Install the openstack-selinux package to automatically manage security policies for OpenStack services:
yum install openstack-selinux -y

SQL database

安装mariadb

#Install the packages:
yum install mariadb mariadb-server python3-PyMySQL -y

修改mariadb配置文件

cat <<EOF >>/etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.123.150

default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 2048
collation-server = utf8_general_ci
character-set-server = utf8
EOF

初始化mariadb数据库

#Start the database service and configure it to start when the system boots:
systemctl enable mariadb.service
systemctl start mariadb.service

#Secure the database service by running the mysql_secure_installation script
mysql_secure_installation

#测试,先空密码测试,再输入密码测试
mysql -uroot -p

Message queue

安装rabbitmq

#Install the package:
yum install rabbitmq-server -y

#Start the message queue service and configure it to start when the system boots:
systemctl enable rabbitmq-server.service
systemctl start rabbitmq-server.service

配置rabbitmq

#Add the openstack user:
rabbitmqctl add_user openstack password #openstack是用户名,password是密码,生产环境不要用弱密码

#Permit configuration, write, and read access for the openstack user:
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
rabbitmqctl set_user_tags openstack administrator


#启用 rabbitmq-manager 插件,开启 Web 控制台
rabbitmq-plugins enable rabbitmq_management

控制台登录验证

#使用浏览器登录验证:
http://192.168.123.150:15672/
#验证没问题后关闭插件
rabbitmq-plugins disable rabbitmq_management

Memcached

安装Memcached

#Install the packages:
yum install memcached python3-memcached -y

#Start the Memcached service and configure it to start when the system boots:
systemctl enable memcached.service
systemctl start memcached.service

验证Memcached

ps -aux | grep 11211
memcach+ 1490 0.0 0.0 455244 9156 ? Ssl Jan17 0:54 /usr/bin/memcached -p 11211 -u memcached -m 64 -c 1024 -l 127.0.0.1,::1
root 1712376 0.0 0.0 221940 1096 pts/6 S+ 03:37 0:00 grep --color=auto 11211

Etcd

安装Etcd

#Install the package:
yum install etcd -y

配置Etcd

按照将以下参数修改 /etc/etcd/etcd.conf

#参数参考
vim /etc/etcd/etcd.conf
#[Member]
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.123.150:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.123.150:2379"
ETCD_NAME="CA-S2101"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.123.150:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.123.150:2379"
ETCD_INITIAL_CLUSTER="CA-S2101=http://192.168.123.150:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_INITIAL_CLUSTER_STATE="new"

启动Etcd

#Enable and start the etcd service:
systemctl enable etcd
systemctl start etcd