OpenStack 是一個開源平台,主要用於通過 Web 瀏覽器儀表板或命令行管理雲環境中的硬件、存儲和網絡設置。您可以構建和部署實例以及管理您的雲。
本教程將向您展示如何在 CentOS 7 上安裝 OpenStack。以 root 身份登錄到非託管 CentOS 7 服務器。 燈組 安裝在它上面。
安裝 OpenStack
1.檢查初始服務器配置
在安裝之前,運行 yum update 命令以確保服務器上的所有內容都是最新的。此命令將檢查存儲庫並通知您是否需要更新。
[[email protected] ~]# yum update
下面的提示表示運行 yum 命令後需要更新的包數量。然後按 y 進來 安裝所需的軟件包。
Transaction Summary
==========================================================================================================
Install 2 Packages (+1 Dependent package)
Upgrade 171 Packages
Total download size: 606 M
Is this ok [y/d/N]:
禁用不必要的服務
通過運行以下命令停止和禁用不必要的服務:
[[email protected] ~]# ss -tulpn
此命令的結果顯示所有正在運行的服務和它們正在偵聽的端口的列表,具體取決於服務器上正在運行的服務。
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 *:48219 *:* users:(("haproxy",pid=71524,fd=6),("haproxy",pid=71523,fd=6))
tcp LISTEN 0 128 *:22 *:* users:(("sshd",pid=940,fd=3))
tcp LISTEN 0 100 127.0.0.1:25 : users:(("master",pid=71392,fd=13))
tcp LISTEN 0 128 *:5000 *:* users:(("haproxy",pid=71524,fd=5))
tcp LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=940,fd=4))
tcp LISTEN 0 100 [::1]:25 [::]:* users:(("master",pid=71392,fd=14))
tcp LISTEN 0 128 [::ffff:127.0.0.1]:9200 [::]:* users:(("java",pid=45448,fd=254))
tcp LISTEN 0 128 [::1]:9200 [::]:* users:(("java",pid=45448,fd=253))
tcp LISTEN 0 128 [::ffff:127.0.0.1]:9300 [::]:* users:(("java",pid=45448,fd=251))
tcp LISTEN 0 128 [::1]:9300 [::]:* users:(("java",pid=45448,fd=250))
只有 SSH 守護程序應該保持活動狀態。因此,使用以下命令禁用除 SSH 守護程序之外的所有內容,例如 HAProxy 負載均衡器和 Elasticsearch(在 Java 中運行):
[[email protected] ~]# systemctl stop haproxy && systemctl disable haproxy; systemctl stop elasticsearch.service && systemctl disable elasticsearch.service
禁用所有不必要的服務後,重新運行上面的 ss-tulpn 命令。 如果您只保留 SSH 守護程序,則輸出將是: 如果您看到 SSH 守護程序以外的其他內容,請重複禁用過程並仔細檢查活動服務。
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp LISTEN 0 128 *:22 *:* users:(("sshd",pid=940,fd=3))
tcp LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=940,fd=4))
如果 SSH 守護程序是列表中剩下的唯一服務,您可以繼續下一步。
檢查 SELinux 是否被禁用
安全性增強的 Linux (SELinux) 通過運行 getenforce 命令在服務器上。如果禁用,輸出將返回禁用。
[[email protected] ~]# getenforce
Disabled
如果 SELinux 仍處於啟用狀態,則輸出返回 Enforcing。
[[email protected] ~]# getenforce
Enforcing
紅帽可以提供幫助 配置 SELinux 以允許或禁用.
設置系統主機名
初始配置的最後一步是設置主機名以匹配運行 OpenStack 安裝的完全限定域名 (FQDN)。
將 set-hostname 更改為您的首選主機名。
[[email protected] ~]#hostnamectl set-hostname host.OpenStack.lan
不會生成任何輸出,因此請使用以下命令驗證主機名是否設置正確:
[[email protected] ~]# hostname -f
輸出顯示當前主機名的名稱。如果您看到所需的主機名,則說明您是最新的。
2. 使用 PackStack 包安裝 OpenStack。
PackStack 在 CentOS 和 Red Hat Enterprise Linux (RHEL) 服務器上部署 OpenStack 的各種組件。首先,您需要使用此命令啟用 RDO(OpenStack 的 RPM 分發)存儲庫。
[[email protected] ~]# yum install https://www.rdoproject.org/repos/rdo-release.rpm
出現提示時,按 y,然後 進來 我得到以下結果。
Running transaction
Installing : rdo-release-train-1.noarch 1/1
Verifying : rdo-release-train-1.noarch 1/1
Installed:
rdo-release.noarch 0:train-1
Complete!
現在使用 yum 安裝 PackStack 包。此命令的輸出很大。
[[email protected] ~]# yum install openstack-packstack
當您看到以下輸出時,按 y 然後 進來.
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud
Importing GPG key 0x764429E6:
Userid : "CentOS Cloud SIG (https://wiki.centos.org/SpecialInterestGroup/Cloud) [email protected]"
Fingerprint: 736a f511 6d9c 40e2 af6b 074b f9b9 fee7 7644 29e6
Package : rdo-release-train-1.noarch (@/rdo-release)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud
檢索密鑰後,您將看到以下輸出,表明 PackStack 包已安裝。
Installed:
openstack-packstack.noarch 1:15.0.1-2.el7
Complete!
3.OpenStack雲配置文件
創建配置文件
要使用 PackStack 生成配置文件,請運行以下命令:
[[email protected] ~]# packstack --gen-answer-file=$(date +"%d.%m.%y").conf
此命令驗證生成的文件是否包含創建日期,如下所示。
Packstack changed given value to required value /root/.ssh/id_rsa.pub
Additional information:
Parameter CONFIG_NEUTRON_L2_AGENT: You have chosen OVN Neutron backend. Note that this backend does not support the VPNaaS or FWaaS services. Geneve will be used as the encapsulation method for tenant networks
注意:對於遵循本指南的所有用戶,CONFIG_NEUTRON_L2_AGENT 參數都存在且正常。
使用 ls 命令找到新創建的配置文件。配置文件為 22.06.21.conf 如下圖。
[[email protected] ~]# ls
22.06.21.conf haproxy.tar.gz results1.nmap results.gnmap results.xml
haproxy-2.3.10 results1.gnmap results1.xml results.nmap
編輯配置文件
現在使用文本編輯器編輯配置文件。 打開 22.06.21.conf 文件並根據需要更新包含密碼的行。
[[email protected] ~]# vi 22.06.21.conf
然後設置你的公眾號 NTP 服務器 到你附近的地方。在下面的示例中, 我們。 泳池區。
CONFIG_NTP_SERVERS=0.us.pool.ntp.org
如下所示更新其餘參數,但包括您自己的密碼。
CONFIG_PROVISION_DEMO=n
CONFIG_KEYSTONE_ADMIN_PW=TeStPASSword234
CONFIG_HORIZON_SSL=y
CONFIG_MARIADB_PW=TeStPASSword234
編輯後,使用編輯器中的 :wq 命令保存並關閉文件。
最後,更新文件以允許 root 登錄。在編輯器中打開文件。
[[email protected] ~]# vi /etc/ssh/sshd_config
以井號 (#) 開頭的代碼行是代碼中的註釋,系統不會讀取。刪除 PermitRootLogin yes 行前面的井號以激活它,如下所示。完成後保存更改。
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
最後,重新啟動 SSH 守護程序。
[[email protected] ~]# systemctl restart sshd
4. 如何安裝 OpenStack
最後,您可以開始安裝 OpenStack。使用編輯後的配置文件運行以下命令:
[[email protected] ~]# packstack --answer-file 22.06.21.conf
安裝過程需要一些時間,但在整個過程中會安裝各種服務。結果輸出如下所示。
Preparing Ceilometer entries [ DONE ]
Preparing Aodh entries [ DONE ]
Preparing Puppet manifests [ DONE ]
Copying Puppet modules and manifests [ DONE ]
Applying 209.59.176.93_controller.pp
209.59.176.93_controller.pp: [ DONE ]
Applying 209.59.176.93_network.pp
209.59.176.93_network.pp: [ DONE ]
Applying 209.59.176.93_compute.pp
209.59.176.93_compute.pp: [ DONE ]
Applying Puppet manifests [ DONE ]
Finalizing [ DONE ]
**** Installation completed successfully ******
Additional information:
* File /root/keystonerc_admin has been created on OpenStack client host 209.59.176.93. To use command line tools you need to source the file.
* NOTE : A certificate was generated to be used for SSL, You should change the SSL certificate configured in /etc/httpd/conf.d/ssl.conf on 209.59.176.93 to use CA signed cert.
* To access the OpenStack Dashboard browse to https://209.59.176.93/dashboard.
Please, find your login credentials stored in the keystonerc_admin in your home directory.
The installation log file is available at: /var/tmp/packstack/20210622-135452-6hMTPK/openstack-s
etup.log
5. 啟動 OpenStack 儀表板
在瀏覽器中輸入以下內容:將下面顯示的 IP 地址替換為您的 IP 地址。
https://209.59.176.93/dashboard
將顯示 OpenStack 登錄屏幕。
輸入 admin 作為配置文件中建立的用戶名和密碼。點擊 登錄.
注意:如果您忘記了密碼,請在安裝 OpenStack 的目錄下的 keystonerc_admin 文件中找到它。
成功登錄後,您將看到 OpenStack 儀表板。
結論是
您已在服務器上成功安裝 OpenStack。我們完全託管的雲託管基於 OpenStack 技術構建,可輕鬆部署可擴展、負載平衡的服務器集群。立即聯繫我們,選擇適合您的雲服務器。