CentOS7安装OpenStack-01.系统环境准备和相关组件安装
官方文档:https://docs.openstack.org
1.0.系统环境
- 生产测试应用的服务器最好是物理机,虚拟目前可以完成搭建测试体验
- 系统选择是目前的最新版本:CentOS Linux release 7.7.1908 (Core)
- 控制节点:Controller :192.168.182.143
- 计算节点:Nova:192.168.182.142
1.1.配置域名解析
1)配置主机名
# 在控制节点上执行 hostnamectl set-hostname controller echo ' # controller 192.168.182.143 controller # compute1 192.168.182.142 compute1 '>>/etc/hosts
1.2.关闭防火墙和selinux
systemctl stop firewalld.service systemctl disable firewalld.service systemctl status firewalld.service setenforce 0 getenforce sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux grep SELINUX=disabled /etc/sysconfig/selinux
1.3.配置时间同步
1)在控制端配置时间同步服务
# 在所有的节点上执行
yum install chrony -y
2)编辑配置文件确认有以下配置
vim /etc/chrony.conf # 在控制节点上配置 # 去掉原有的server server ntp6.aliyun.com iburst allow 192.168.182.0/24
3)重启ntp服务,并配置开机自启动
systemctl restart chronyd.service
systemctl status chronyd.service
systemctl enable chronyd.service
systemctl list-unit-files |grep chronyd.service
4)设置时区,同步时间
timedatectl set-timezone Asia/Shanghai chronyc sources timedatectl status
1.4.配置相关yum源
1)配置阿里云的base和epel源
mv -f /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
2)安装openstack-rocky的仓库
yum install centos-release-openstack-rocky -y
yum clean all
yum makecache
# 也可以手动创建OpenStack的阿里云yum源地址
echo '[centos-openstack-rocky] name=CentOS-7 - OpenStack rocky baseurl=http://mirrors.aliyun.com/centos/7/cloud/$basearch/openstack-rocky/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud [centos-openstack-rocky-test] name=CentOS-7 - OpenStack rocky Testing baseurl=http://mirrors.aliyun.com/centos/7/cloud/$basearch/openstack-rocky/ gpgcheck=0 enabled=0 [centos-openstack-rocky-debuginfo] name=CentOS-7 - OpenStack rocky - Debug baseurl=http://mirrors.aliyun.com/centos/7/cloud/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud [centos-openstack-rocky-source] name=CentOS-7 - OpenStack rocky - Source baseurl=http://mirrors.aliyun.com/centos/7/cloud/$basearch/openstack-rocky/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud [rdo-trunk-rocky-tested] name=OpenStack rocky Trunk Tested baseurl=http://mirrors.aliyun.com/centos/7/cloud/$basearch/rdo-trunk-rocky-tested/ gpgcheck=0 enabled=0'>/etc/yum.repos.d/CentOS-OpenStack-Rocky.repo
3)更新软件包
yum update -y
4)安装openstack客户端相关软件
yum install python-openstackclient openstack-selinux -y
1.5.在控制节点安装数据库
1)安装mariadb相关软件包
yum install mariadb mariadb-server MySQL-python python2-PyMySQL -y
2)创建openstack的数据库配置文件
vim /etc/my.cnf.d/mariadb-server.cnf # 在[mysqld]添加以下配置 # ----------------------------------- [mysqld] bind-address = 0.0.0.0 default-storage-engine = innodb innodb_file_per_table = on max_connections = 4096 collation-server = utf8_general_ci character-set-server = utf8 init-connect = 'SET NAMES utf8' # -----------------------------------
3)启动数据库设置开机启动
systemctl restart mariadb.service
systemctl status mariadb.service
systemctl enable mariadb.service
systemctl list-unit-files |grep mariadb.service
4)初始化数据库并重新启动
# 最后安全初始化,运行``mysql_secure_installation``脚本
mysql_secure_installation
步骤依次如下:
回车
n
Y
Y
Y
Y
# 重启服务
systemctl restart mariadb.service
1.6.在控制节点安装消息队列rabbitmq
1)安装rabbitmq-server
yum install rabbitmq-server -y
2)启动rabbitmq,并配置自启动
systemctl start rabbitmq-server.service systemctl status rabbitmq-server.service systemctl enable rabbitmq-server.service systemctl list-unit-files |grep rabbitmq-server.service
3)创建消息队列中openstack账号及密码
# 添加openstack用户和密码,配置用户权限,配置读,写权限
rabbitmqctl add_user openstack openstack rabbitmqctl set_permissions openstack ".*" ".*" ".*" rabbitmqctl set_permissions -p "/" openstack ".*" ".*" ".*"
# 启用web管理插件,需要重启服务使之生效
rabbitmq-plugins enable rabbitmq_management systemctl restart rabbitmq-server.service rabbitmq-plugins list lsof -i:15672
# web访问:http://192.168.182.143:15672
1.7.在控制节点上安装Memcached
# 认证服务认证缓存使用Memcached缓存令牌。缓存服务memecached运行在控制节点。在生产部署中,推荐联合启用防火墙、认证和加密保证它的安全。
1)安装Memcached用于缓存令牌
yum install memcached python-memcached -y
2)修改memcached配置文件
# 修改配置,改成本机的IP地址,为了外部能访问 sed -i 's#127.0.0.1#192.168.182.143#g' /etc/sysconfig/memcached
3)启动memcached并设置开机自启动
systemctl start memcached.service systemctl status memcached.service netstat -anptl|grep memcached systemctl enable memcached.service systemctl list-unit-files |grep memcached.service
1.8.在控制节点上安装Etcd服务
# 这个Etcd服务是新加入的,用于自动化配置
1)安装etcd服务
yum install etcd -y
2)修改etcd配置文件
vim /etc/etcd/etcd.conf ----------------------------------- #[Member] ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_PEER_URLS="http://192.168.182.143:2380" ETCD_LISTEN_CLIENT_URLS="http://192.168.182.143:2379" ETCD_NAME="controller" #[Clustering] ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.182.143:2380" ETCD_ADVERTISE_CLIENT_URLS="http://192.168.182.143:2379" ETCD_INITIAL_CLUSTER="controller=http://192.168.182.143:2380" ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01" ETCD_INITIAL_CLUSTER_STATE="new" ------------------------------------
# 注意上面的IP地址不能用controller替代,无法解析
3)启动etcd并设置开机自启动
systemctl start etcd.service systemctl status etcd.service netstat -anptl|grep etcd systemctl enable etcd.service systemctl list-unit-files |grep etcd.service
~~~至此,控制节点controller就完成基础环境的配置,下面可以开始安装 openstack 的组件~~~