前言:
一個(gè)良好的運(yùn)行環(huán)境對(duì)于任何一個(gè)部署工作來(lái)說(shuō)都是必須的,俗話說(shuō)?萬(wàn)事開(kāi)頭難,其實(shí)很多部署工作失敗的原因在于初始環(huán)境沒(méi)有正確的配置,因此,按照官網(wǎng)的部署文檔并結(jié)合自己的實(shí)際情況,配置一個(gè)合理的OpenStack運(yùn)行環(huán)境是十分有必要的。
OpenStack的運(yùn)行環(huán)境配置文檔:Environment — Installation Guide documentation
?可以看到內(nèi)容是比較多得,其中需要注意的是,SQL數(shù)據(jù)庫(kù)也就是MySQL或者mariadb,或者postgresql。以及消息隊(duì)列服務(wù)rabbitmq,消息中間件memcached和etcd都是劃歸為運(yùn)行環(huán)境的,etcd計(jì)劃使用集群而不是官方文檔內(nèi)的單實(shí)例etcd。
下面的環(huán)境配置根據(jù)自己的實(shí)際情況做得,并沒(méi)有完全遵照官方文檔。
一,
security?安全方面
三個(gè)服務(wù)器都關(guān)閉防火墻和selinux
systemctl disable firewalld && systemctl stop firewalld
vim /etc/selinux/config
編輯文件,關(guān)閉selinux
修改SELINUX=disabled
當(dāng)然,OpenStack有一個(gè)工具名稱為openstack-selinux,但為了部署更順暢,還是將防火墻和selinux徹底關(guān)閉比較好。
二,
設(shè)置主機(jī)名稱和域名解析hosts
###注:主機(jī)名在openstack里是非常非常重要的,原因是配置文件里基本都是引用的主機(jī)名,如果部署完成后,修改了主機(jī)名,結(jié)果將是災(zāi)難性的。
192.168.123.130?
[root@openstack1 ~]# cat /etc/hostname
openstack1
192.168.123.131
[root@openstack2 ~]# cat /etc/hostname
openstack2
192.168.123.131
[root@openstack3 ~]# cat /etc/hostname
openstack3
三個(gè)服務(wù)器都一樣的hosts:
[root@openstack1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.123.130 openstack1 manager.node
192.168.123.131 openstack2 work.node1
192.168.123.132 openstack3 work.node2
[root@openstack1 ~]# scp /etc/hosts openstack1:/etc/
hosts 100% 274 283.5KB/s 00:00
[root@openstack1 ~]# scp /etc/hosts openstack2:/etc/
hosts 100% 274 65.9KB/s 00:00
[root@openstack1 ~]# scp /etc/hosts openstack3:/etc/
hosts
三,
服務(wù)器之間的免密
以192.168.123.130為例:
ssh-keygen -t rsa
一路回車到底,生成私鑰
拷貝私鑰,按提示輸入yes和對(duì)應(yīng)主機(jī)的密碼
ssh-copy-id 192.168.123.130
ssh-copy-id 192.168.123.131
ssh-copy-id 192.168.123.132
四,
ntp時(shí)間服務(wù)器的搭建
####注:時(shí)間服務(wù)器可以看做是集群的基礎(chǔ)設(shè)施,集群能不能部署好,能不能保證不出現(xiàn)各種稀奇古怪的問(wèn)題,就看時(shí)間服務(wù)器的了
以130服務(wù)器作為時(shí)間服務(wù)器,其它兩個(gè)節(jié)點(diǎn)同步130服務(wù)器的時(shí)間
192.168.123.130服務(wù)器:
yum install ntp -y
編輯配置文件 /etc/ntp.conf,增加這么兩行:
server 127.127.1.0
fudge 127.127.1.0 stratum 10
重啟服務(wù):
systemctl restart ntpd
192.168.123.131服務(wù)器和132服務(wù)器:
yum install ntp -y
編輯配置文件 /etc/ntp.conf,增加這一行:
server 192.168.123.130 prefer
?重啟服務(wù):
systemctl restart ntpd
在131和132上,查看ntp狀態(tài)是這樣的表示時(shí)間服務(wù)器搭建完畢(需要等待10來(lái)分鐘,才會(huì)這個(gè)狀態(tài)):
[root@openstack2 ~]# ntpstat
synchronised to NTP server (192.168.123.130) at stratum 12
time correct to within 45 ms
polling server every 64 s
?五,
yum倉(cāng)庫(kù)的配置
基礎(chǔ)軟件倉(cāng)庫(kù)1:
cat >/etc/yum.repos.d/centos7.repo <<EOF
[aliyun]
name=aliyun
baseurl=https://mirrors.aliyun.com/centos-vault/7.4.1708/os/x86_64/
enable=1
gpgcheck=0
[update]
name=aliyun-update
baseurl=https://mirrors.aliyun.com/centos-vault/7.4.1708/updates/x86_64/
enable=1
gpgcheck=0
EOF
基礎(chǔ)倉(cāng)庫(kù)2:?
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
EPEL擴(kuò)展倉(cāng)庫(kù):?
cat >/etc/yum.repos.d/epel.repo <<EOF
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel-archive/7.8/x86_64/
enable=1
gpgcheck=0
EOF
?OpenStack倉(cāng)庫(kù):
cat >/etc/yum.repos.d/openstack.repo <<EOF
[openstack]
name=openstack
baseurl=https://mirrors.aliyun.com/centos-vault/7.6.1810/cloud/x86_64/openstack-rocky/
enable=1
gpgcheck=0
EOF
yum upgrade -y
yum install centos-release-openstack-rocky -y
yum install python-openstackclient -y
yum install openstack-selinux -y
六,
SQL database?
官方文檔:SQL database for RHEL and CentOS — Installation Guide documentation
根據(jù)文檔,選用mariadb,安裝步驟如下:
1,
在192.168.123.130控制節(jié)點(diǎn)安裝
yum install mariadb mariadb-server python2-PyMySQL -y
2,
啟動(dòng)數(shù)據(jù)庫(kù)服務(wù)?
systemctl enable mariadb && systemctl start mariadb
3,
新建mariadb的配置文件:
因?yàn)槭前惭b在controller節(jié)點(diǎn)192.168.123.130,因此,綁定IP為130
cat >/etc/my.cnf.d/openstack.cnf <<EOF
[mysqld]
bind-address = 192.168.123.130
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
EOF
4,
初始化數(shù)據(jù)庫(kù)
mysql_secure_installation
輸出如下:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
5,
數(shù)據(jù)庫(kù)遠(yuǎn)程連接配置
登陸數(shù)據(jù)庫(kù),給root用戶遠(yuǎn)程登陸權(quán)限
[root@openstack1 ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> grant all privileges on *.* to 'root'@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> grant all privileges on *.* to 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
6,
使用Navicat測(cè)試
?七,
Message queue for RHEL and CentOS
消息隊(duì)列服務(wù)器--rabbitmq
官方文檔:
Message queue for RHEL and CentOS — Installation Guide documentation
使用的rabbitmq,依然是安裝在130服務(wù)器上,安裝步驟:
1,Install the package:
yum install rabbitmq-server -y
2,Start the message queue service and configure it to start when the system boots:
啟動(dòng)服務(wù)并加入自啟動(dòng)
systemctl enable rabbitmq-server.service && systemctl start rabbitmq-server.service
3,Add the?openstack
?user
增加用戶并設(shè)置密碼,密碼為RABBIT_PASS,此密碼可以自定義
######注:此命令是非常重要的,因?yàn)樵摲?wù)openstack的幾個(gè)主要組件都是和其交互的,儲(chǔ)存了不少重要信息在這個(gè)數(shù)據(jù)庫(kù)內(nèi)的。也算是基礎(chǔ)設(shè)施類的
rabbitmqctl add_user openstack RABBIT_PASS
4,
用戶賦權(quán)
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
輸出如下:
[root@openstack1 ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/"
八,
緩存數(shù)據(jù)庫(kù)
官方文檔:Memcached for RHEL and CentOS — Installation Guide documentation
緩存數(shù)據(jù)庫(kù)的作用是保存用戶令牌,此數(shù)據(jù)庫(kù)仍然是安裝在130服務(wù)器上
######注:緩存數(shù)據(jù)庫(kù)只是被幾個(gè)服務(wù)調(diào)用,但也是比較重要的一個(gè)數(shù)據(jù)庫(kù),此數(shù)據(jù)庫(kù)后續(xù)基本沒(méi)有任何改動(dòng),基礎(chǔ)設(shè)施類服務(wù)。
部署步驟
1,
安裝緩存數(shù)據(jù)庫(kù)
yum install memcached python-memcached -y
2,
Edit the?/etc/sysconfig/memcached
?file and complete the following actions:
編輯緩存數(shù)據(jù)庫(kù)的配置文件;
Change the existing line?OPTIONS="-l?127.0.0.1,::1"?修改為OPTIONS="-l 127.0.0.1,::1,openstack1"
這里說(shuō)明一下,openstack1是130的主機(jī)名
3,
設(shè)置開(kāi)啟啟動(dòng)并啟動(dòng)緩存服務(wù):
systemctl enable memcached&&systemctl start memcached
systemctl status memcached
最后的輸出如下:
[root@openstack1 ~]# systemctl status memcached
● memcached.service - memcached daemon
Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-01-30 19:13:20 CST; 1s ago
Main PID: 3345 (memcached)
CGroup: /system.slice/memcached.service
└─3345 /usr/bin/memcached -p 11211 -u memcached -m 64 -c 1024 -l 127.0.0.1,::1,openstack1
Jan 30 19:13:20 openstack1 systemd[1]: Started memcached daemon.
Jan 30 19:13:20 openstack1 systemd[1]: Starting memcached daemon...
九,
etcd集群的安裝
######注:本次部署中并沒(méi)有使用到etcd,但,后續(xù)的一些服務(wù)比如計(jì)費(fèi)系統(tǒng)是需要用到此集群的。
集群安裝使用ansible自動(dòng)部署,具體步驟見(jiàn)原來(lái)的博客:centos7操作系統(tǒng) ---ansible劇本離線快速部署etcd集群_centos離線安裝etcd_晚風(fēng)_END的博客-CSDN博客
最終測(cè)試結(jié)果如下即可:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-400741.html
[root@openstack1 ~]# etcd_search endpoint status -w table
+------------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+------------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| https://192.168.123.130:2379 | 8fef69ba298e9bc3 | 3.4.9 | 20 kB | true | false | 55 | 9 | 9 | |
| https://192.168.123.131:2379 | 548b7cecabe21cd7 | 3.4.9 | 20 kB | false | false | 55 | 9 | 9 | |
| https://192.168.123.132:2379 | 28b34b044580be86 | 3.4.9 | 20 kB | false | false | 55 | 9 | 9 | |
+------------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------
以上就是openstack的基本運(yùn)行環(huán)境了,部署完畢后,可以將三個(gè)虛擬機(jī)打上快照啦。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-400741.html
到了這里,關(guān)于云計(jì)算|OpenStack|社區(qū)版OpenStack安裝部署文檔(二---OpenStack運(yùn)行環(huán)境搭建)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!