1. 程式人生 > >OpenStack—Q 環境部署

OpenStack—Q 環境部署

一、基本配置要求

配置: VMware-14、Centos7.5、雙節點 Controller節點:4G執行記憶體、2個處理器、50G硬碟 Compute 節點:2G執行記憶體、2個處理、50G硬碟 在這裡插入圖片描述 在這裡插入圖片描述 網路要求: 同我之前搭建的OpenStack-M版(一個內網,一個外網) ens33作為管理網路,主要負責各節點之間的通訊 ens34作為外部網路,主要負責與外部通訊 配置過程(略) Linux網路配置教程:

二、配置主機對映

Controller、Compute節點

修改/etc/hosts(新增)

# vi /etc/hosts
192.168.100.10 controller
192.168.100.20 compute

檢查網路連通性 在這裡插入圖片描述 在這裡插入圖片描述

三、配置阿里yum源

    備份
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    下載
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    # yum clean all (清除yum快取)

四、安裝NTP時鐘服務

Controller節點

# yum install -y chrony

編輯chrony.conf檔案,在檔案中新增、更改或刪除以下內容
vi /etc/chrony.conf
server  controlelr  iburst  ##所有節點向controller節點同步時間
allow 10.71.11.0/24         ##設定時間同步網段

設定NTP服務開機啟動
# systemctl enable chronyd.service
# systemctl start chronyd.service

compute節點

    # yum install chrony -y
   
    配置所有節點指向controller同步時間
    vi /etc/chrony.conf
    server  controlelr  iburst

    # systemctl enable chronyd.service
    # systemctl start chronyd.service

驗證時鐘同步服務 在controller節點執行

[[email protected] ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* time4.aliyun.com              2  10   377  1015   +115us[ +142us] +/-   14ms
^- ntp8.flashdance.cx            2  10   347   428    +27ms[  +27ms] +/-  259ms
^- 85.199.214.101                1  10   377   988    +38ms[  +38ms] +/-  202ms
^- ntp7.flashdance.cx            2  10   367   836    +35ms[  +35ms] +/-  247ms

MS列中的內容應該指明* NTP服務當前同步的伺服器。 在其他節點執行

[[email protected] ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* leontp.ccgs.wa.edu.au         1  10   377   752    +49ms[  +49ms] +/-  121ms
^+ ntp5.flashdance.cx            2  10   373  1155    +15ms[  +16ms] +/-  258ms
^+ 85.199.214.101                1  10   377   46m    -22ms[  -21ms] +/-  164ms
^+ ntp8.flashdance.cx            2  10   333   900  -6333us[-5976us] +/-  257ms

注意:日常運維中經常遇見時鐘飄逸問題,導致叢集服務腦裂

五、安裝Q版OpenStack

Controller、Compute節點

# yum install -y centos-release-openstack-queens
更新linux包
# yum upgrade   
安裝OpenStack client
# yum install -y python-openstackclient
安裝OpenStack-selinux來自動化管理OpenStack服務的安全策略
# yum install -y openstack-selinux

六、安裝SQL database

Controller節點

# yum install -y mariadb mariadb-server python2-PyMySQL

建立並編寫/etc/my.cnf.d/openstack.cnf檔案
(備份你/etc/my.cnf.d/目錄下所需的配置檔案)

建立一個[mysqld]部分,並將bind-address設定為controller節點的管理IP地址,以支援通過管理網路訪問其他節點。設定額外的鍵來啟用有用的選項和UTF-8字符集:
[mysqld]
bind-address = 192.168.100.10
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
# systemctl enable mariadb.service
# systemctl start mariadb.service
# 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   (資料庫密碼設為  123456,避免出錯)
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
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

七、安裝RabbitMQ(訊息佇列)元件

controller節點

# yum install -y rabbitmq-server
# systemctl enable rabbitmq-server.service;systemctl start rabbitmq-server.service

新增openstack 使用者
rabbitmqctl add_user openstack 123456
openstack使用者配置讀寫、訪問的許可權
rabbitmqctl set_permissions openstack ".*" ".*" ".*"

安裝快取資料庫Memcached
# yum install -y memcached python-memcached

編輯/etc/sysconfig/memcached通過管理網路支援其他節點訪問
(在OPTIONS中新增controller)
vi /etc/sysconfig/memcached
OPTIONS="-l 127.0.0.1,::1,controller"

八、Etcd服務安裝

Controller節點

1.安裝服務

# yum install -y etcd

2.編輯/etc/etcd/etcd.conf檔案,設定為管理controller節點的IP地址和主機名,以支援通過管理網路訪問其他節點

#[Member]
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.100.10:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.100.10:2379"
ETCD_NAME="controller"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.100.10:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.100.10:2379"
ETCD_INITIAL_CLUSTER="controller=http://192.168.100.10:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_INITIAL_CLUSTER_STATE="new"