前言
大二上學期學習Openstack,苦于百度與CSDN上沒有對應版本的教程,學的十分艱難,在此,將我的Openstack云平臺搭建程序寫出,留給新手學習
準備作業:
VMware Workstation Pro 虛擬機 我使用版本:15.5.2 build-15785246
CentOS-7-x86_64-DVD-1511.iso
XianDian-IaaS-v2.2.iso
補上需要的兩個鏡像
鏈接:https://pan.baidu.com/s/1RUzNN4j8myJhMlFerny7uw
提取碼:bxae
復制這段內容后打開百度網盤手機App,操作更方便哦
虛擬機配置 (controller和compute配置相同):
記憶體 3G
處理器 2G
硬碟 50G
CD/DVD CentOS-7-x86_64-DVD-1511.iso
網路配接器 VMnet1
網路配接器2 VMnet2
controller和compute網路配置
| 主機名 | VMnet1 | VMnet2 |
| controller | 192.168.28.10 | 192.168.128.10 |
| compute | 192.168.28.20 | 192.168.128.20 |
controller改主機名字,關防火墻,設定主機映射開啟虛擬機
hostnamectl set-hostname controller
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
cat >>/etc/hosts<<eof
192.168.28.10 controller
192.168.28.20 compute
eof
compute
hostnamectl set-hostname compute
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
cat >>/etc/hosts<<eof
192.168.28.10 controller
192.168.28.20 compute
eof
controller
接下來,進入opt目錄,創建掛載點 centos 以及 iaas
cd /opt
mkdir centos iaas
設定開機自動掛載鏡像檔案
cat >>/etc/fstab<<eof
/dev/cdrom /opt/centos iso9660 defaults 0 0
/opt/XianDian-IaaS-v2.2.iso /opt/iaas iso9660 defaults 0 0
eof
掛載立即生效
mount -a
進入 /etc/yum.repos.d 目錄,洗掉或移動里面的大寫C開頭的檔案,否則后面會造成快取錯誤,載創建repo源檔案
cd /etc/yum.repos.d
mkdir bk
mv C* bk
cat >>/etc/yum.repos.d/local.repo<<eof
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=file:///opt/iaas/iaas-repo
gpgcheck=0
enabled=1
eof
清除快取,生成快取
yum clean all
yum makecache
出現提示,說明是成功了(不需要和我的完全一摸一樣,因為iso版本的不同,生成的快取也不同)
[root@controller ~]# yum makecache
已加載插件:fastestmirror
centos | 3.6 kB 00:00:00
iaas | 2.9 kB 00:00:00
(1/7): centos/filelists_db | 2.9 MB 00:00:00
(2/7): centos/group_gz | 155 kB 00:00:00
(3/7): iaas/filelists_db | 1.9 MB 00:00:00
(4/7): iaas/primary_db | 2.3 MB 00:00:00
(5/7): centos/primary_db | 2.8 MB 00:00:00
(6/7): iaas/other_db | 692 kB 00:00:00
(7/7): centos/other_db | 1.2 MB 00:00:00
Determining fastest mirrors
元資料快取已建立
注意,如果出現 下面展示 的段落資訊,說明你之前的步驟出錯了,可能是yum源沒配置好,也可能是沒掛載好,這里很坑
[root@compute yum.repos.d]# yum makecache
已加載插件:fastestmirror
One of the configured repositories failed (未知),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Disable the repository, so yum won't use it by default. Yum will then
just ignore the repository until you permanently enable it again or use
--enablerepo for temporary usage:
yum-config-manager --disable <repoid>
4. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: centos
如果是出現了 /var/run/yum.pid 的訊息
執行下面這段命令即可
rm -rf /var/run/yum.pid
接下來安裝vsftpd和iaas-xiandian
yum install iaas-xiandian vsftpd -y
在controller上安裝 ftp(檔案傳輸)服務
增加匿名訪問
cat >>/etc/vsftpd/vsftpd.conf<<eof
anon_root=/opt
eof
systemctl restart network
systemctl start vsftpd
systemctl enable vsftpd
接下來配置xiandian的openrc.sh應答檔案(一個字都不能錯)
sed -i 's/.//' /etc/xiandian/openrc.sh
sed -i 's/PASS=/PASS=000000/g' /etc/xiandian/openrc.sh
sed -i 's/HOST_IP=/HOST_IP=192.168.28.10/g' /etc/xiandian/openrc.sh
sed -i 's/HOST_NAME=/HOST_NAME=controller/g' /etc/xiandian/openrc.sh
sed -i 's/HOST_IP_NODE=/HOST_IP_NODE=192.168.28.20/g' /etc/xiandian/openrc.sh
sed -i 's/HOST_NAME_NODE=/HOST_NAME_NODE=compute/g' /etc/xiandian/openrc.sh
sed -i 's/RABBIT_USER=/RABBIT_USER=openstack/g' /etc/xiandian/openrc.sh
sed -i 's/DOMAIN_NAME=/DOMAIN_NAME=demo/g' /etc/xiandian/openrc.sh
sed -i 's/METADATA_SECRET=/METADATA_SECRET=000000/g' /etc/xiandian/openrc.sh
sed -i 's/INTERFACE_NAME=/INTERFACE_NAME=ens34/g' /etc/xiandian/openrc.sh
至此,controller停止配置,開始compute配置
compute
查看是否連接到controller的 opt/ 下面的掛載檔案
[root@compute yum.repos.d]# curl ftp://192.168.28.10
-rw-r--r-- 1 0 0 2851502080 Jun 04 2020 XianDian-IaaS-v2.2.iso
dr-xr-xr-x 8 0 0 2048 Dec 09 2015 centos
drwxr-xr-x 4 0 0 2048 Nov 06 2017 iaas
進入opt目錄,創建centos和iaas檔案,移動或洗掉大寫C開頭檔案,創建一個ftp.repo源檔案
cd /opt
mkdir centos iaas
cd /etc/yum.repos.d/
mkdir bk
mv C* bk
touch ftp.repo
進入 /etc/yum.repos.d/ftp.repo 寫入
cat >>/etc/yum.repos.d/ftp.repo<<eof
[centos]
name=centos
baseurl=ftp://192.168.28.10/centos
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=ftp://192.168.28.10/iaas/iaas-repo
gpgcheck=0
enabled=1
eof
清除快取,生成快取
yum clean all
yum makecache
如出現以下畫面,說明成功
[root@compute yum.repos.d]# yum makecache
已加載插件:fastestmirror
centos | 3.6 kB 00:00:00
iaas | 2.9 kB 00:00:00
(1/7): centos/group_gz | 155 kB 00:00:00
(2/7): centos/filelists_db | 2.9 MB 00:00:00
(3/7): centos/primary_db | 2.8 MB 00:00:00
(4/7): centos/other_db | 1.2 MB 00:00:00
(5/7): iaas/filelists_db | 1.9 MB 00:00:00
(6/7): iaas/primary_db | 2.3 MB 00:00:00
(7/7): iaas/other_db | 692 kB 00:00:00
Determining fastest mirrors
元資料快取已建立
下載 iaas-xiandain 進入 /etc/xiandian ,將openrc.sh 改名為openrc.sh.bk 備份 以防出現錯誤
再將 controller(192.168.28.10)中的 /etc/xiandian/openrc.sh 檔案傳輸到 本機
yum -y install iaas-xiandian
cd /etc/xiandian
mv openrc.sh openrc.sh.bk
scp 192.168.28.10:/etc/xiandian/openrc.sh openrc.sh
執行安裝腳本
兩個節點均執行初始化腳本
iaas-pre-host.sh
注意:執行需要一段時間,不要去按回車什么的了,在出現 【reboot】提示后,必須重啟,否則之后的實體發不出去,問題很大!!!
兩臺均重啟
reboot
重新啟動虛擬機
控制節點安裝 (controller)
cd /usr/local/bin
cat >>/usr/local/bin/all-in-one.sh<<eof
iaas-install-mysql.sh
iaas-install-keystone.sh
iaas-install-glance.sh
iaas-install-nova-controller.sh
iaas-install-neutron-controller.sh
iaas-install-neutron-controller-gre.sh
iaas-install-dashboard.sh
eof
source all-in-one.sh
計算節點安裝(compute)
cd /usr/local/bin
cat >>/usr/local/bin/all-in-one.sh<<eof
iaas-install-nova-compute.sh
iaas-install-neutron-compute.sh
iaas-install-neutron-compute-gre.sh
eof
source all-in-one.sh
安裝需要很長時間,請耐心等待
執行完成后
使用Chrome瀏覽器訪問(其他瀏覽器不太好,造成訪問不到)
http://計算節點IP/dashboard
我的計算節點IP為 192.168.28.10
所以我訪問
http://192.168.28.10/dashboard
訪問成功界面
域:demo
用戶名:admin
密碼:000000

進入

至此,Openstack云平臺的安裝結束
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/258505.html
標籤:其他
上一篇:免費制作一個屬于你的微信紅包封面
下一篇:【內網穿透Nas】基于Frp實作群暉的遠程訪問(ssh、DSM、DS file、WebDAV Server、emby)
