1. 程式人生 > >OpenStack部署(一)

OpenStack部署(一)

systemd include init mman lean ted none 實施 monit

OpenStack介紹:

OpenStack是一個由NASA(美國國家航空航天局)和Rackspace合作研發並發起的,以Apache許可證授權的自由軟件和開放源代碼項目。

OpenStack是一個開源的雲計算管理平臺項目,由幾個主要的組件組合起來完成具體工作。OpenStack支持幾乎所有類型的雲環境,項目目標是提供實施簡單、可大規模擴展、豐富、標準統一的雲計算管理平臺。OpenStack通過各種互補的服務提供了基礎設施即服務(IaaS)的解決方案,每個服務提供API以進行集成。

OpenStack是一個旨在為公共及私有雲的建設與管理提供軟件的開源項目。它的社區擁有超過130家企業及1350位開發者,這些機構與個人都將OpenStack作為基礎設施即服務(IaaS)資源的通用前端。OpenStack項目的首要任務是簡化雲的部署過程並為其帶來良好的可擴展性。本文希望通過提供必要的指導信息,幫助大家利用OpenStack前端來設置及管理自己的公共雲或私有雲。

OpenStack雲計算平臺,幫助服務商和企業內部實現類似於 Amazon EC2 和 S3 的雲基礎架構服務(Infrastructure as a Service, IaaS)。OpenStack 包含兩個主要模塊:Nova 和 Swift,前者是 NASA 開發的虛擬服務器部署和業務計算模塊;後者是 Rackspace開發的分布式雲存儲模塊,兩者可以一起用,也可以分開單獨用。OpenStack除了有 Rackspace 和 NASA 的大力支持外,還有包括 Dell、Citrix、 Cisco、 Canonical等重量級公司的貢獻和支持,發展速度非常快,有取代另一個業界領先開源雲平臺 Eucalyptus 的態勢。

OpenStack架構1:
技術分享圖片

OpenStack架構2:
技術分享圖片

OpenStack版本:
技術分享圖片

OpenStack官網:
http://www.openstack.org/

OpenStack Services:
技術分享圖片

實驗架構:
環境:
操作系統:
CentOS-7-x86_64-Minimal-1611

linux-node1.smoke.com: 192.168.56.11 控制節點
技術分享圖片
linux-node2.smoke.com: 192.168.56.12 計算節點
技術分享圖片

node1:
修改主機名:註意:修改主機名,以後不能更改。

[root@localhost ~]# hostname linux-node1.smoke.com`
[root@localhost ~]# vim /etc/hostname
hostname linux-node1.smoke.com

網卡配置:

[root@linux-node1 ~]# ifconfig 
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.11  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::20c:29ff:fe81:308f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:81:30:8f  txqueuelen 1000  (Ethernet)
        RX packets 1198  bytes 105479 (103.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1079  bytes 228271 (222.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.47.136  netmask 255.255.255.0  broadcast 192.168.47.255
        inet6 fe80::20c:29ff:fe81:3099  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:81:30:99  txqueuelen 1000  (Ethernet)
        RX packets 20266  bytes 29152833 (27.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4139  bytes 258109 (252.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

添加hosts文件:

[root@linux-node1 ~]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.11   linux-node1 linux-node1.smoke.com
192.168.56.12   linux-node2 linux-node2.smoke.com

時間同步:會影響OpenStack正常運行。

[root@linux-node1 ~]# yum -y install chrony
[root@linux-node1 ~]# vim /etc/chrony.conf
allow 192.168.0.0/16
[root@linux-node1 ~]# systemctl enable chronyd.service
[root@linux-node1 ~]# systemctl start chronyd.service

設置時區:
[root@linux-node1 ~]# timedatectl set-timezone Asia/Shanghai

[root@linux-node1 ~]# date
2018年 09月 30日 星期日 22:33:31 CST

安裝MySQL:

[root@linux-node1 ~]# yum -y install mariadb mriadb-server MySQL-python

[root@linux-node1 ~]# cp /usr/share/mariadb/my-medium.cnf /etc/my.cnf
cp:是否覆蓋"/etc/my.cnf"? y
[root@linux-node1 ~]# vim /etc/my.cnf
[mysqld]
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = ‘SET NAMES utf8‘
character-set-server = utf8
[root@linux-node1 ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@linux-node1 ~]# systemctl start mariadb.service
[root@linux-node1 ~]# 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
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] Y
 ... Success!

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!
[root@linux-node1 ~]# mysql -uroot -psmoke520
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)

MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| column_stats              |
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| gtid_slave_pos            |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| index_stats               |
| innodb_index_stats        |
| innodb_table_stats        |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| roles_mapping             |
| servers                   |
| slow_log                  |
| table_stats               |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
30 rows in set (0.01 sec)

MariaDB [mysql]> exit;
Bye

Keystone數據庫:

[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "CREATE DATABASE keystone;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "GRANT ALL PRIVILEGES ON keystone.* TO ‘keystone‘@‘localhost‘ IDENTIFIED BY ‘keystone‘;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "GRANT ALL PRIVILEGES ON keyston.* TO ‘keystone‘@‘%‘ IDENTIFIED BY ‘keystone‘;"

Glance數據庫:

[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "CREATE DATABASE glance;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "GRANT ALL PRIVILEGES ON glance.* TO ‘glance‘@‘localhost‘ IDENTIFIED BY ‘glance‘;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "GRANT ALL PRIVILEGES ON glance.* TO ‘glance‘@‘%‘ IDENTIFIED BY ‘glance‘;"

Nove數據庫:

[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "CREATE DATABASE nova;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "GRANT ALL PRIVILEGES ON nova.* TO ‘nova‘@‘localhost‘ IDENTIFIED BY ‘nova‘;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "GRANT ALL PRIVILEGES ON nova.* TO ‘nova‘@‘%‘ IDENTIFIED BY ‘nova‘;"

Neutron數據庫:

[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "CREATE DATABASE neutron;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron‘@‘localhost‘ IDENTIFIED BY ‘neutron‘;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "GRANT ALL PRIVILEGES ON neutron.* TO ‘neutron‘@‘%‘ IDENTIFIED BY ‘neutron‘;"

Cinder數據庫:

[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "CREATE DATABASE cinder;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "GRANT ALL PRIVILEGES ON cinder.* TO ‘cinder‘@‘localhost‘ IDENTIFIED BY ‘cinder‘;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 -e "GRANT ALL PRIVILEGES ON cinder.* TO ‘cinder‘@‘%‘ IDENTIFIED BY ‘cinder‘;"
[root@linux-node1 ~]# mysql -uroot -psmoke520 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 30
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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| cinder             |
| glance             |
| information_schema |
| keystone           |
| mysql              |
| neutron            |
| nova               |
| performance_schema |
+--------------------+
8 rows in set (0.00 sec)

MariaDB [(none)]> exit;
Bye

SOA(面向服務的架構) :
面向服務架構,它可以根據需求通過網絡對松散耦合的粗粒度應用組件進行分布式部署、組合和使用。服務層是SOA的基礎,可以直接被應用調用,從而有效控制系統中與軟件代理交互的人為依賴性。
SOA是一種粗粒度、松耦合服務架構,服務之間通過簡單、精確定義接口進行通訊,不涉及底層編程接口和通訊模型。SOA可以看作是B/S模型、XML(標準通用標記語言的子集)/Web Service技術之後的自然延伸。
SOA將能夠幫助軟件工程師們站在一個新的高度理解企業級架構中的各種組件的開發、部署形式,它將幫助企業系統架構者以更迅速、更可靠、更具重用性架構整個業務系統。較之以往,以SOA架構的系統能夠更加從容地面對業務的急劇變化。

體系結構:
松耦合的系統

基本特征:
可從企業外部訪問
隨時可用
粗粒度的服務接口分級
松散耦合
可重用的服務
服務接口設計管理
標準化的服務接口
支持各種消息模式
精確定義的服務契約

SOA 服務用消息進行通信,該消息通常使用XML Schema來定義(也叫做XSD, XML Schema Definition)。消費者和提供者或消費者和服務之間的通信多見於不知道提供者的環境中。服務間的通訊也可以看作企業內部處理的關鍵商業文檔。

SOA服務通過一個扮演目錄列表(directory listing)角色的登記處(Registry)來進行維護。應用程序在登記處(Registry)尋找並調用某項服務。統一描述,定義和集成(UDDI, Universal Description, Definition, and Integration)是服務登記的標準。

安裝Message queue(消息隊列):
OpenStack支持RabbitMQ,Qpid,ZeroMQ消息隊列。
[root@linux-node1 ~]# yum -y install rabbitmq-server
如果yum無法安裝,可以到官網下載最新包安裝,https://github.com/rabbitmq/rabbitmq-server/releases/tag/v3.7.8

[root@linux-node1 ~]# ll
總用量 258604
-rw-------. 1 root root 1245 7月 18 19:48 anaconda-ks.cfg
-rw-r--r-- 1 root root 170023183 10月 1 01:53 jdk-8u181-linux-x64.rpm
drwxrwxr-x 12 421 wheel 4096 10月 1 01:47 otp_src_21.1
-rw-r--r-- 1 root root 85214629 10月 1 01:22 otp_src_21.1.tar.gz
-rw-r--r-- 1 root root 9557762 10月 1 01:08 rabbitmq-server-3.7.8-1.el7.noarch.rpm

JDK下載地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

[root@linux-node1 ~]# yum -y install jdk-8u181-linux-x64.rpm
[root@linux-node1 otp_src_21.1]# yum -y install make ncurses-devel gcc gcc-c++ unixODBC unixODBC-devel openssl openssl-devel

wxWidgets下載地址:
https://www.wxwidgets.org/downloads/
[root@linux-node1 wxWidgets-3.1.1]# yum -y install gtk2-devel binutils-devel
[root@linux-node1 ~]# tar xf wxWidgets-3.1.1.tar.bz2
[root@linux-node1 ~]# cd wxWidgets-3.1.1
[root@linux-node1 wxWidgets-3.1.1]# yum install gtk2-devel
[root@linux-node1 wxWidgets-3.1.1]# yum -y install mesa-libGLU-devel
[root@linux-node1 wxWidgets-3.1.1]# ./configure --with-opengl --enable-debug --enable-unicode
[root@linux-node1 wxWidgets-3.1.1]# make && make install
[root@linux-node1 include]# vim /etc/ld.so.conf.d/wxWidgets.conf
[root@linux-node1 include]# ldconfig

Erlang下載地址:
http://www.erlang.org/downloads

[root@linux-node1 ~]# tar xf otp_src_21.1.tar.gz
[root@linux-node1 ~]# cd otp_src_21.1
[root@linux-node1 otp_src_21.1]# ./configure

node2:
[root@localhost ~]# hostname linux-node2.smoke.com

[root@cloud ~]# vim /etc/hostname
hostname linux-node2.smoke.com
[root@localhost ~]# ifconfig 
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.12  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::9752:504d:ee43:64f5  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b2:dc:b3  txqueuelen 1000  (Ethernet)
        RX packets 23651  bytes 33698486 (32.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6118  bytes 455955 (445.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.47.135  netmask 255.255.255.0  broadcast 192.168.47.255
        inet6 fe80::c33f:7c14:d42c:bc06  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b2:dc:bd  txqueuelen 1000  (Ethernet)
        RX packets 684  bytes 49408 (48.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 108  bytes 10149 (9.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 20  bytes 1708 (1.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20  bytes 1708 (1.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@linux-node2 ~]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.11   linux-node1 linux-node1.smoke.com
192.168.56.12   linux-node2 linux-node2.smoke.com
[root@linux-node2 ~]# yum -y install chrony`
allow 192.168.0.0/16
[root@linux-node2 ~]# systemctl enable chronyd.service

[root@linux-node2 ~]# systemctl start chronyd.service

[root@linux-node2 ~]# timedatectl set-timezone Asia/Shanghai

[root@linux-node2 ~]# date
2018年 09月 30日 星期日 22:33:55 CST

OpenStack部署(一)