做一个学习OpenStack的记录,先从安装部署开始。由于OpenStack需要安装部署的内容较多,按内容章节编写。因为是部署学习,都是在虚拟机下操作完成,节点配置都不是很高。系统上选择的CentOS,也可以根据自己喜好选择其他Linux版本。如无特殊说明,都是切换到root帐号在所有节点操作执行。
概念架构
逻辑架构
硬件要求
系统环境
操作系统:CentOS Linux release 7.9.2009 (Core)
控制节点controller:192.168.1.10、10.0.0.10
计算节点compute:192.168.1.11、10.0.0.11
存储节点storage:192.168.1.12、10.0.0.12
设置静态网络
网卡一
vim /etc/sysconfig/network-scripts/ifcfg-enp0s3修改编辑如下参数
BOOTPROTO=static
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=223.5.5.5
DNS2=8.8.8.8
网卡二
从原有第一个网卡(如eth0)/etc/sysconfig/network-scripts/ifcfg-enp0s3复制配置文件作为第二个网卡(如eth1)/etc/sysconfig/network-scripts/ifcfg-enp0s8配置,修改以下地方,其他参数不动
DEVICE=enp0s8
NAME=enp0s8
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.0.0.10
NETMASK=255.255.255.0
#GATEWAY=10.0.0.1 # 注释网卡二的网关
重启网络
systemctl restart network
关闭NetworkManager
systemctl stop NetworkManager
systemctl disable NetworkManager
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
关闭selinux
setenforce 0
getenforce
修改/etc/selinux/config如下配置SELINUX=disabled
设置主机名
<pre class="wp-block-syntaxhighlighter-code">hostnamectl set-hostname <hostname> # </hostname><hostname>替换为自己要主机名</hostname></pre>
配置域名解析
编辑/etc/hosts文件配置如下信息
192.168.1.10 controller-01
192.168.1.11 compute-01
192.168.1.12 storage-01
验证域名解析
ping -c 4 compute-01
重启主机
reboot
主机免密
ssh-keygen
ssh-copy-id -i .ssh/id_rsa.pub compute-01
ssh compute-01
替换阿里云YUM源
备份mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
清理重新生成缓存yum clean all
yum makecache
安装NTP时间同步服务
yum install chrony
编辑/etc/chrony.conf
去掉原server配置,添加修改如下配置(控制节点)
server ntp6.aliyun.com iburst
allow 192.168.1.0/24 (根据自己实际子网修改)
去掉原server配置,添加修改如下配置(其他节点)
server controller-01 iburst
设置时区
timedatectl set-timezone Asia/Shanghai timedatectl status
启动NTP服务systemctl start chronyd
chronyc sources
安装openstack仓库(Queens)
yum install centos-release-openstack-queens
yum upgrade
yum install python-openstackclient
yum install openstack-selinux
替换国内阿里云RDO仓库源
[root@compute-01 yum.repos.d]# cat CentOS-OpenStack-queens-aliyun.repo
# CentOS-OpenStack-queens.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/Cloud for more
# information
[centos-openstack-queens]
name=CentOS-7 - OpenStack queens
baseurl=http://mirrors.aliyun.com/centos/7/cloud/x86_64/openstack-queens/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud
yum clean all
yum makecache
数据库mariadb服务安装(控制节点)
yum install mariadb mariadb-server python2-PyMySQL
使用vi编辑器打开/etc/my.cnf.d/mariadb-server.cnf,在[mysqld]中添加
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
init_connect = 'SET collation_connection = utf8_unicode_ci'
init_connect = 'SET NAMES utf8'
skip-character-set-client-handshake
使用vi编辑器打开/etc/my.cnf.d/client.cnf,在[client]中添加default-character-set=utf8
使用vi编辑器打开/etc/my.cnf.d/mysql-clients.cnf,在[mysql]中添加default-character-set=utf8
启动MariaDBsystemctl start mariadb
设置开机启动systemctl enable mariadb
初始化安装mysql_secure_installation
步骤依次如下:
回车
n
Y
Y
Y
Y
重启systemctl restart mariadb
全部保存后,进入到MariaDB控制台,查看字符集show variables like "%character%";
show variables like "%collation%";
全部显示UTF-8则配置成功
消息队列rabbitmq服务安装(控制节点)
1、安装软件
yum install rabbitmq-server
2、启动服务并配置自启动
systemctl enable rabbitmq-server.service
systemctl start rabbitmq-server.service
3、添加openstack用户和密码
rabbitmqctl add_user openstack RABBIT_PASS # RABBIT_PASS密码自定义设置openstack
4、配置openstack用户权限,读、写访问权限
rabbitmqctl set_permissions openstack "." "." ".*"
5、启用web管理界面,需要重启服务使之生效
rabbitmq-plugins list
rabbitmq-plugins enable rabbitmq_management
systemctl restart rabbitmq-server.service
netstat -nltp | grep 15672
6、浏览器登录访问
http://192.168.1.10:15672/
用户名、密码均为:guest(第一次登录必须使用该用户密码)
点击Admin——>Users列表点击openstack用户——>点击Update this user——>输入两次RABBIT_PASS原密码,tags栏点击下方”Admin”选择为administrator——>Update user
缓存memcached服务安装(控制节点)
1、安装软件
yum install memcached python-memcached
2、修改memcached配置文件/etc/sysconfig/memcached,添加controller-01为了外部能访问
OPTIONS="-l 127.0.0.1,::1,controller-01"
3、启动服务并设置自启动
systemctl enable memcached.service
systemctl start memcached.service
netstat -anltup | grep memcached
etcd服务安装(控制节点)
1、安装软件
yum install etcd
2、修改etcd配置文件/etc/etcd/etcd.conf
#[Member]
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://192.68.1.10:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.68.1.10:2379"
ETCD_NAME="controller"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.68.1.10:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.68.1.10:2379"
ETCD_INITIAL_CLUSTER="controller=http://192.68.1.10:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_INITIAL_CLUSTER_STATE="new"
3、启动服务并设置自启动systemctl enable etcd
systemctl start etcd
netstat -anltp | grep etcd
至此,基础环境安装部分完成,后面将会开始OpenStack各服务组件的安装。
参考文档
https://docs.openstack.org/queens/index.html