OpenStack+CentOS7.6 雲平台環境搭建 — 1.操作系統環境配置及基礎服務創建


摘要

①控制節點(controller)

控制節點(controller)上運行身份服務,鏡像服務,計算節點管理,網絡管理,各種網絡代理和儀表板。它還包括支持服務,如SQL數據庫,消息隊列和NTP。

可選地,控制器節點運行塊存儲,對象存儲,編排和遙測服務的部分。

注:計算節點上需要至少配置兩塊網卡。

②計算節點(Nova)

計算節點運行操作實例的 計算部分。默認情況下使用 :`KVM 或QUME作為hypervisor。計算節點同樣運行網絡服務代理,用來連接實例到虛擬網絡,通過:security groups 為實例提供防火牆服務。instances via .

注:可以部署超過一個計算節點。但每個結算節點至少需要兩塊網卡。

③塊設備存儲(Cinder)

可選的塊存儲節點上包含了磁盤,塊存儲服務和共享文件系統會向實例提供這些磁盤。

為了簡單起見,計算節點和本節點之間的服務流量使用管理網絡。生產環境中應該部署一個單獨的存儲網絡以增強性能和安全。

注:可以部署超過一個塊存儲節點。但每個塊存儲節點要求至少一塊網卡。

④對象存儲

可選的對象存儲節點包含了磁盤。對象存儲服務用這些磁盤來存儲賬號,容器和對象。

為了簡單起見,計算節點和本節點之間的服務流量使用管理網絡。生產環境中應該部署一個單獨的存儲網絡以增強性能和安全。

一、部署環境

主機名

內存

硬盤

網卡

系統

ct

8

300+300

VM1:192.168.100.100

Centos7.6

NAT:20.0.0.10

c1

8

300+300

VM1:192.168.100.101

Centos7.6

NAT:20.0.0.20

c2

8

300+300

VM1:192.168.100.102

Centos7.6

NAT:20.0.0.30

二、基礎環境配置(所有節點,ct上演示)

2.1、修改主機名

1 [root@server1 ~]#  hostnamectl set-hostname ct 2 [root@server1 ~]#  su
3 
4 [root@server2 ~]#  hostnamectl set-hostname c1 5 [root@server2 ~]#  su
6 
7 [root@server3 ~]#  hostnamectl set-hostname c2 8 [root@server3 ~]#  su

2.2、基礎環境依賴包

1 [root@ct ~]# yum -y install net-tools bash-completion vim gcc gcc-c++ make pcre  pcre-devel expat-devel cmake  bzip2 
2 [root@ct ~]# yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils
1 python-openstackclient #安裝 OpenStack 客戶端 2 openstack-selinux             #RHEL和 CentOS 默認啟用 SELinux 。安裝 openstack-selinux 包實現對OpenStack服務的安全策略進行自動管理

2.3、設置網卡參數

 1 配置NAT網卡  2 [root@ct etcd]# vi /etc/sysconfig/network-scripts/ifcfg-ens33  3 TYPE=Ethernet  4 PROXY_METHOD=none  5 BROWSER_ONLY=no  6 BOOTPROTO=static  7 IPADDR=20.0.0.10
 8 NETMASK=255.255.255.0
 9 GATEWAY=20.0.0.2
10 DNS=20.0.0.2
11 DEFROUTE=yes 12 IPV4_FAILURE_FATAL=no 13 IPV6INIT=yes 14 IPV6_AUTOCONF=yes 15 IPV6_DEFROUTE=yes 16 IPV6_FAILURE_FATAL=no 17 IPV6_ADDR_GEN_MODE=stable-privacy 18 NAME=ens33 19 UUID=633054e7-1f23-4fd7-9007-24c491adff63 20 DEVICE=ens33 21 ONBOOT=yes 22 
23 配置VM1網卡 24 [root@ct etcd]# cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens37 25 [root@ct etcd]# vi /etc/sysconfig/network-scripts/ifcfg-ens37 26 TYPE=Ethernet 27 PROXY_METHOD=none 28 BROWSER_ONLY=no 29 BOOTPROTO=static 30 IPADDR=192.168.100.100
31 NETMASK=255.255.255.0
32 DEFROUTE=yes 33 IPV4_FAILURE_FATAL=no 34 IPV6INIT=yes 35 IPV6_AUTOCONF=yes 36 IPV6_DEFROUTE=yes 37 IPV6_FAILURE_FATAL=no 38 IPV6_ADDR_GEN_MODE=stable-privacy 39 NAME=ens37 40 DEVICE=ens37 41 ONBOOT=yes 42 
43 重啟網卡並查看 44 [root@ct ~]# systemctl restart network 45 [root@ct ~]# ip addr

 

 

2.4、配置Hosts

 1 [root@ct ~]# vi /etc/hosts  2 192.168.100.100 ct  3 192.168.100.101 c1  4 192.168.100.102 c2  5 
 6 [root@ct ~]# systemctl stop firewalld  7 [root@ct ~]# systemctl disable firewalld  8 [root@ct ~]# setenforce 0
 9 [root@ct ~]# vim /etc/sysconfig/selinux 10 SELINUX=disabled

2.5、免交互

1 非對稱密鑰 2 [root@ct ~]#  ssh-keygen -t rsa #一直空格 3 [root@ct ~]#  ssh-copy-id ct 4 [root@ct ~]#  ssh-copy-id c1 5 [root@ct ~]#  ssh-copy-id c2

2.6、配置DNS

1 [root@ct ~]# vim /etc/resolv.conf 2 nameserver 8.8.8.8

2.7、控制節點ct時間同步配置

 1 [root@ct ~]# yum install chrony -y  2 [root@ct ~]# vim /etc/chrony.conf  3 #4-7行注釋  4 #8行ct添加兩行  5 server ntp6.aliyun.com iburst  6 allow 192.168.100.0/24
 7 
 8 #8行另外兩個節點上添加一行  9 server ct iburst 10 
11 [root@ct ~]# systemctl enable chronyd 12 [root@ct ~]# systemctl restart chronyd 13 
14 使用 chronyc sources 命令查詢時間同步信息 15 [root@ct ~]# chronyc sources 16 210 Number of sources = 1
17 MS Name/IP address Stratum Poll Reach LastRx Last sample 18 ===============================================================================
19 ^* 203.107.6.88                  2   9   377    73  -2993us[-4411us] +/- 19ms 20 
21 設置周期性任務 22 [root@ct ~]# crontab -e 23 */30 * * * * /usr/bin/chronyc sources >> /var/log/chronyc.log 24 [root@ct ~]# crontab -l 25 */2 * * * * /usr/bin/chronyc sources >> /var/log/chronyc.log

三、配置服務(控制節點)

3.1、安裝、配置MariaDB

 1 [root@ct ~]# yum -y install mariadb mariadb-server python2-PyMySQL  2 
 3 #此包用於openstack的控制端連接mysql所需要的模塊,如果不安裝,則無法連接數據庫;此包只安裝在控制端  4 [root@ct ~]# yum -y install libibverbs  5 
 6 添加MySQL子配置文件,增加如下內容  7 [root@ct ~]# vim /etc/my.cnf.d/openstack.cnf  8 [mysqld]  9 bind-address = 192.168.100.100 #控制節點局域網地址 10 default-storage-engine = innodb #默認存儲引擎 11 innodb_file_per_table = on #每張表獨立表空間文件 12 max_connections = 4096 #最大連接數 13 collation-server = utf8_general_ci #默認字符集 14 character-set-server = utf8 15 
16 開機自啟動、開啟服務 17 [root@ct my.cnf.d]# systemctl enable mariadb 18 [root@ct my.cnf.d]# systemctl start mariadb 19 
20 執行MariaDB 安全配置腳本 21 [root@ct my.cnf.d]# mysql_secure_installation 22 Enter current password for root (enter for none): #回車 23 OK, successfully used password, moving on... 24 Set root password? [Y/n] Y 25 Remove anonymous users? [Y/n] Y 26  ... Success!
27 Disallow root login remotely? [Y/n] N 28  ... skipping. 29 Remove test database and access to it? [Y/n] Y 30 Reload privilege tables now? [Y/n] Y     

3.2、安裝RabbitMQ

所有創建虛擬機的指令,控制端都會發送到rabbitmq,node節點監聽rabbitmq

 1 [root@ct ~]# yum -y install rabbitmq-server  2 
 3 配置服務,啟動RabbitMQ服務,並設置其開機啟動  4 [root@ct ~]# systemctl enable rabbitmq-server.service  5 [root@ct ~]# systemctl start rabbitmq-server.service  6 
 7 創建消息隊列用戶,用於controler和node節點連接rabbitmq的認證  8 [root@ct ~]# rabbitmqctl add_user openstack RABBIT_PASS  9 Creating user "openstack"
10 
11 配置openstack用戶的操作權限(正則,配置讀寫權限) 12 [root@ct ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
13 Setting permissions for user "openstack" in vhost "/"
14 
15 查看rabbitmq插件列表 16 [root@ct ~]# rabbitmq-plugins list 17  Configured: E = explicitly enabled; e = implicitly enabled 18  | Status:   [failed to contact rabbit@ct - status not shown] 19  |/
20 [e ] amqp_client                       3.6.16
21 [e ] cowboy                            1.0.4
22 [e ] cowlib                            1.0.2
23 [  ] rabbitmq_amqp1_0                  3.6.16
24 [  ] rabbitmq_auth_backend_ldap        3.6.16
25 [  ] rabbitmq_auth_mechanism_ssl       3.6.16
26 [  ] rabbitmq_consistent_hash_exchange 3.6.16
27 [  ] rabbitmq_event_exchange           3.6.16
28 [  ] rabbitmq_federation               3.6.16
29 [  ] rabbitmq_federation_management    3.6.16
30 [  ] rabbitmq_jms_topic_exchange       3.6.16
31 [E ] rabbitmq_management               3.6.16
32 [e ] rabbitmq_management_agent         3.6.16
33 [  ] rabbitmq_management_visualiser    3.6.16
34 [  ] rabbitmq_mqtt                     3.6.16
35 [  ] rabbitmq_random_exchange          3.6.16
36 [  ] rabbitmq_recent_history_exchange  3.6.16
37 [  ] rabbitmq_sharding                 3.6.16
38 [  ] rabbitmq_shovel                   3.6.16
39 [  ] rabbitmq_shovel_management        3.6.16
40 [  ] rabbitmq_stomp                    3.6.16
41 [  ] rabbitmq_top                      3.6.16
42 [  ] rabbitmq_tracing                  3.6.16
43 [  ] rabbitmq_trust_store              3.6.16
44 [e ] rabbitmq_web_dispatch             3.6.16
45 [  ] rabbitmq_web_mqtt                 3.6.16
46 [  ] rabbitmq_web_mqtt_examples        3.6.16
47 [  ] rabbitmq_web_stomp                3.6.16
48 [  ] rabbitmq_web_stomp_examples       3.6.16
49 [  ] sockjs                            0.3.4
50 
51 開啟rabbitmq的web管理界面的插件,端口為15672 52 [root@ct ~]# rabbitmq-plugins enable rabbitmq_management 53 The following plugins have been enabled: 54 mochiweb 55 webmachine 56 rabbitmq_web_dispatch 57 amqp_client 58 rabbitmq_management_agent 59 rabbitmq_management 60 
61 Applying plugin configuration to rabbit@likeadmin... started 6 plugins. 62 
63 檢查端口(25672 5672 1567264 [root@ct ~]# ss -anpt | grep 5672
65 LISTEN     0      128          *:25672                    *:*                   users:(("beam.smp",pid=35087,fd=46)) 66 LISTEN     0      128          *:15672                    *:*                   users:(("beam.smp",pid=35087,fd=57)) 67 LISTEN     0      128         :::5672                    :::*                   users:(("beam.smp",pid=35087,fd=55))

網頁訪問http://20.0.0.10:15672,默認賬戶密碼均為guest

 

 

 

 

3.3、安裝memcached

3.3.1、作用

安裝memcached是用於存儲session信息;服務身份驗證機制使用Memcached來緩存令牌 在登錄openstack的dashboard時,會產生一些session信息,這些session信息會存放到memcached中

3.3.2、 安裝Memcached

 1 [root@ct ~]# yum install -y memcached python-memcached  2 #python-*模塊在OpenStack中起到連接數據庫的作用  3 
 4 修改Memcached配置文件  5 [root@ct ~]# cat /etc/sysconfig/memcached  6 PORT="11211"
 7 USER="memcached"
 8 MAXCONN="1024"
 9 CACHESIZE="64"
10 OPTIONS="-l 127.0.0.1,::1,ct"
11 
12 [root@ct ~]# systemctl enable memcached 13 [root@ct ~]# systemctl start memcached 14 
15 [root@ct ~]# netstat -nautp | grep 11211

3.4、安裝etcd

 1 [root@ct ~]# yum -y install etcd  2 
 3 修改etcd配置文件  4 [root@ct ~]# cd /etc/etcd/
 5 [root@ct etcd]# ls
 6 etcd.conf  7 [root@ct etcd]# vim etcd.conf  8 ETCD_DATA_DIR="/var/lib/etcd/default.etcd" #數據目錄位置  9 ETCD_LISTEN_PEER_URLS="http://192.168.100.100:2380" #監聽其他etcd member的url(2380端口,集群之間通訊,域名為無效值) 10 ETCD_LISTEN_CLIENT_URLS="http://192.168.100.100:2379" #對外提供服務的地址(2379端口,集群內部的通訊端口) 11 ETCD_NAME="ct" #集群中節點標識(名稱) 12 ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.100.100:2380"
13 ETCD_ADVERTISE_CLIENT_URLS="http://192.168.100.100:2379
14 ETCD_INITIAL_CLUSTER="ct=http://192.168.100.100:2380" #該節點成員的URL地址,2380端口:用於集群之間通訊。 15 ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01" #集群唯一標識 16 ETCD_INITIAL_CLUSTER_STATE="new" #初始集群狀態,new為靜態,若為existing,則表示此ETCD服務將嘗試加入已有的集群 17 若為DNS,則表示此集群將作為被加入的對象 18 
19 開機自啟動、開啟服務,檢測端口 20 [root@ct ~]# systemctl enable etcd.service 21 [root@ct ~]# systemctl start etcd.service 22 [root@ct ~]# netstat -anutp |grep 2379
23 [root@ct ~]# netstat -anutp |grep 2380

注:至此OpenStack基礎環境已基本搭建完成

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM