CentOS7安裝OpenStack-01.系統環境准備和相關組件安裝


官方文檔:https://docs.openstack.org 

1.0.系統環境

  1. 生產測試應用的服務器最好是物理機,虛擬目前可以完成搭建測試體驗
  2. 系統選擇是目前的最新版本:CentOS Linux release 7.7.1908 (Core)
  3. 控制節點:Controller :192.168.182.143
  4. 計算節點: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
View Code

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 的組件~~~

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM