詳細Openstack T版部署搭建-Vmware實踐


 

Openstack Train版本部署指南實踐。

本指南根據官方網站而寫,並結合個人實踐,

詳細說明可參考官方教程:OpenStack Installation Guide — Installation Guide documentatio

如有問題請留言,或點擊頁腳添加聯系方式。

 

>點擊此處加QQ群<歡迎大家共同交流,不足之處請指正。

一、環境

vmware:

  controller節點:                                  

       配置:                                       

       內存:6G                                              

       處理器:四核                                      

       硬盤:60G                                        

       網卡:1、NAT(外部網卡)ens33:192.168.200.10                           

          2、僅主機(管理網絡)ens34:192.168.100.10                              

          鏡像:CentOS-7-x86_64-Minimal-2009                           

     compute節點:

                配置:

                     內存:4G

                     處理器:4核

                     硬盤:60G

                     網卡:1、NAT(外部網卡)ens33:192.168.200.20

                               2、僅主機(管理網絡)ens34:192.168.100.20

                     鏡像:CentOS-7-x86_64-Minimal-2009

 

打開虛擬化:

 

密碼記錄表:
服務 用戶 密碼
mysql root 000000
  keystone KEYSTONE_DBPASS
  glance GLANCE_DBPASS
  placement PLACEMENT_DBPASS
  nova NOVA_DBPASS
  neutron NEUTRON_DBPASS
     
rabbitmq openstack 000000
     
     
openstack用戶(keystone) admin ADMIN_PASS
  myuser myuser
  glance glance
  placement placement
  nova nova
     
metadata metadata_secret METADATA_SECRET

通過用keepalived和haproxy實現高可用

二、基本環境配置步驟

1、初始化環境配置

(以下controller、compute節點配置)

#####controller和compute節點#####
#安裝基礎工具包
yum install wget net-tools vim -y


#修改對應的主機名稱,改完之后需要exit后重新進入終端,才顯示
hostnamectl set-hostname compute
hostnamectl set-hostname controller	

#關閉seliux、防火牆
sed -i 's\SELINUX=enforcing\SELINUX=disable\' /etc/selinux/config				//替換config文件中的enforcing為disable          (enforcing:強制執行)
setenforce 0
systemctl stop firewalld && systemctl disable firewalld
#查看防火牆規則iptables -L,若沒有則關掉

#測試網絡連通性,若沒問題則繼續
ping www.baidu.com

#配置名稱解析(更改自己對應的管理網絡onlyhost)
sed -i '$a\192.168.100.10 controller\' /etc/hosts
sed -i '$a\192.168.100.20 compute\' /etc/hosts

2、時間同步服務器的安裝與配置

#####controller節點安裝時間同步服務器chrony,刪除已有的無用server,配置阿里雲服務器,設置允許本地所有網段#####
#安裝chrony包
yum install chrony -y

#編輯配置文件
sed -i '3,6d' /etc/chrony.conf
sed -i '3a\server ntp3.aliyun.com iburst\' /etc/chrony.conf	
sed -i 's\#allow 192.168.0.0/16\allow all\' /etc/chrony.conf
sed -i 's\#local stratum 10\local stratum 10\' /etc/chrony.conf

#啟動服務
systemctl enable chronyd.service
systemctl restart chronyd.service


#####compute和其他節點也安裝服務器,刪除已有的無用server,配置服務器為controller節點#####
#安裝chrony包
yum install chrony -y

#編輯配置文件
sed -i '3,6d' /etc/chrony.conf
sed -i '3a\server controller iburst\' /etc/chrony.conf

#啟動服務
systemctl enable chronyd.service
systemctl restart chronyd.service

#查看同步情況,顯示controller即為成功
chronyc sources -v

 

 

3、安裝openstack源

#####controller和compute安裝train的yum源#####
yum install centos-release-openstack-train -y
yum upgrade	
yum install python-openstackclient  -y
yum install openstack-utils -y
openstack-selinux(暫時未裝)

4、安裝SQL數據庫

#####controller節點#####
#安裝數據庫包
yum install mariadb mariadb-server python2-PyMySQL -y
#創建並編輯配置文件
touch /etc/my.cnf.d/openstack.cnf

cat > /etc/my.cnf.d/openstack.cnf << EOF
[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
EOF

#啟動服務
systemctl enable mariadb.service
systemctl restart mariadb.service

#初始化數據庫,並設置root密碼
mysql_secure_installation			
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

5、安裝消息隊列

#####controller#####
#安裝rabbitmq-server包
yum install rabbitmq-server -y
#啟動服務
systemctl enable rabbitmq-server.service
systemctl start rabbitmq-server.service
#添加rabbitmq用戶並配置權限
rabbitmqctl add_user openstack 000000						//RABBIT_PASS改為密碼
rabbitmqctl set_permissions openstack ".*" ".*" ".*"			//允許openstack用戶進行配置、寫入和讀取訪問
# 查看需要啟動的服務
rabbitmq-plugins list
# 開啟圖形化界面
rabbitmq-plugins enable rabbitmq_management rabbitmq_management_agent

ss -tnl						//查詢監聽端口
					    	//-t, –tcp 顯示 TCP 協議的 sockets
 							//-n, –numeric 不解析服務的名稱,如 “22” 端口不會顯示成 “ssh”
 							//-l, –listening 只顯示處於監聽狀態的端口
# 訪問
http://192.168.100.10:15672/				//賬號:guest	密碼:guest


#rabbitmqctl常用命令:
rabbitmqctl list_users				//查詢用戶

6、緩存Memcached

#####controller節點#####
#安裝memcached包
yum install memcached python-memcached -y
#編輯配置文件
sed -i 's\OPTIONS="-l 127.0.0.1,::1"\OPTIONS="-l 127.0.0.1,::1,controller"\' /etc/sysconfig/memcached
sed -i 's\CACHESIZE="64"\CACHESIZE="1024"\' /etc/sysconfig/memcached
#啟動服務
systemctl enable memcached.service
systemctl restart memcached.service

7、Etcd

#####controller#####
#安裝etcd包
yum install etcd -y
cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak		//備份一下配置文件

#編輯配置文件
sed -i 's\#ETCD_LISTEN_PEER_URLS="http://localhost:2380"\ETCD_LISTEN_PEER_URLS="http://192.168.100.10:2380"\' /etc/etcd/etcd.conf
sed -i 's\ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"\ETCD_LISTEN_CLIENT_URLS="http://192.168.100.10:2379"\' /etc/etcd/etcd.conf
sed -i 's\ETCD_NAME="default"\ETCD_NAME="controller"\' /etc/etcd/etcd.conf
sed -i 's\#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"\ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.100.10:2380"\' /etc/etcd/etcd.conf
sed -i 's\ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"\ETCD_ADVERTISE_CLIENT_URLS="http://192.168.100.10:2379"\' /etc/etcd/etcd.conf
sed -i 's\#ETCD_INITIAL_CLUSTER="default=http://localhost:2380"\ETCD_INITIAL_CLUSTER="controller=http://192.168.100.10:2380"\' /etc/etcd/etcd.conf
sed -i 's\#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"\ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"\' /etc/etcd/etcd.conf
sed -i 's\#ETCD_INITIAL_CLUSTER_STATE="new"\ETCD_INITIAL_CLUSTER_STATE="new"\' /etc/etcd/etcd.conf

#啟動
systemctl enable etcd
systemctl restart etcd

 三、Openstack Train版各個組件配置步驟

1、keystone組件部署

#####controller節點#####
#創建數據庫、並配置密碼和權限
mysql -uroot -p
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'KEYSTONE_DBPASS';		
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'KEYSTONE_DBPASS';

#安裝軟件包
yum install openstack-keystone httpd mod_wsgi -y

#編輯配置文件
	//修改配置文件/etc/keystone/keystone.conf,在相應位置添加如下:
    
    [database]
	# ...
	connection = mysql+pymysql://keystone:KEYSTONE_DBPASS@controller/keystone
    
    [token]
	# ...
	provider = fernet
    
(或使用如下命令)
sed -i 's\#connection = <None>\connection = mysql+pymysql://keystone:KEYSTONE_DBPASS@controller/keystone\' /etc/keystone/keystone.conf
sed -i '2475a\provider = fernet\' /etc/keystone/keystone.conf

#同步keystone數據庫
su -s /bin/sh -c "keystone-manage db_sync" keystone
//可使用查詢命令show tables from keystone;有表即為成功。

#創建令牌
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone

keystone-manage bootstrap --bootstrap-password ADMIN_PASS --bootstrap-admin-url http://controller:5000/v3/ \
--bootstrap-internal-url http://controller:5000/v3/ --bootstrap-public-url http://controller:5000/v3/ --bootstrap-region-id RegionOne

#配置Apache HTTP服務器
sed -i '/#ServerName www.example.com:80/a\ServerName controller:80\' /etc/httpd/conf/httpd.conf
ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/

#開啟HTTP服務
systemctl enable httpd.service
systemctl restart httpd.service

#編寫臨時環境變量腳本
touch ~/temp_admin.sh

cat >~/temp_admin.sh << EOF
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
EOF	
//此處顯示的指是由keystone-manage bootstrap創建



source ~/temp_admin.sh				//添加包含openstack密碼的臨時環境變量

 

#####controller節點######
#創建域、項目、用戶和角色
openstack project create --domain default --description "Service Project" service		//使用默認域創建service項目
openstack project create --domain default --description "Demo Project" myproject		//使用默認域創建myproject項目(no-admin使用)
openstack user create --domain default --password-prompt myuser							//創建myuser用戶,需要設置密碼,可設置為myuser
openstack role create myrole															//創建myrole角色
openstack role add --project myproject --user myuser myrole								//添加myrole至myproject的myuser用戶,此項無輸出

#####controller#####
(跳過驗證步驟)
##配置環境變量腳本(臨時棄用)
unset OS_AUTH_URL OS_PASSWORD		//清楚臨時腳本

#admin(管理員)
touch ~/admin-openrc.sh
cat > ~/admin-openrc.sh << EOF
#!/bin/bash
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
EOF
//PASSWORD設置成自己設置的密碼


#myuser(非管理員)(!可選配置,搭建環境主要使用admin!)
touch ~/myuser-openrc.sh
cat > ~/myuser-openrc.sh << EOF
#!/bin/bash
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=myproject
export OS_USERNAME=myuser
export OS_PASSWORD=myuser
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
EOF
//PASSWORD設置成自己設置的密碼

#執行環境變量
source admin-openrc.sh

#驗證
openstack user list
//若有內容即為成功

2、搭建Glance鏡像服務

#####controller
#創建glance數據庫
mysql -u root -p000000
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';

#若這之前關過機器或重開了終端,則需再加載一次環境變量口令
source ~/admin-openrc.sh

#創建用戶、角色
openstack user create --domain default --password glance glance							//創建glance用戶,密碼glance
openstack role add --project service --user glance admin								
openstack service create --name glance --description "OpenStack Image" image

#創建glance endpoint
openstack endpoint create --region RegionOne image public http://controller:9292
openstack endpoint create --region RegionOne image internal http://controller:9292
openstack endpoint create --region RegionOne image admin http://controller:9292

#####controller#####
#安裝服務
yum install openstack-glance -y

#配置glance服務
cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
sed -i '2072a\connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance\' /etc/glance/glance-api.conf
sed -i '4859a\www_authenticate_uri  = http://controller:5000\' /etc/glance/glance-api.conf
sed -i '4860a\memcached_servers = controller:11211\' /etc/glance/glance-api.conf
sed -i '4861a\auth_type = password\' /etc/glance/glance-api.conf
sed -i '4862a\project_domain_name = Default\' /etc/glance/glance-api.conf
sed -i '4863a\user_domain_name = Default\' /etc/glance/glance-api.conf
sed -i '4864a\project_name = service\' /etc/glance/glance-api.conf
sed -i '4865a\username = glance\' /etc/glance/glance-api.conf
sed -i '4866a\password = glance\' /etc/glance/glance-api.conf
sed -i '4867a\auth_url = http://controller:5000\' /etc/glance/glance-api.conf
sed -i '5503a\flavor = keystone\' /etc/glance/glance-api.conf
sed -i '3350a\stores = file,http\' /etc/glance/glance-api.conf
sed -i '3350a\default_store = file\' /etc/glance/glance-api.conf

#存儲位置
sed -i '3350a\filesystem_store_datadir = /var/lib/glance/images/\' /etc/glance/glance-api.conf
#
#同步數據庫
su -s /bin/sh -c "glance-manage db_sync" glance

#啟動glance服務
systemctl enable openstack-glance-api.service
systemctl restart openstack-glance-api.service


*查看日志命令
tail -f /var/log/glance/api.log

                日志沒問題

#####controller#####
##驗證操作上傳鏡像
#下載鏡像
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img

#上傳鏡像
glance image-create --name "cirros" --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility public

#查看鏡像列表
openstack image list

3、Placement服務搭建

        在Openstack的Stein版本之前,Placement組件是nova組件的一部分,在Stein版本之后Placement組件被獨立出來,所以在安裝Nova之前需要先安裝Placement。

        作用:Placement服務可以跟蹤服務器資源的使用情況,提供自定義資源的能力,為分配資源提供服務。

#####Controller#####
#創建數據庫
mysql -u root -p000000					//這里000000換成自己的數據庫root密碼
CREATE DATABASE placement;
GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY 'PLACEMENT_DBPASS';
GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'PLACEMENT_DBPASS';

#創建placement用戶,添加角色
openstack user create --domain default --password placement placement				//設置密碼為placement
openstack role add --project service --user placement admin
openstack service create --name placement --description "Placement API" placement

#創建endpoint
openstack endpoint create --region RegionOne placement public http://controller:8778
openstack endpoint create --region RegionOne placement internal http://controller:8778
openstack endpoint create --region RegionOne placement admin http://controller:8778

#####controler#####
#安裝和配置組件
yum install openstack-placement-api -y
cp /etc/placement/placement.conf /etc/placement/placement.conf.bak
sed -i 's\#connection = <None>\connection = mysql+pymysql://placement:PLACEMENT_DBPASS@controller/placement\' /etc/placement/placement.conf		//設置成自己的密碼
sed -i 's\#auth_strategy = keystone\auth_strategy = keystone\' /etc/placement/placement.conf
sed -i 's\#auth_uri = <None>\auth_url = http://controller:5000/v3\' /etc/placement/placement.conf
sed -i 's\#memcached_servers = <None>\memcached_servers = controller:11211\' /etc/placement/placement.conf
sed -i 's\#auth_type = <None>\auth_type = password\' /etc/placement/placement.conf
sed -i '241a\project_domain_name = Default\' /etc/placement/placement.conf
sed -i '242a\user_domain_name = Default\' /etc/placement/placement.conf
sed -i '243a\project_name = service\' /etc/placement/placement.conf
sed -i '244a\username = placement\' /etc/placement/placement.conf
sed -i '245a\password = placement\' /etc/placement/placement.conf							//需要設置自己的密碼


#同步數據庫
su -s /bin/sh -c "placement-manage db sync" placement

#BUG修復
在此配置文件/etc/httpd/conf.d/00-placement-api.conf的最后添加如下:

<Directory /usr/bin>
   <IfVersion >= 2.4>
      Require all granted
   </IfVersion>
   <IfVersion < 2.4>
      Order allow,deny
      Allow from all
   </IfVersion>
</Directory>


#重啟httpd
systemctl restart httpd

官網的BUG修復:

        若不添加此修復,在compute部署nova時會有以下報錯:

#####controller#####
#驗證操作
placement-status upgrade check						//狀態檢查

#####controller#####(可選)
#針對api的驗證
pip install osc-placement
openstack --os-placement-api-version 1.2 resource class list --sort-column name
openstack --os-placement-api-version 1.6 trait list --sort-column name

4、nova部署

#####controller節點#####
#刷變量
source admin-openrc.sh
#創建數據庫並配權限
mysql -u root -p000000
CREATE DATABASE nova_api;
CREATE DATABASE nova;
CREATE DATABASE nova_cell0;
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';

GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';

GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';

#創建nova用戶
openstack user create --domain default --password nova nova							//密碼nova

#添加管理員角色給nova
openstack role add --project service --user nova admin

#創建compute服務
openstack service create --name nova  --description "OpenStack Compute" compute

#創建endpoint
openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1
openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1
openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1

##安裝和配置服務
#安裝nova服務
yum install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler -y
//openstack-nova-conductor:提供數據庫連接
//openstack-nova-novncproxy:訪問雲主機的vnc
//openstack-nova-scheduler:提供調度服務

#配置服務
openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata
openstack-config --set /etc/nova/nova.conf api_database connection mysql+pymysql://nova:NOVA_DBPASS@controller/nova_api
openstack-config --set /etc/nova/nova.conf database connection mysql+pymysql://nova:NOVA_DBPASS@controller/nova
openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:000000@controller:5672/		
!!這里需要修改自己rabbitmq的openstack密碼

openstack-config --set /etc/nova/nova.conf api auth_strategy keystone
openstack-config --set /etc/nova/nova.conf keystone_authtoken www_authenticate_uri http://controller:5000/
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://controller:5000/
openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service
openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova
openstack-config --set /etc/nova/nova.conf keystone_authtoken password nova
!!這里修改自己keystone認證的nova密碼。

openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 192.168.100.10
!!這里填自己的管理IP地址

openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron true
openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver

openstack-config --set /etc/nova/nova.conf vnc enabled true
openstack-config --set /etc/nova/nova.conf vnc server_listen 192.168.100.10
openstack-config --set /etc/nova/nova.conf vnc server_proxyclient_address 192.168.100.10
!!填自己的IP

openstack-config --set /etc/nova/nova.conf glance api_servers http://controller:9292
openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp

openstack-config --set /etc/nova/nova.conf placement region_name RegionOne
openstack-config --set /etc/nova/nova.conf placement project_domain_name Default
openstack-config --set /etc/nova/nova.conf placement project_name service
openstack-config --set /etc/nova/nova.conf placement auth_type password
openstack-config --set /etc/nova/nova.conf placement user_domain_name Default
openstack-config --set /etc/nova/nova.conf placement auth_url http://controller:5000/v3
openstack-config --set /etc/nova/nova.conf placement username placement
openstack-config --set /etc/nova/nova.conf placement password placement
!!這里換成自己keystone中placement的密碼

#同步nova-api的數據庫
su -s /bin/sh -c "nova-manage api_db sync" nova

#注冊cell0數據庫:
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova

#創建cell1單元格:
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova

#同步nova數據庫
su -s /bin/sh -c "nova-manage db sync" nova

#驗證nova cell0和cell1已正確注冊
su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova

#開啟服務完成安裝
systemctl enable openstack-nova-api.service openstack-nova-scheduler.service \
    openstack-nova-conductor.service openstack-nova-novncproxy.service
systemctl restart openstack-nova-api.service openstack-nova-scheduler.service \
    openstack-nova-conductor.service openstack-nova-novncproxy.service

 

#####compute節點#####
#安裝服務
yum install openstack-nova-compute -y

#編輯配置文件
openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata
openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:000000@controller
openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 192.168.100.20	
												!!填自己計算節點的管理IP
openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron true
openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver

openstack-config --set /etc/nova/nova.conf api auth_strategy keystone
openstack-config --set /etc/nova/nova.conf keystone_authtoken www_authenticate_uri http://controller:5000/
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://controller:5000/
openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service
openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova
openstack-config --set /etc/nova/nova.conf keystone_authtoken password nova

openstack-config --set /etc/nova/nova.conf vnc enabled true
openstack-config --set /etc/nova/nova.conf vnc server_listen 0.0.0.0
openstack-config --set /etc/nova/nova.conf vnc server_proxyclient_address 192.168.100.20
openstack-config --set /etc/nova/nova.conf novncproxy_base_url http://controller:6080/vnc_auto.html

openstack-config --set /etc/nova/nova.conf glance api_servers http://controller:9292

openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp

openstack-config --set /etc/nova/nova.conf placement region_name RegionOne
openstack-config --set /etc/nova/nova.conf placement project_domain_name Default
openstack-config --set /etc/nova/nova.conf placement project_name service
openstack-config --set /etc/nova/nova.conf placement auth_type password
openstack-config --set /etc/nova/nova.conf placement user_domain_name Default
openstack-config --set /etc/nova/nova.conf placement auth_url http://controller:5000/v3
openstack-config --set /etc/nova/nova.conf placement password placement
openstack-config --set /etc/nova/nova.conf placement username placement

#使用以下命令確定計算節點是否支持虛擬機的硬件加速:
egrep -c '(vmx|svm)' /proc/cpuinfo
(如果此命令返回1或更大的值,則計算節點支持硬件加速,通常不需要額外配置)
(如果此命令返回的值為0,則計算節點不支持硬件加速,必須將libvirt配置為使用QEMU而不是KVM。)
#(可選)將libvirt配置為QEMU
openstack-config --set /etc/nova/nova.conf libvirt virt_type qemu


#啟動計算服務(包括其依賴項),並將其配置為在系統引導時自動啟動
systemctl enable libvirtd.service openstack-nova-compute.service
systemctl start libvirtd.service openstack-nova-compute.service


#####controller#####
#驗證
openstack compute service list --service nova-compute

#####controller#####
#主機發現
每添加主機就需要執行主機發現:
命令:
su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
或者配置自動發現:
openstack-config --set /etc/nova/nova.conf scheduler discover_hosts_in_cells_interval 300

 

5、neutron部署

#####controller#####
#建庫授權
mysql -u root -p000000
CREATE DATABASE neutron;
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'NEUTRON_DBPASS';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'NEUTRON_DBPASS';

source admin-openrc.sh
#創建服務憑據:
openstack user create --domain default --password neutron neutron
openstack role add --project service --user neutron admin
openstack service create --name neutron --description "OpenStack Networking" network

#創建API endpoint
openstack endpoint create --region RegionOne network public http://controller:9696
openstack endpoint create --region RegionOne network internal http://controller:9696
openstack endpoint create --region RegionOne network admin http://controller:9696

        neutron服務有兩種網絡:

        網絡選項1:提供商網絡

        網絡選項2:自助服務網絡

     選項1部署了最簡單的架構,只支持將實例連接到提供程序(外部)網絡。沒有自助(專用)網絡、路由器或浮動IP地址。只有管理員或其他特權用戶才能管理提供商網絡。

     選項2使用支持將實例連接到自助服務網絡的第3層服務來增強選項1。演示或其他非特權用戶可以管理自助服務網絡,包括在自助服務網絡和提供商網絡之間提供連接的路由器。此外,浮動IP地址使用來自外部網絡(如Internet)的自助服務網絡提供到實例的連接。

     自助服務網絡通常使用覆蓋網絡。覆蓋網絡協議(如VXLAN)包括額外的報頭,這些報頭會增加開銷並減少有效負載或用戶數據的可用空間。在不了解虛擬網絡基礎設施的情況下,實例嘗試使用1500字節的默認以太網最大傳輸單元(MTU)發送數據包。網絡服務通過DHCP自動向實例提供正確的MTU值。但是,有些雲映像不使用DHCP或忽略DHCP MTU選項,需要使用元數據或腳本進行配置。

 

本篇選擇選項2自服務網絡(需要部署提供者網絡的可點擊上面鏈接查看官方文檔)

Networking Option 2: Self-service networks
#####controller#####
##安裝服務
yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables -y

##配置服務
#在[database]部分,配置數據庫訪問:
openstack-config --set /etc/neutron/neutron.conf database connection mysql+pymysql://neutron:NEUTRON_DBPASS@controller/neutron

#在[DEFAULT]部分,啟用模塊化第2層(ML2)插件、路由器服務和重疊IP地址:
openstack-config --set /etc/neutron/neutron.conf DEFAULT core_plugin ml2
openstack-config --set /etc/neutron/neutron.conf DEFAULT service_plugins router
openstack-config --set /etc/neutron/neutron.conf DEFAULT allow_overlapping_ips true

#在[DEFAULT]部分中,配置Rabbit MQ消息隊列訪問:
openstack-config --set /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:000000@controller
!!此項000000密碼改為自己rabbitmq的密碼

#在[DEFAULT]和[keystone_authtoken]部分中,配置身份服務訪問:
openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken www_authenticate_uri http://controller:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://controller:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password neutron
!!此項密碼改為自己keystone的neutron密碼


#在[DEFAULT]和[nova]部分中,配置網絡以通知Compute網絡拓撲更改:
openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_status_changes true
openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_data_changes true
openstack-config --set /etc/neutron/neutron.conf nova auth_url http://controller:5000
openstack-config --set /etc/neutron/neutron.conf nova auth_type password
openstack-config --set /etc/neutron/neutron.conf nova project_domain_name default
openstack-config --set /etc/neutron/neutron.conf nova user_domain_name default
openstack-config --set /etc/neutron/neutron.conf nova region_name RegionOne
openstack-config --set /etc/neutron/neutron.conf nova project_name service
openstack-config --set /etc/neutron/neutron.conf nova username nova
openstack-config --set /etc/neutron/neutron.conf nova password nova
!!替換自己keyston中的nova的密碼

#在[oslo_concurrency]部分,配置lock_path:
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp


##配置模塊化第2層(ML2)插件
#在[ml2]部分中,啟用flat、VLAN和VXLAN網絡:
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vlan,vxlan

#在[ml2]部分中,啟用VXLAN自助服務網絡:
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan

#在[ml2]部分中,啟用Linux網橋和第2層填充機制:
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers linuxbridge,l2population

#在[ml2]部分中,啟用端口安全擴展驅動程序:
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security

#在[ml2_type_flat]部分中,將提供商虛擬網絡配置為平面網絡:
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks provider

#在[ml2_type_vxlan]部分,為自助服務網絡配置vxlan網絡標識符范圍:
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vxlan vni_ranges 1:1000 

#在[securitygroup]部分,啟用ipset以提高安全組規則的效率:
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup enable_ipset true

##配置Linux網橋代理
#在[linux_bridge]部分,將提供商虛擬網絡映射到提供商物理網絡接口:
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:ens33
!!將最后的網卡名換成自己的提供商物理網絡接口名

#在[vxlan]部分,啟用vxlan覆蓋網絡,配置處理覆蓋網絡的物理網絡接口的IP地址,並啟用第2層填充:
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip 192.168.100.10
!!將IP地址換成管理網絡的接口IP地址



#在[securitygroup]部分,啟用安全組並配置Linux橋iptables防火牆驅動程序:
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

#
#驗證網絡網橋是否支持,若不支持則加載br_netfilter內核模塊。
使用如下命令驗證,如返回結果為1則支持,否則需要加載br_netfilter內核模塊
sysctl net.bridge.bridge-nf-call-iptables
sysctl net.bridge.bridge-nf-call-ip6tables


#加載br_netfilter內核模塊
modprobe br_netfilter

touch cat /etc/rc.sysinit
cat > /etc/rc.sysinit <<EOF
#!/bin/bash
for file in /etc/sysconfig/modules/*.modules ; do
[ -x $file ] && $file
done
EOF

touch /etc/sysconfig/modules/br_netfilter.modules
cat > /etc/sysconfig/modules/br_netfilter.modules <<EOF
modprobe br_netfilter
EOF

chmod 755 /etc/sysconfig/modules/br_netfilter.modules

sed -i '$a\net.bridge.bridge-nf-call-iptables=1\' /etc/sysctl.conf
sed -i '$a\net.bridge.bridge-nf-call-ip6tables=1\' /etc/sysctl.conf
sysctl -p


##配置第3層代理»
編輯/etc/中子/l3_agent.ini文件並完成以下操作:
#在[DEFAULT]部分,配置Linux網橋接口驅動程序:
openstack-config --set /etc/neutron/l3_agent.ini DEFAULT interface_driver linuxbridge

##配置DHCP代理»
編輯/etc/neutron/dhcp_agent.ini文件並完成以下操作:
#在[DEFAULT]部分,配置Linux網橋接口驅動程序、Dnsmasq DHCP驅動程序,並啟用隔離元數據,以便提供商網絡上的實例可以通過網絡訪問元數據:
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT interface_driver linuxbridge
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT dhcp_driver neutron.agent.linux.dhcp.Dnsmasq
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT enable_isolated_metadata true

 

#####controller#####

###配置元數據代理
##編輯/etc/neutron/metadata_agent.ini 文件並完成以下操作:
#在[DEFAULT]部分,配置元數據主機和共享密鑰
openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT nova_metadata_host controller
openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT metadata_proxy_shared_secret METADATA_SECRET

###將計算服務配置為使用網絡服務
##編輯/etc/nova/nova.conf文件並執行以下操作:
#在[neutron]部分,配置訪問參數,啟用元數據代理,並配置密碼:
openstack-config --set /etc/nova/nova.conf neutron auth_url http://controller:5000
openstack-config --set /etc/nova/nova.conf neutron auth_type password
openstack-config --set /etc/nova/nova.conf neutron project_domain_name default
openstack-config --set /etc/nova/nova.conf neutron user_domain_name default
openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne
openstack-config --set /etc/nova/nova.conf neutron project_name service
openstack-config --set /etc/nova/nova.conf neutron username neutron
openstack-config --set /etc/nova/nova.conf neutron password neutron
openstack-config --set /etc/nova/nova.conf neutron service_metadata_proxy true
openstack-config --set /etc/nova/nova.conf neutron metadata_proxy_shared_secret METADATA_SECRET
!!此處的metadata密碼是上一步設置的默認的

###完成安裝
#配置軟連接
ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini


#同步數據庫
su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \
  --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
  
#重啟
systemctl restart openstack-nova-api.service

systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service
systemctl start neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service

systemctl enable neutron-l3-agent.service
systemctl start neutron-l3-agent.service

 目前沒有報錯

     配置計算節點的neutron服務

#####compute節點#####
##安裝組件
yum install openstack-neutron-linuxbridge ebtables ipset -y
##編輯配置文件 /etc/neutron/neutron.conf
#在[database]部分,注釋掉所有連接選項,因為計算節點不直接訪問數據庫。
#在[DEFAULT]部分中,配置Rabbit MQ消息隊列訪問
openstack-config --set /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:000000@controller
!!注意此處密碼,替換成自己所設密碼

#在[DEFAULT]和[keystone_authtoken]部分中,配置身份服務訪問:
openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken www_authenticate_uri http://controller:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://controller:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password neutron

# 在[oslo_concurrency]部分,配置lock_path
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp

 

     接下來配置compute節點的自服務網絡,若需要配置提供者網絡,可參考以下鏈接:

#####compute#####
###配置自服務網絡
##配置Linux網橋代理
/etc/neutron/plugins/ml2/linuxbridge_agent.ini
#在[linux_bridge]部分,將提供商虛擬網絡映射到提供商物理網絡接口 
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:ens33


#在[vxlan]部分,啟用vxlan覆蓋網絡,配置處理覆蓋網絡的物理網絡接口的IP地址,並啟用第2層填充:
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip 192.168.100.20
!!計算節點的管理IP地址。


#在[securitygroup]部分,啟用安全組並配置Linux橋iptables防火牆驅動程序:
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver



#通過驗證以下所有sysctl值均設置為1,確保Linux操作系統內核支持網橋篩選器:
sysctl net.bridge.bridge-nf-call-iptables
sysctl net.bridge.bridge-nf-call-ip6tables

 將計算服務配置為使用網絡服務»

#####compute#####
##編輯/etc/nova/nova.conf文件並完成以下操作:
#在[neutron]部分,配置訪問參數:
openstack-config --set /etc/nova/nova.conf neutron auth_url http://controller:5000
openstack-config --set /etc/nova/nova.conf neutron auth_type password
openstack-config --set /etc/nova/nova.conf neutron project_domain_name default
openstack-config --set /etc/nova/nova.conf neutron user_domain_name default
openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne
openstack-config --set /etc/nova/nova.conf neutron project_name service
openstack-config --set /etc/nova/nova.conf neutron username neutron
openstack-config --set /etc/nova/nova.conf neutron password neutron

 完成安裝

#####compute#####
##完成安裝
#重新啟動計算服務:
systemctl restart openstack-nova-compute.service

#啟動Linux網橋代理,並將其配置為在系統引導時啟動:
systemctl enable neutron-linuxbridge-agent.service
systemctl restart neutron-linuxbridge-agent.service

 沒有報錯-

#####controller#####
驗證操作
openstack network agent list

6、horizon

        為openstack集群部署dashboard

#####controller#####
###安裝和配置組件
yum install openstack-dashboard -y

##編輯配置文件/etc/openstack-dashboard/local_settings:
#配置在controller上:
sed -i 's\OPENSTACK_HOST = "127.0.0.1"\OPENSTACK_HOST = "controller"\' /etc/openstack-dashboard/local_settings

#允許所有主機訪問dashboard
sed -i 's/ALLOWED_HOSTS = [\'horizon.example.com\', \'localhost\']/ALLOWED_HOSTS = [\'*\']/' /etc/openstack-dashboard/local_settings

#配置memcached會話存儲服務,在配置文件中添加如下內容:
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'

CACHES = {
    'default': {
         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
         'LOCATION': 'controller:11211',
    }
}
#啟用標識API版本3:
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST

#啟用對域的支持:
sed -i '$a\OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True\' /etc/openstack-dashboard/local_settings

#配置API版本,在文件末尾添加如下:
OPENSTACK_API_VERSIONS = {
    "identity": 3,
    "image": 2,
    "volume": 3,
}

#將Default配置為通過儀表板創建的用戶的默認域:
sed -i '$a\OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "Default"\' /etc/openstack-dashboard/local_settings

#將用戶配置為通過儀表板創建的用戶的默認角色:
sed -i '$a\OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"\' /etc/openstack-dashboard/local_settings

#(可選)配置時區:
sed -i 's\TIME_ZONE = "UTC"\TIME_ZONE = "Asia/Shanghai"\ /etc/openstack-dashboard/local_settings

#如果未包括,請將以下配置添加到/etc/httpd/conf.d/openstack-dashboard.conf

sed -i '$a\WSGIApplicationGroup %{GLOBAL}\' /etc/httpd/conf.d/openstack-dashboard.conf

###重啟服務
systemctl restart httpd.service memcached.service


免責聲明!

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



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