webdriver 核心方法和屬性使用
一、系統的安裝及設定
1.1 系統安裝
1、製作主機模板template,後續用到的主機均以此主機為模板進行克隆
系統安裝要求
在vmware workstation 中安裝,需要勾選對應虛擬化選項
-
刪除不用硬體裝置,例如印表機、音效卡。vxlan 和ceph 叢集網絡卡可以安裝完系統初始化後時再新增
-
作業系統映象:CentOS-7-x86_64-DVD-2009.iso
-
時區修改為:Asia/Shanghai
-
語言勾選支援:中文
-
軟體包選擇:Development and Create Workstation
-
Addiional Development
-
Compatibility Libraries
-
Development Tools
-
Hardware Monitoring Utilities
-
Large Systems Performance
-
Platform Development
-
System Administration Tools
分割槽如圖所示
1.2 系統初始化引數設定
1、設定主機名及hosts
hostnamectl set-hostname template cat >>/etc/hosts <<'EOF' # openstack 192.168.10.20 controller 192.168.10.31 compute01 192.168.10.32 compute02 # cpeh-public 192.168.10.11 ceph01 192.168.10.12 ceph02 192.168.10.13 ceph03 # ceph-cluster 172.16.10.11 ceph01-cluster 172.16.10.12 ceph02-cluster 172.16.10.13 ceph03-cluster EOF
2、配置IP 地址並且關閉NetworkMnanager
各主機第一塊網絡卡按規劃用作Provider IP (使用NAT 網路,可出外網)
cat > /etc/sysconfig/network-scripts/ifcfg-ens32 <<'EOF' TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes IPV6INIT=no NAME=ens32 DEVICE=ens32 ONBOOT=yes # ip 地址,不同主機修改成不同IP IPADDR=192.168.10.200 NETMASK=255.255.255.0 GATEWAY=192.168.10.254 DNS1=223.5.5.5 EOF
3、修改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 https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
5、關閉防火牆和selinux
systemctl restart network
systemctl stop NetworkManager && systemctl disable NetworkManager
systemctl stop firewalld && systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
5、設定核心引數及檔案控制代碼等資源限制引數
cat >> /etc/sysctl.conf <<EOF
## default 1
net.ipv4.tcp_syncookies = 1
## default 0
net.ipv4.tcp_tw_reuse = 1
## default 0
net.ipv4.tcp_tw_recycle = 1
## default 60
net.ipv4.tcp_fin_timeout = 30
## default 256
net.ipv4.tcp_max_syn_backlog = 4096
## default 32768 60999
net.ipv4.ip_local_port_range = 1024 65535
## default 129=8
net.core.somaxconn = 32768
EOF
cat >> /etc/security/limits.conf <<EOF
* hard nofile 655360
* soft nofile 655360
* hard nproc 655360
* soft nproc 655360
* soft core 655360
* hard core 655360
EOF
sed -i 's/4096/unlimited/g' /etc/security/limits.d/20-nproc.conf
6、設定CPU 巢狀虛擬化,讓虛擬機器中再支援虛擬化
cat /sys/module/kvm_amd/parameters/nested #amd的cpu
cat /sys/module/kvm_intel/parameters/nested #intel的cpu
cat > /etc/modprobe.d/kvm-nested.conf <<EOF
options kvm_amd nested=1 ept=0 unrestricted_guest=0
EOF
rmmod kvm_amd
modprobe kvm_amd ept=0 unrestricted_guest=0
cat /sys/module/kvm_amd/parameters/nested
7、安裝OpenStack 客戶端
yum -y install python-openstackclient
1.3 克隆第1 臺虛擬機器
克隆虛擬機器操作步驟如下圖所示
右鍵點選模板主機,選擇“管理”-->“克隆”
1.4 完成克隆後,啟動克隆好的虛擬機器,修改hostname、IP
以controller 主機為例
hostnamectl set-hostname controller
sed -i 's/10.200/10.20/g' /etc/sysconfig/network-scripts/ifcfg-ens32
systemctl restart network
ping 192.168.10.254
1.5新增網絡卡和硬碟
按照規劃,為compute01、compute02 新增硬碟,controller、compute01、compute02 各增加2 塊網絡卡,此處以controller 截圖為例
編輯controller 虛擬機器,新增網路介面卡
新增Lan 區段,即自定義網段(類似hub 或網橋),也可以通過新增網路,vmware 全域性支援新增20 個虛擬網路(VMNet0-VMNet19)。
按上述操作完成compute01 和compute02 的2 塊網絡卡新增。
compute01、compute02 各增加一塊200G 硬碟(用作cinder 儲存)。此處僅以compute01 截圖為例
檢查並完成上述操作後,啟動controller、compute01、compute02,開始進入openstack 部署環節
二、openstack初始化環境安裝
1、網絡卡IP 配置。
配置controller、compute01、compute02 上的第2、3 塊網絡卡IP
在所有節點上分別執行dhclient
命令後使用ip a
檢視網絡卡名稱
配置ens33和ens34網絡卡IP,以controller為例:
cat > /etc/sysconfig/network-scripts/ifcfg-ens33 <<EOF
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV6INIT=no
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=10.10.10.20
NETMASK=255.255.255.0
EOF
cat > /etc/sysconfig/network-scripts/ifcfg-ens34 <<EOF
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
IPV6INIT=no
NAME=ens34
DEVICE=ens34
ONBOOT=yes
IPADDR=172.16.10.20
NETMASK=255.255.255.0
EOF
重啟網路
systemctl restart network
2、NTP 安裝及配置
1、統一時區,在所有節點(controller、compute01、compute02)上執行
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
注:安裝時若有選擇正確時區,可忽略上述設定
2、在控制節點controller 安裝chrony,將控制節點作為NTP 服務端,預設已經安裝。
yum -y install chrony
修改配置/etc/chrony.conf
指定時間同步伺服器,這裡採用阿里雲時鐘源。如果無外網,則指向本機主機名
sed -i 's/0.centos.pool.ntp.org/ntp1.aliyun.com/g' /etc/chrony.conf
sed -i '4,6d' /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 restart chronyd && systemctl enable chronyd.service
3、在計算節點computer01 安裝chrony,將控制節點作為NTP 服務端,預設已經安裝。
yum -y install chrony
compute和其他節點也安裝伺服器,刪除已有的無用server,配置伺服器為controller節點
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源
yum install centos-release-openstack-train -y
yum install python-openstackclient openstack-utils openstack-selinux -y
4、MariaDB 安裝及配置
1、安裝與配置資料庫
在控制節點(controller)執行以下操作。
yum -y install mariadb mariadb-server python2-PyMySQL
2、配置資料庫
cat > /etc/my.cnf.d/openstack.cnf << EOF
[mysqld]
bind-address = 0.0.0.0
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 8192
collation-server = utf8_general_ci
character-set-server = utf8
EOF
4、修改“/usr/lib/systemd/system/mariadb.service”檔案,在檔案[Service]下新增如下內容:
sed -i '33a\LimitNOFILE=65535\' /usr/lib/systemd/system/mariadb.service
sed -i '34a\LimitNPROC=65535\' /usr/lib/systemd/system/mariadb.service
5、設定開機自啟動
systemctl daemon-reload
systemctl enable mariadb.service
systemctl start mariadb.service
6、資料庫初始化設定(可選設定)。
#初始化資料庫,並設定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、RabbitMQ 安裝及配置
1、安裝與配置rabbitMQ
在控制節點(controller)執行以下操作
yum -y install rabbitmq-server
2、配置rabbitmq,修改rabbitmq 預設開啟檔案控制代碼數限制
sed -i '12a\LimitNOFILE=32768\' /usr/lib/systemd/system/rabbitmq-server.service
3、設定開機自啟動
systemctl daemon-reload
systemctl enable rabbitmq-server.service && systemctl start rabbitmq-server.service
4、在rabbitMQ 中新增用於openstack 的使用者並授予管理員許可權。
rabbitmqctl add_user openstack openstack
rabbitmqctl set_user_tags openstack administrator
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
也可在web 控制檯完成使用者新增
注:為openstack 使用者設定的密碼,密碼不要包含字元"#"
5、啟用rabbitmq-manager 外掛,開啟Web 控制檯
rabbitmq-plugins enable rabbitmq_management
6、登入驗證
控制檯登入:http://controller:15672
guest/guest (預設賬戶)
openstack/openstack
6、Memcache 安裝及配置
1、安裝與配置memcached
在控制節點(controller)執行以下操作
yum -y install memcached python-memcached
2、修改配置
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="256"\' /etc/sysconfig/memcached
sed -i 's\MAXCONN="1024"\MAXCONN="4096"\' /etc/sysconfig/memcached
注意監聽IP 地址,也可以設定成192.168.10.20
3、設定服務開機自啟
systemctl enable memcached.service
systemctl restart memcached.service
4、驗證
~]# systemctl status memcached
● memcached.service - memcached daemon
Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2021-12-28 15:59:20 CST; 26s ago
Main PID: 7451 (memcached)
Tasks: 10
CGroup: /system.slice/memcached.service
└─7451 /usr/bin/memcached -p 11211 -u memcached -m 64 -c 4096 -l 0.0.0.0,::1
Dec 28 15:59:20 controller systemd[1]: Started memcached daemon.
~]# netstat -atnp |grep 11211
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 7451/memcached
tcp6 0 0 ::1:11211 :::* LISTEN 7451/memcached
7、etcd 安裝及配置(可選安裝)
1、安裝與etcd
在控制節點(controller)執行以下操作
yum -y install etcd
2、配置etcd
sed -i 's\#ETCD_LISTEN_PEER_URLS="http://localhost:2380"\ETCD_LISTEN_PEER_URLS="http://192.168.10.20:2380"\' /etc/etcd/etcd.conf
sed -i 's\ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"\ETCD_LISTEN_CLIENT_URLS="http://192.168.10.20: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.10.20:2380"\' /etc/etcd/etcd.conf
sed -i 's\ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"\ETCD_ADVERTISE_CLIENT_URLS="http://192.168.10.20:2379"\' /etc/etcd/etcd.conf
sed -i 's\#ETCD_INITIAL_CLUSTER="default=http://localhost:2380"\ETCD_INITIAL_CLUSTER="controller=http://192.168.10.20: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
3、設定服務開機自啟
systemctl enable etcd
systemctl start etcd
8、安裝openstack 客戶端
1、確保所有節點上已經安裝了OpenStack 客戶端
yum -y install python-openstackclient
在模板主上就已經安裝,此處忽略該安裝步驟。
三、openstack 業務元件安裝
1、安裝keystone(控制節點)
keystone 是OpenStack 的身份認證服務(Identity Service),OpenStack 中的認證、鑑權、角色管理都是由keystone 來完成,同時還提供服務目錄註冊功
能。keystone 是一個關鍵服務,同時也是安裝Openstack 時第一個要安裝的服務。
配置keystone 時,需要為使用者建立合適的角色、服務、租戶、使用者賬號和服務API 端點。
keystone 裡有相關概念需要了解。比如,租戶、角色、使用者。
- 租戶對應專案,它有一些資源,包括使用者、映象、例項,還有僅對該專案可見的網路(如果建立網路時沒有勾選“共享”)
- 一個使用者可隸屬於一個或多個專案(租戶),並且可以在這些專案間進行切換,部署Openstack 至少要建立admin 和service 二個專案。
- service 專案是一個特殊的專案,Openstack 自身服務都配置在service 專案中,這樣做的目的是提高安全性。
- 一個使用者可以被指定成多種角色,即一個使用者可能會有多個專案,在不同專案中角色不同。例如,user1 同時在project1 和project2 中,在project1
的角色是admin,在project2 的角色是user。 - openstack 中預設只有4 種角色,包括admin(管理雲環境)、member(雲環境普通使用者角色)、reader、user
OpenStack keystone 服務託管在httpd 上,修改配置後需要重啟httpd
1、登入資料庫建立keystone 資料庫
~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE keystone default character set utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'openstack';
2、安裝Keystone 軟體包並修改配置檔案
yum -y install openstack-keystone httpd mod_wsgi
3、修改配置檔案
sed -i 's\#connection = <None>\connection = mysql+pymysql://keystone:openstack@controller/keystone\' /etc/keystone/keystone.conf
sed -i '2475a\provider = fernet\' /etc/keystone/keystone.conf
sed -i '2476a\expiration = 86400\' /etc/keystone/keystone.conf
4、同步Identity 服務的初始資料到keystone 庫
su -s /bin/sh -c "keystone-manage db_sync" keystone
5、初始化Fernet 金鑰儲存庫
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
6、執行身份引導服務(會建立endpoint)
keystone-manage bootstrap --bootstrap-password openstack \
--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
2、配置Apache 服務(控制節點controller)
1、修改apache 配置檔案
sed -i '/#ServerName www.example.com:80/a\ServerName controller:80\' /etc/httpd/conf/httpd.conf
2、建立軟連結
ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
3、啟動Apache HTTP 服務並配置其隨系統啟動
systemctl enable httpd.service
systemctl restart httpd.service
4、配置管理員帳戶,並建立專案、域、使用者、角色
cat > /etc/keystone/admin-openrc.sh <<EOF
#!/bin/bash
export OS_USERNAME=admin
export OS_PASSWORD=openstack
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
export OS_IMAGE_API_VERSION=2
EOF
source /etc/keystone/admin-openrc.sh
5、建立service 專案、user 角色、域,default 域預設已經存在
~]# openstack domain list
+---------+---------+---------+--------------------+
| ID | Name | Enabled | Description |
+---------+---------+---------+--------------------+
| default | Default | True | The default domain |
+---------+---------+---------+--------------------+
openstack domain create --description "An Example Domain" example
openstack domain list
openstack project create --domain default --description "Demo Project" myproject
openstack user create --domain default --password-prompt myuser
openstack role create myrole
openstack role add --project myproject --user myuser myrole
openstack role list
一個租戶在OpenStack 裡就是一個專案,建立使用者時必須先要有租戶(專案),同時還需要一個能分配給該使用者的角色,這樣建立的使用者才有意義。
建立service 專案(租戶),service 專案將作為OpenStack 的系統專案,所有系統服務都要加入到service 專案中。
~]# openstack project create --domain default --description "Service Project" service
~]# openstack project list
+----------------------------------+---------+
| ID | Name |
+----------------------------------+---------+
| 856a6d41ac044e889118cd96706b8847 | admin |
| c60e5165c7ed4f17b171a6d3f2187505 | service |
+----------------------------------+---------+
建立user 角色
~]# openstack role create user
~]# openstack role list
+----------------------------------+--------+
| ID | Name |
+----------------------------------+--------+
| 569e6552f6044d21bd333af3f041da54 | reader |
| a75928a0f41849819c3f6c58da497c3c | member |
| baa06ee9bb124c50b692f7169be2594f | admin |
| d1d6bed4c52146468736255155a50b6a | user |
+----------------------------------+--------+
6、驗證Keystone
source /etc/keystone/admin-openrc.sh
openstack token issue
取消環境變數,驗證
unset OS_AUTH_URL OS_PASSWORD
使用admin 使用者,請求身份驗證令牌。
openstack --os-auth-url http://controller:5000/v3 \
--os-project-domain-name Default \
--os-user-domain-name Default \
--os-project-name admin \
--os-username admin token issue
輸入admin 的密碼:openstack
3、安裝placement(控制節點)
Placement 在Openstack 中主要用於跟蹤和監控各種資源的使用情況,例如,在Openstack 中包括計算資源、儲存資源、網路等各種資源。Placement
用來跟蹤管理每種資源的當前使用情況。
Placement 服務在Openstack 14.0.0 Newton 版本中被引入到nova 庫,並在19.0.0 Stein 版本中被獨立到Placement 庫中,即在stein 版被獨立成元件。
Placement 服務提供REST API 堆疊和資料模型,用於跟蹤資源提供者不同型別的資源的庫存和使用情況。資源提供者可以是計算資源、共享儲存池、
IP 池等。例如,建立一個例項時會消耗計算節點的CPU、記憶體,會消耗儲存節點的儲存;同時還會消耗網路節點的IP 等等,所消耗資源的型別被跟蹤為
類。Placement 提供了一組標準資源類(例如DISK_GB、MEMORY_MB 和VCPU),並提供了根據需要定義自定義資源類的能力。
placement 服務託管在httpd 上,修改配置需重啟httpd。
1、登入資料庫建立placement 資料庫
~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE placement default character set utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'openstack';
2、建立使用者和API 服務端點
source /etc/keystone/admin-openrc.sh
openstack user create --domain default --password openstack placement
將placement 加入到service 專案以及admin 角色
openstack role add --project service --user placement admin
建立服務實體
openstack service create --name placement --description "Placement API" placement
建立Placement API 服務端點
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
3、安裝配置Placement
yum -y install openstack-placement-api
注:https://docs.openstack.org/api-ref/placement/?expanded=
修改配置檔案/etc/placement/placement.conf
openstack-config --set /etc/placement/placement.conf placement_database connection mysql+pymysql://placement:openstack@controller/placement
openstack-config --set /etc/placement/placement.conf api auth_strategy keystone
openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_url http://controller:5000/v3
openstack-config --set /etc/placement/placement.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_type password
openstack-config --set /etc/placement/placement.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/placement/placement.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/placement/placement.conf keystone_authtoken project_name service
openstack-config --set /etc/placement/placement.conf keystone_authtoken username placement
openstack-config --set /etc/placement/placement.conf keystone_authtoken password openstack
修改配置檔案/etc/httpd/conf.d/00-placement-api.conf
cat >>/etc/httpd/conf.d/00-placement-api.conf <<EOF
<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>
EOF
4、同步placement 資料庫
su -s /bin/sh -c "placement-manage db sync" placement
注:忽略同步資料時報的Warning
5、重啟httpd 服務並驗證Placement
systemctl restart httpd
執行placement-status 命令檢查狀態
~]# placement-status upgrade check
+----------------------------------+
| Upgrade Check Results |
+----------------------------------+
| Check: Missing Root Provider IDs |
| Result: Success |
| Details: None |
+----------------------------------+
| Check: Incomplete Consumers |
| Result: Success |
| Details: None |
+----------------------------------+
安裝pip(如果無外網則跳過該設定,使用離線安裝)
yum install -y epel-release
yum install -y python-pip
rm -rf /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo
配置國內pip 源
cat > /etc/pip.conf <<EOF
[global]
index-url = https://pypi.douban.com/simple/
[install]
trusted-host = https://pypi.douban.com
EOF
安裝osc-placement 外掛
pip install osc-placement==2.2.0
離線安裝
在yum01 主機上通過pip download osc-placement==2.2.0 下載離線包放入/var/www/html/yumrepos/pip 目錄下
yum install -y python-pip
wget http://yum01/yumrepos/pip/osc-placement-2.2.0.tar.gz
pip install osc-placement-2.2.0.tar.gz
列出可用的資源類和特徵。
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、安裝配置並驗證Glance(控制節點)
OpenStack 映象服務就是Glance,可以讓使用者上傳、匯出、修改、刪除虛擬機器映象。另外,openstack 映象服務支援將映象檔案儲存在各種型別的儲存
中,如本地檔案系統、Openstack 物件儲存服務swift、ceph 等分散式儲存中。
OpenStack 映象服務包括glance-api、glance-registry 兩個子服務。glance-api 對外提供通訊介面,與其他服務互動;glance-registry 用於管理儲存在硬
盤或glance 資料庫中的物件。
修改好配置後,需要重啟openstack-glance-api.service 或openstack-glance-registry.service
1、登入資料庫建立glance 資料庫
~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE glance default character set utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'openstack';
2、建立使用者和API 服務端點
source /etc/keystone/admin-openrc.sh
openstack user create --domain default --password openstack glance
將glance 加入到service 專案以及admin 角色
openstack role add --project service --user glance admin
建立glance 服務實體
openstack service create --name glance --description "OpenStack Image" image
建立Glance API 服務端點
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
3、安裝配置Glance
yum -y install openstack-glance
修改/etc/glance/glance-api.conf
openstack-config --set /etc/glance/glance-api.conf openstack-config --set /etc/glance/glance-api.conf DEFAULT show_image_direct_url True
openstack-config --set /etc/glance/glance-api.conf openstack-config --set /etc/glance/glance-api.conf DEFAULT transport_url rabbit://openstack:openstack@controller
openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:openstack@controller/glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken www_authenticate_uri http://controller:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://controller:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password openstack
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
修改/etc/glance/glance-registry.conf
openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:openstack@controller/glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken www_authenticate_uri http://controller:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://controller:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password openstack
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
4、同步Glance 資料庫
su -s /bin/sh -c "glance-manage db_sync" glance
5、啟動Glance 服務並設定成開機自啟動
systemctl enable openstack-glance-api.service openstack-glance-registry.service && systemctl start openstack-glance-api.service openstack-glance-registry.service
6、驗證Glance 服務
source /etc/keystone/admin-openrc.sh
下載測試映象cirros 上傳到Glance
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
上傳映象到glance
openstack image create "cirros-0.4.0-x86_64" --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --public
上傳的映象分私有映象和公有映象。私有映象只有上傳者才擁有許可權使用;如果要設定成公有映象,則只需要加上--public 引數即可
確認上傳的映象和屬性。
openstack image list
glance image-list
openstack image show ${image_id}
glance image-show ${image_id}
設定映象為公有映象
openstack image set cirros-0.4.0-x86_64 --public
刪除映象
openstack image delete ${image_name}
5、安裝並驗證Nova(計算節點+控制節點)
Nova 是OpenStack 中的計算服務。OpenStack 中虛擬機器例項(instance)生命週期都是由Nova 服務來管理完成,包括例項建立、排程、刪除等。
nova 服務包含一系列元件,其中有nova-api、nova-conductor、nova-scheduler、nova-novncproxy 、nova-compute
nova-scheduler:把nova-api 呼叫請求對映為OpenStack 將要排程哪個伺服器來響應執行例項的請求,會根據諸如CPU 構架、可用域、記憶體、負載等作
出調度決策。
nova-api:對外提供API 介面來管理內部基礎設施,例如啟動停止例項。
nova-conductor:nova-compute 和資料庫之間的一個元件,nova-conductor 建立的初衷是基於安全考慮,避免nova-compute 直接訪問資料庫。
nova-novncproxy:提供控制檯服務,允許終端使用者以vnc 方式訪問例項控制檯,後續如果使用spice-server,需要停止。
nova-compute:用於管理例項生命週期。通過訊息佇列接收請求,並承擔操作工作。
綜合對上面元件的介紹,可以看出Nova 也是一個非常重要的核心元件,且對應子模組非常多,配置也會變得雜。
在控制節點(controller)安裝nova 服務
1、登入資料庫建立nova,nova_api,nova_cell0 資料庫
~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE nova_api default character set utf8;
MariaDB [(none)]> CREATE DATABASE nova default character set utf8;
MariaDB [(none)]> CREATE DATABASE nova_cell0 default character set utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'openstack';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'openstack';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'openstack';
說明:OpenStack Rocky 版本需新增Placement 資料庫,在Stein 版本之後已在單獨的Placement 元件新增,請忽略以下操作。
CREATE DATABASE placement;
GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY 'openstack';
GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'openstack'
2、建立使用者和API 服務端點
source /etc/keystone/admin-openrc.sh
openstack user create --domain default --password openstack nova
將nova 加入到service 專案以及admin 角色
openstack role add --project service --user nova admin
建立nova 服務實體
openstack service create --name nova --description "OpenStack Compute" compute
建立nova API 服務端點。
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
使用命令檢視
openstack endpoint list
說明:OpenStack Rocky 版本需新增placement 使用者,Stein 版本已在單獨的Placement 元件新增,請忽略以下操作(可以使用openstack endpoint list 查
看)。
建立使用者placement 並設定密碼。
openstack user create --domain default --password-prompt placement
新增角色。
openstack role add --project service --user placement admin
建立Placement API 使用者和服務端點。
openstack service create --name placement --description "Placement API" placement
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
3、安裝配置Nova
安裝元件
yum -y install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler
說明:
OpenStack Rocky 版本需在這裡安裝placement,Stein 版本之後已在單獨的placement 元件安裝,請忽略。
yum -y install openstack-nova-placement-api
修改配置檔案/etc/nova/nova.conf
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:openstack@controller
openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 192.168.10.20
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 DEFAULT allow_resize_to_same_host true
openstack-config --set /etc/nova/nova.conf api_database connection mysql+pymysql://nova:openstack@controller/nova_api
openstack-config --set /etc/nova/nova.conf database connection mysql+pymysql://nova:openstack@controller/nova
openstack-config --set /etc/nova/nova.conf api auth_strategy keystone
openstack-config --set /etc/nova/nova.conf api token_cache_time 3600
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://controller:5000/v3
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 openstack
openstack-config --set /etc/nova/nova.conf keystone_authtoken token_cache_time 3600
openstack-config --set /etc/nova/nova.conf vnc enabled true
openstack-config --set /etc/nova/nova.conf vnc server_listen \$my_ip
openstack-config --set /etc/nova/nova.conf vnc server_proxyclient_address \$my_ip
openstack-config --set /etc/nova/nova.conf vnc novncproxy_host 0.0.0.0
openstack-config --set /etc/nova/nova.conf vnc novncproxy_port 6080
openstack-config --set /etc/nova/nova.conf vnc 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 username placement
openstack-config --set /etc/nova/nova.conf placement password openstack
openstack-config --set /etc/nova/nova.conf scheduler discover_hosts_in_cells_interval 180
4、同步nova 資料庫並驗證
su -s /bin/sh -c "nova-manage api_db sync" nova
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
su -s /bin/sh -c "nova-manage db sync" nova
說明:忽略Warning
驗證cell0 和cell1 是否正確註冊。
su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova
6、啟動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
systemctl status openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
在計算節點安裝配置Nova
1、安裝元件
yum -y install openstack-nova-compute
2、修改配置檔案/etc/nova/nova.conf
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:openstack@controller
openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 192.168.10.31
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 auth_url http://controller:5000/v3
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 openstack
openstack-config --set /etc/nova/nova.conf keystone_authtoken token_cache_time 3600
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 \$my_ip
openstack-config --set /etc/nova/nova.conf vnc novncproxy_base_url http://controller:6080/vnc_auto.html
openstack-config --set /etc/nova/nova.conf vnc vncserver_proxyclient_address \$my_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 openstack
openstack-config --set /etc/nova/nova.conf scheduler discover_hosts_in_cells_interval 180
openstack-config --set /etc/nova/nova.conf libvirt hw_machine_type x86_64=pc-i440fx-rhel7.2.0
openstack-config --set /etc/nova/nova.conf libvirt cpu_mode host-passthrough
啟動計算服務(包括其依賴項),並將其配置為在系統引導時自動啟動
systemctl enable libvirtd.service openstack-nova-compute.service
systemctl start libvirtd.service openstack-nova-compute.service
3、驗證Nova
在控制節點執行以下操作進行驗證。
檢視計算服務元件狀態
openstack compute service list
檢視已註冊的計算節點
openstack compute service list --service nova-compute
主機發現 每新增主機就需要執行主機發現:
su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
列出keystone 服務中的API 端點以驗證與Identity 服務的連線。
~]# openstack catalog list
+-----------+-----------+-----------------------------------------+
| Name | Type | Endpoints |
+-----------+-----------+-----------------------------------------+
| nova | compute | RegionOne |
| | | internal: http://controller:8774/v2.1 |
| | | RegionOne |
| | | admin: http://controller:8774/v2.1 |
| | | RegionOne |
| | | public: http://controller:8774/v2.1 |
| | | |
| glance | image | RegionOne |
| | | internal: http://controller:9292 |
| | | RegionOne |
| | | admin: http://controller:9292 |
| | | RegionOne |
| | | public: http://controller:9292 |
| | | |
| keystone | identity | RegionOne |
| | | internal: http://controller:5000/v3/ |
| | | RegionOne |
| | | admin: http://controller:5000/v3/ |
| | | RegionOne |
| | | public: http://controller:5000/v3/ |
| | | |
| placement | placement | RegionOne |
| | | admin: http://controller:8778 |
| | | RegionOne |
| | | public: http://controller:8778 |
| | | RegionOne |
| | | internal: http://controller:8778 |
| | | |
+-----------+-----------+-----------------------------------------+
6、安裝配置Neutron(控制節點)
OpenStack 網路使用的是一個SDN(Software Defined Networking)元件,即Neutron,SDN 是一個可插拔的架構,支援插入交換機、防火牆、負載均
衡器等,這些都定義在軟體中,從而實現對整個雲基礎設施的精細化管控。
前期規劃,將ens33 網口作為外部網路(在Openstack 術語中,外部網路常被稱之為Provider 網路),同時也用作管理網路,便於測試訪問,生產環境
建議分開;ens37 網路作為租戶網路,即vxlan 網路;ens38 作為ceph 叢集網路。
OpenStack 網路部署方式可選的有OVS 和LinuxBridge。此處選擇LinuxBridge 模式,部署大同小異。
在控制節點上要啟動的服務neutron-server.service
neutron-linuxbridge-agent.service
neutron-dhcp-agent.service
neutron-metadata-agent.service
neutron-l3-agent.service
在控制節點(controller)安裝Neutron 服務,同時配置支援vxlan
1、登入資料庫建立neutron 資料庫
~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE neutron default character set utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'openstack';
2、建立使用者和API 服務端點
source /etc/keystone/admin-openrc.sh
建立Neutron 使用者,密碼設定為openstack
openstack user create --domain default --password openstack neutron
說明:使用--password openstack2022 neutron 是非互動式方式,而--password-prompt 是互動式,需要在視窗輸入2 次密碼確認
將neutron 加入到service 專案以及admin 角色
openstack role add --project service --user neutron admin
建立Neutron 服務實體。
openstack service create --name neutron --description "OpenStack Networking" network
建立Neutron API 服務端點。
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
3、安裝配置Neutron
採用Provider-LinuxBridge 模式
yum -y install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables
修改配置檔案/etc/neutron/neutron.conf
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 transport_url rabbit://openstack:openstack@controller
openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
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 DEFAULT allow_overlapping_ips true
openstack-config --set /etc/neutron/neutron.conf database connection mysql+pymysql://neutron:openstack@controller/neutron
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 openstack
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken token_cache_time 3600
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 openstack
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp
修改ML2 外掛配置檔案/etc/neutron/plugins/ml2/ml2_conf.ini
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vlan,vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers linuxbridge,l2population
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks provider
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vlan network_vlan_ranges provider
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vxlan vni_ranges 1:3000
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup enable_ipset true
修改/etc/neutron/plugins/ml2/linuxbridge_agent.ini 檔案,配置Linux 橋代理
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:ens32
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 local_ip 10.10.10.20
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
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
說明:local_ip 要修改成控制節點/計算節點實際用於vxlan IP。
provider 網路使用的是ens33 網口,部署時根據實際情況調整,provider 網路可以理解為能與外部網際網路相通的網路,後面在建立Flat 型別網路時
--provider-physical-network 要指定是provider。
修改核心配置檔案/etc/sysctl.conf,確保系統核心支援網橋過濾器
cat >> /etc/sysctl.conf <<EOF
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
執行以下命令,新增網橋過濾器,並設定開機載入
modprobe br_netfilter
cat > /etc/rc.sysinit <<EOF
#!/bin/bash
for file in /etc/sysconfig/modules/*.modules ; do
[ -x $file ] && $file
done
EOF
cat > /etc/sysconfig/modules/br_netfilter.modules <<EOF
modprobe br_netfilter
EOF
chmod 755 /etc/sysconfig/modules/br_netfilter.modules
修改/etc/neutron/dhcp_agent.ini 檔案,配置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
修改/etc/neutron/metadata_agent.ini 檔案,配置元資料代理
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 openstack
修改/etc/neutron/l3_agent.ini 檔案,配置layer-3 代理
openstack-config --set /etc/neutron/l3_agent.ini DEFAULT interface_driver linuxbridge
openstack-config --set /etc/neutron/l3_agent.ini DEFAULT external_network_bridge
配置計算服務以使用 Neutron 網路
前提:已經安裝了 nova 服務 yum -y install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler
修改/etc/nova/nova.conf檔案
openstack-config --set /etc/nova/nova.conf neutron url http://controller:9696
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 openstack
openstack-config --set /etc/nova/nova.conf neutron service_metadata_proxy true
openstack-config --set /etc/nova/nova.conf neutron metadata_proxy_shared_secret openstack
4、初始化建立網路
ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
5、同步 neutron 資料庫
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
6、啟動 neutron 各服務並設定為開機自啟動
systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service
systemctl restart neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service
systemctl status neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service
在計算節點(compute)安裝 Neutron 服務,同時配置支援 vxlan
說明:如果想把 controller 節點也作為計算節點,在 controller 節點上執行以下步驟
1、安裝元件neutron
yum install openstack-neutron-linuxbridge ebtables ipset -y
2、修改配置檔案/etc/neutron/neutron.conf
openstack-config --set /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:openstack@controller
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 openstack
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken token_cache_time 3600
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp
3、修改配置檔案/etc/neutron/plugins/ml2/linuxbridge_agent.ini
為例項建立layer-2 虛擬網路並且處理安全組規則,並將Flat 網路和外部物理業務網路介面對應起來
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:ens32
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 local_ip 10.10.10.31
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group True
說明:local_ip 要修改成計算節點實際用於vxlan IP。
provider 網路使用的是ens33 網口,部署時根據實際情況調整,provider 網路可以理解為能與外部網際網路相通的網路,後面在建立Flat 型別網路時物理
網路--provider-physical-network 要指定是provider。
3、修改配置檔案/etc/nova/nova.conf
openstack-config --set /etc/nova/nova.conf neutron url http://controller:9696
openstack-config --set /etc/nova/nova.conf neutron auth_url http://controller:5000/v3
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 openstack
修改核心配置檔案/etc/sysctl.conf,確保系統核心支援網橋過濾器
cat >> /etc/sysctl.conf <<EOF
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
執行以下命令,新增網橋過濾器,並設定開機載入
modprobe br_netfilter
cat > /etc/rc.sysinit <<EOF
#!/bin/bash
for file in /etc/sysconfig/modules/*.modules ; do
[ -x $file ] && $file
done
EOF
cat > /etc/sysconfig/modules/br_netfilter.modules <<EOF
modprobe br_netfilter
EOF
chmod 755 /etc/sysconfig/modules/br_netfilter.modules
5、啟動neutron-linuxbridge-agent 服務並設定開機自啟動
systemctl enable neutron-linuxbridge-agent.service
systemctl restart neutron-linuxbridge-agent.service
驗證Neutron
在控制節點執行以下操作進行驗證。
source /etc/keystone/admin-openrc.sh
1、列出成功啟動的Neutron 代理
~]# openstack network agent list
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| ID | Agent Type | Host | Availability Zone | Alive | State | Binary |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| 78cf5fd3-3330-47fe-876d-25cdd8a18c29 | DHCP agent | controller | nova | :-) | UP | neutron-dhcp-agent |
| 79563b4f-99b6-4ca9-97f1-a972d970e3d6 | L3 agent | controller | nova | :-) | UP | neutron-l3-agent |
| 9ca07dd3-b66a-4a17-abff-75df0c173bf6 | Metadata agent | controller | None | :-) | UP | neutron-metadata-agent |
| ea4500c8-4fbb-4f4d-bcd5-608e410f1d38 | Linux bridge agent | controller | None | :-) | UP | neutron-linuxbridge-agent |
| f5fe54c0-1662-4877-8ee5-873ea299b1a4 | Linux bridge agent | compute01 | None | :-) | UP | neutron-linuxbridge-agent |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
2、建立一個Flat 網路
openstack network create --share --external --provider-network-type flat public --provider-physical-network provider
說明:在linuxbridge_agent.ini 檔案中的physical_interface_mappings = provider:ens33,所以當前建立的flat 型別的物理網路
--provider-physical-network 要指定為provider
建立子網
在型別為Flat 名稱為public 網路下建立子網
openstack subnet create --network public \
--allocation-pool start=192.168.10.100,end=192.168.10.240 \
--dns-nameserver 223.5.5.5 \
--gateway 192.168.10.254 \
--subnet-range 192.168.10.0/24 flat_subnet
建立網路介面
openstack port create --network public --fixed-ip subnet=flat_subnet ip-address=192.168.10.110
檢視網路
openstack network list
檢視子網
openstack subnet list
檢視網路介面
openstack port list
刪除網路
openstack port delete ip-address=192.168.10.110
openstack subnet delete flat_subnet
openstack network delete public
說明:刪除網路前,要先後順序刪除,即先要刪除子網下的網路介面-->刪除子網-->刪除網路
7、安裝配置Horizon
OpenStack Dashboard 就是Horizon,提供了基於Web 控制檯,是一個執行在httpd 伺服器上的Web 服務
在控制節點(controller)安裝Horizon 服務
1、安裝軟體
yum -y install openstack-dashboard
2、修改配置檔案/etc/openstack-dashboard/local_settings
sed -i '$a\WEBROOT = \'\'/dashboard/\' /etc/openstack-dashboard/local_settings
a、配置WEBROOT 路徑和會話超時時間
sed -i '$a\SESSION_TIMEOUT = 86400\' /etc/openstack-dashboard/local_settings
b、更改OPENSTACK_HOST 值為"controller",若為127.0.0.1 則只能在當前主機訪問
sed -i 's\OPENSTACK_HOST = "127.0.0.1"\OPENSTACK_HOST = "controller"\' /etc/openstack-dashboard/local_settings
c、允許所有主機訪問,注意格式,逗號後面有一個空格
ALLOWED_HOSTS = ['*']
d、配置memcached 會話儲存服務,請註釋掉任何其他會話儲存配置,請注意格式。
#配置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
j、開啟對第3 層網路服務的支援。
OPENSTACK_NEUTRON_NETWORK = {
'enable_router': True,
'enable_quotas': True,
'enable_rbac_policy': True,
'enable_distributed_router': False,
'enable_ha_router': False,
'enable_ipv6': False,
'enable_lb': False,
'enable_firewall': False,
'enable_vpn': False,
'enable_fip_topology_check': True,
'default_dns_nameservers': [],
'supported_provider_types': ['*'],
'segmentation_id_range': {},
'extra_provider_types': {},
'supported_vnic_types': ['*'],
'physical_networks': [],
}
k、開啟卷備份特性,需要後端儲存型別為swift 或ceph 等支援分散式物件儲存
OPENSTACK_CINDER_FEATURES = {
'enable_backup': True,
}
3、修改配置檔案/etc/httpd/conf.d/openstack-dashboard.conf
sed -i '$a\WSGIApplicationGroup %{GLOBAL}\' /etc/httpd/conf.d/openstack-dashboard.conf
4、修改/usr/share/openstack-dashboard/ 資料夾屬組、屬主為apache
chown -R apache:apache /usr/share/openstack-dashboard/
5、重新啟動httpd 伺服器和Memcache 服務
systemctl restart httpd.service memcached.service
8、安裝並驗證cinder
塊儲存服務(Block Storage Service)cinder,作為OpenStack 的塊儲存服務,為Instance 提供虛擬磁碟,其類似AWS 的EBS(Elastic Block Storage),
它們之間的區別在於儲存卷暴露給虛擬機器例項的方式。在OpenStack 中,通過iSCSI 暴露LVM 卷組(VG)對捲進行管理,所以使用cinder 的儲存節點都會
有VG。
cinder 在控制節點上需要安裝openstack-cinder,對應要啟動的服務有:cinder-api、cinder-scheduler。修改好配置後,需要啟動:
openstack-cinder-api.service openstack-cinder-scheduler.service
cinder 在儲存節點上需要安裝openstack-cinder lvm2 device-mapper-persistent-data openstack-cinder targetcli python-keystone
cinder 在儲存節點上執行的服務是:cinder-volume,當然還需啟動其依賴的LVM、target 服務。修改好配置後,需要啟動:lvm2-lvmetad.service、
openstack-cinder-volume.service target.service
說明:cinder-api 用來接收api 請求,然後將請求訊息加工後放到MQ 裡,cinder-scheduler 從MQ 中消費訊息,通過排程演算法選擇相應的儲存節點,然
後將訊息放到MQ 裡,cinder-volume 收到scheduler 訊息後,開始對捲進行操作。cinder-volume 用來管理卷volume 生命令週期,cinder-volume 是運
行在儲存節點上。
沒有安裝cinder 服務時,Openstack Dashboard 是不能對外提供卷服務操作的
控制節點和儲存節點的cinder.conf 配置可以相同,前提是當控制節點不具備對應的VG 時,不要啟動openstack-cinder-volume.service,否則會報錯找
不到VG。
在控制節點(controller)安裝配置Cinder 塊儲存服務
1、登入資料庫建立cinder 資料庫
~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE cinder default character set utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'openstack';
2、建立使用者和API 服務端點
source /etc/keystone/admin-openrc.sh
建立cinder 使用者,密碼設定為:openstack
openstack user create --domain default --password openstack cinder
將cinder 加入到service 專案以及admin 角色
openstack role add --project service --user cinder admin
建立cinderv2 和cinderv3 服務實體
openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
建立Block Storage API 服務端點
openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 public http://controller:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 internal http://controller:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 admin http://controller:8776/v3/%\(project_id\)s
3、安裝cinder 軟體包並修改配置檔案
yum -y install openstack-cinder
修改配置檔案/etc/cinder/cinder.conf
openstack-config --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://openstack:openstack@controller
openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 192.168.10.20
openstack-config --set /etc/cinder/cinder.conf DEFAULT default_volume_type hdd
openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:openstack@controller/cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken www_authenticate_uri http://controller:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://controller:5000/v3
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_name service
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken username cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken password openstack
openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
修改配置檔案/etc/nova/nova.conf,讓計算服務支援塊儲存
openstack-config --set /etc/nova/nova.conf cinder os_region_name RegionOne
4、同步cinder 資料庫
su -s /bin/sh -c "cinder-manage db sync" cinder
說明:忽略帶有“Deprecated: Option...” 輸出
5、重啟服務並設定成開機自啟動
重啟nova-api 服務
systemctl restart openstack-nova-api.service
啟動cinder-api、cinder-scheduler 服務並將其設定為開機自啟動。
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl status openstack-cinder-api.service openstack-cinder-scheduler.service
6、驗證控制節點cinder-scheduler,狀態為up 即正常
~]# openstack volume service list
+------------------+------------+------+---------+-------+----------------------------+
| Binary | Host | Zone | Status | State | Updated At |
+------------------+------------+------+---------+-------+----------------------------+
| cinder-scheduler | controller | nova | enabled | up | 2022-03-20T07:43:46.000000 |
+------------------+------------+------+---------+-------+----------------------------+
在儲存節點(compute)安裝配置Cinder 服務
cinder 在儲存節點上執行的服務是:cinder-volume,當然其依賴LVM、target 服務。
修改好配置後,需要啟動的服務有:lvm2-lvmetad.service、openstack-cinder-volume.service target.service
1、在儲存節點安裝和配置LVM 並設定為開機自啟動
yum -y install lvm2 device-mapper-persistent-data
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service
2、計算節點compute分別規劃了1 個200GB 的硬碟用作虛機儲存,在系統上對應是/dev/sdb
建立分割槽
~]# parted /dev/sdb
建立PV
pvcreate /dev/sdb1
建立VG,VG 名稱定義為cinder-volumes
vgcreate cinder-volumes /dev/sdb1
3、修改配置檔案/etc/lvm/lvm.conf
vi /etc/lvm/lvm.conf
在devices 部分中,新增一個接受/dev/sdb 裝置的過濾器並拒絕所有其他裝置。
devices {
filter = [ "a/sda/", "a/sdb/", "r/.*/"]
}
說明:filter 過濾器陣列中的每個專案開頭為“a”或者“r”,用於接受或用於拒絕某個裝置,如果儲存節點在作業系統磁碟上使用LVM,則還必須將關聯的
系統盤裝置新增到過濾器。同樣,如果計算節點在作業系統磁碟上使用LVM,也需要修改這些節點上“/etc/lvm/lvm.conf”檔案中的過濾器以包括操作系
統磁碟。例如,如果“/dev/sda”裝置包含作業系統,則需要將“sda”新增到過濾器。
參考:https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/cinder-storage-install.html
4、安裝和配置儲存節點
說明:儲存節點的cinder.conf 包含了控制節點的cinder.conf,如果控制節點即是儲存節點,可以直接用儲存節點的cinder.conf安裝軟體包
yum -y install openstack-cinder targetcli python-keystone
修改配置檔案/etc/cinder/cinder.conf
openstack-config --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://openstack:openstack@controller
openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 192.168.10.31
openstack-config --set /etc/cinder/cinder.conf DEFAULT enabled_backends lvm
openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_api_servers http://controller:9292
openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:openstack@controller/cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken www_authenticate_uri http://controller:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://controller:5000/v3
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_name service
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken username cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken password openstack
openstack-config --set /etc/cinder/cinder.conf lvm volume_driver cinder.volume.drivers.lvm.LVMVolumeDriver
openstack-config --set /etc/cinder/cinder.conf lvm volume_group cinder-volumes
openstack-config --set /etc/cinder/cinder.conf lvm target_protocol iscsi
openstack-config --set /etc/cinder/cinder.conf lvm target_helper lioadm
openstack-config --set /etc/cinder/cinder.conf lvm volume_backend_name cinder-volumes
openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
5、啟動cinder-volume、target 服務,並設定開機自啟動
systemctl enable openstack-cinder-volume.service target.service
systemctl restart openstack-cinder-volume.service target.service
6、在控制節點(controller)進行驗證
列出儲存服務元件,若狀態均為up 即正常
~]# openstack volume service list
+------------------+---------------+------+---------+-------+----------------------------+
| Binary | Host | Zone | Status | State | Updated At |
+------------------+---------------+------+---------+-------+----------------------------+
| cinder-scheduler | controller | nova | enabled | up | 2022-03-20T08:19:27.000000 |
| cinder-volume | compute01@lvm | nova | enabled | up | 2022-03-20T08:19:29.000000 |
+------------------+---------------+------+---------+-------+----------------------------+
Cinder 常用命令
a、建立儲存卷
openstack volume create --size 1 volume01
說明:建立一個卷名為volume01 大小為1GB 的卷
b、檢視儲存卷列表
openstack volume list
c、為儲存卷建立快照
openstack volume snapshot create --volume volume01 snap-volume01
說明:為卷volume01 建立一個名為snap-volume01 的快照
d、檢視快照列表
openstack volume snapshot list
e、掛載捲到例項
nova volume-attach vm01 ead55f47-a0f3-4eb9-854e-9dff638ff534 /dev/vdb
說明:掛載卷時,要指定卷id,此處要指定卷volume01 的id,然後是連線到例項vm01 的/dev/vdb 上
虛擬機器解除安裝卷
nova volume-detach vm01 ead55f47-a0f3-4eb9-854e-9dff638ff534
說明:解除安裝卷時,請先在作業系統層停止正在使用要解除安裝的應用,umount 掉,然後再執行volume-detach
刪除所選儲存卷
openstack volume snapshot delete snap-volume01
openstack volume delete volume01
說明:刪除卷要具備2 個條件,第一個是卷狀態是可用(available)或其他而非使用中;第二個就是要刪除的捲上沒有快照,如果有要先刪除快照。
openstack volume show volume01
禁用儲存節點
openstack volume service set --disable compute02@lvm cinder-volume
啟用儲存節點
openstack volume service set --enable compute02@lvm cinder-volume