因工做須要接觸openstack(Mitaka),故搭建一個測試環境學習一下。python
本文爲安裝過程手順,根據開源社區安裝手冊編寫,安裝過程當中碰到問題也參考了很多網上資料,感謝各路大神的文檔!mysql
第一次部署,若有不對之處,還請大神留言指正!linux
本文適合第一次安裝部署的新手,不要認爲openstack很高大上,高不可攀而心生畏懼!web
好好看看開源社區的安裝手冊(https://docs.openstack.org/zh_CN/),一臺8G內存的筆記本電腦就可讓你開始實驗了!sql
個人筆記本電腦配置較低:mongodb
ThinkPad 翼480 i5-8250U 8G內存 256G SSD+500G SSD(簡化版T480,心水T480啊!)數據庫
VM 15 開了兩個虛擬機centos
操做系統:CentOS 7.3 (1611)緩存
控制節點:內存4G、硬盤100G(不要糾結硬盤大小,用不了那麼多的,實際也就十幾GB而已!)網絡
計算節點:內存2G、硬盤100G --除控制服務外,其餘服務均安裝在這個節點
網絡規劃: VM給controller節點分配三塊網卡:
一、僅主機模式:111.111.111.0/24 --管理網絡
二、自定義VMnet2模式:192.168.111.0/24 --provider網絡
yum源地址:
http://vault.centos.org/centos/7.3.1611/cloud/x86_64/openstack-mitaka 869+1200common
http://vault.centos.org/centos/7.3.1611/extras/x86_64 451
http://vault.centos.org/centos/7.3.1611/virt/x86_64/kvm-common 89
http://vault.centos.org/centos/7.3.1611/storage/x86_64/ceph-hammer 71
http://vault.centos.org/centos/7.3.1611/os/x86_64/Packages/
有幾個python包,是從https://pkgs.org/ 站點下載。
一、基礎環境準備
配置範圍:全部節點
1.一、配置host文件
111.111.111.201 controller
111.111.111.202 computer01
1.二、配置本地yum源
我已經將安裝包都下載到了本地,因此使用離線yum源安裝
同時將離線包所在目錄作成web站點,這樣計算節點能夠直接配置http的yum源
1.三、安裝時間同步服務
安裝範圍:全部節點
1.3.一、安裝chrony包
# yum install chrony -y
1.3.二、啓動同步服務
# systemctl enable chronyd
# systemctl restart chronyd
# systemctl status chronyd
1.3.三、防火牆設置
第一次部署,關閉防火牆和selinux
1.3.四、配置Chrony
# vi /etc/chrony.conf
如上圖所示,將默認的server所有註釋掉,而後添加本機IP,在其餘客戶機也是這樣配置
爲了容許其餘節點能夠鏈接到控制節點的 chrony 後臺進程,在``/etc/chrony.conf`` 文件添加下面的鍵:
allow 111.111.111.0/24
啓動 NTP 服務並將其配置爲隨系統啓動:
# systemctl enable chronyd.service
# systemctl start chronyd.service
1.四、安裝openstack最新的源
安裝範圍:全部節點
yum install centos-release-openstack-mitaka
yum install https://rdoproject.org/repos/rdo-release.rpm ---本次操做不能執行這一步,不然新增的repo文件指向的是T版本的openstack
yum upgrade (更新源) --本步驟須要先移除預裝的mariadb的包,不然報錯 :yum remove mariadb-libs
yum install python-openstackclient(安裝opentack必須的插件)
yum install openstack-selinux(可選則安裝這個插件,我直接關閉了selinux,由於不熟,對後續不會有影響)
說明:若是使用自定義源,那麼上面centos和redhat的操做能夠省略
1.五、部署mariadb數據庫
控制節點:
安裝報錯,經查資料懷疑是自帶的Mariadb干擾了
如圖查到了自帶的mariadb包,所有移除
# yum remove mariadb* -y
yum install mariadb mariadb-server python2-PyMySQL -y
編輯:
vi /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 111.111.111.201
default-storage-engine = innodb
innodb_file_per_table
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
啓服務:
# systemctl enable mariadb
# systemctl start mariadb
# systemctl status mariadb
mysql_secure_installation
先是設置密碼,會提示先輸入密碼
Enter current password for root (enter for none): <–初次運行直接回車
設置密碼 : P@ssw0rd
Set root password? [Y/n] <– 是否設置root用戶密碼,輸入y並回車或直接回車
New password: <– 設置root用戶的密碼
Re-enter new password: <– 再輸入一次你設置的密碼
其餘配置
Remove anonymous users? [Y/n] <– 是否刪除匿名用戶,Y,回車
Disallow root login remotely? [Y/n] <–是否禁止root遠程登陸,N,回車,
Remove test database and access to it? [Y/n] <– 是否刪除test數據庫,n,回車
Reload privilege tables now? [Y/n] <– 是否從新加載權限表,回車
初始化MariaDB完成
1.六、爲Telemetry 服務部署MongoDB
控制節點:
# yum install mongodb-server mongodb -y
編輯:vi /etc/mongod.conf
bind_ip = 111.111.111.201
smallfiles = true
啓動服務:
# systemctl enable mongod
# systemctl start mongod
1.七、部署消息隊列rabbitmq
控制節點:
# yum install rabbitmq-server -y
啓動服務:
# systemctl enable rabbitmq-server
# systemctl start rabbitmq-server
新建rabbitmq用戶密碼:
# rabbitmqctl add_user openstack P@ssw0rd
刪除了guest用戶:
# rabbitmqctl delete_user guest
爲新建的用戶openstack設定權限:
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
啓動管理WEB
rabbitmq-plugins enable rabbitmq_management
(驗證方式:http://111.111.111.201:15672/ 用戶:openstack 密碼:P@ssw0rd)
可是登錄失敗如紅框所示:Login failed
爲何呢?由於不是管理員!!
rabbitmqctl set_user_tags openstack administrator
以下圖所示,將openstack用戶添加爲管理員後就登錄成功了!
1.八、部署memcached緩存(爲keystone服務緩存tokens)
控制節點:
# yum install memcached python-memcached -y
cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="10240"
CACHESIZE="64"
#OPTIONS="-l 127.0.0.1,::1"
OPTIONS="-l 0.0.0.0"
疑問:這一步在官方文檔裏是不修改OPTIONS選項的,默認就是127.0.0.1那一行
啓動服務:
# systemctl enable memcached
# systemctl start memcached
基礎環境準備完畢!