目錄
1、安裝環境說明
OS:Ubuntu 14.04 LTS
Controller
- IP:10.0.0.11 / 24
- Gateway:10.0.0.1
Network
- Management IP:10.0.0.21 / 24 (eth0)
- Gateway:10.0.0.1
- Instance Tunnel IP:10.0.1.21 / 24 (eth1)
- External Interface (eth2)
- IP:不指定 IP
- 設定方式如下:(修改 /etc/network/interfaces)
auto eth2
iface eth2 inet manual
up ip link set dev $IFACE up
down ip link set dev $IFACE down
Compute 1
- Management IP:10.0.0.31 / 24
- Gateway:10.0.0.1
- Instance Tunnel IP:10.0.1.31
Block Storage 1
- Management IP:10.0.0.41 / 24
- Gateway:10.0.0.1
- Instance Tunnel IP:10.0.1.41
修改每個 node 的 /etc/hosts 檔案,並加入以下內容:
10.0.0.11 controller
10.0.0.21 network
10.0.0.31 compute1
10.0.0.41 block1
- 使用者身分:root
2、Block Storage Service(Cinder) 概觀
OpenStack Block Storage(Cinder) 的工作包含 volume、volume 快照、volume 類型的管理,主要用來提供給 VM 區塊等級(Block Level)的永久性儲存空間,提供快照、資料回復…等功能,還可以整合其他商業化的企業儲存平台,例如 NetApp、Nexenta … 等。
3、Cinder 服務元件架構
在安裝之前,可以先用以下這張圖來了解一下 Cinder 是由那些 component 組合而成的(截錄自工研院-OpenStack Cinder Tutorial 一文):
從上圖可看出,Cinder 共包含了以下重要的部分:
3.1 cinder-api
用來接受來自外部對於 volume 空間的請求後,透過 message queue 將請求轉給 cinder-scheduler 後再轉給 cinder-volume 進行後續處理。
3.2 cinder-scheduler
類似 nova-schedular 的角色,接收到來自 message queue 的命令後,會從多個(如果有)提供 block storage 服務的 node 挑選出一個最合適來建立 volume。
3.3 cinder-volume
cinder-volume 的工作大概有幾項:
- 接收來自 cinder-scheduler 的命令,建立新的 volume。
- 接收來自 message queue 的訊息,進行 volume 空間的讀寫。
- 透過不同的 driver,還可以使用多種不同的 storage provider 所提供的設備。
3.4 message queue
負責將訊息派送給各個 Block Storage service。
4、安裝 & 設定 Block Storage Service Controller
了解 Block Storage 各個不同服務之後,接下來要來進行各個服務的安裝,首先這邊要先安裝的是 cinder-api & cinder-scheduler。
由於這兩個服務並不牽涉到真正磁碟空間的存取 or 外部儲存設備的控制,因此這邊選擇在 controller node 上進行安裝。
4.1 安裝服務套件
controller# apt-get install cinder-api cinder-scheduler
4.2 設定資料庫
首先建立資料庫 & 設定權限:
# 登入 MySQL
controller# mysql -u root -p
Enter password:
# 建立 cinder 資料庫
mysql> create database cinder;
Query OK, 1 row affected (0.02 sec)
# 設定使用者權限
mysql> grant all privileges on cinder.* to 'cinder'@'localhost' identified by 'YOUR_CINDER_DB_PASSWORD';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on cinder.* to 'cinder'@'%' identified by 'YOUR_CINDER_DB_PASSWORD';
Query OK, 0 rows affected (0.00 sec)
接著修改 Cinder 設定檔 /etc/cinder/cinder.conf,加入以下內容:
[database]
connection = mysql://cinder:YOUR_CINDER_DB_PASSWORD@controller/cinder
最後建立 Cinder 資料庫中的相關 table:
controller# sh -c "cinder-manage db sync" cinder
4.3 設定 message queue
此處要設定 Cinder 使用之前所安裝好的 RabbitMQ message broker 作為 message queue 之用。
修改設定檔 /etc/cinder/cinder.conf,加入以下內容:
[DEFAULT]
rpc_backend = rabbit
rabbit_host = controller
rabbit_userid = guest
rabbit_password = YOUR_RABBITMQ_PASSWORD
4.4 設定 Identity Service 認證
#建立 Cinder service 用的 user
controller# keystone user-create --name=cinder --pass=YOUR_CINDER_PASSWORD --email=admin@example.com
+----------+----------------------------------+
| Property | Value |
+----------+----------------------------------+
| email | admin@example.com |
| enabled | True |
| id | f31b2ebaf1be446490769637c6987b5b |
| name | cinder |
| username | cinder |
+----------+----------------------------------+
#將 user / service Tenant / admin Role 連結
controller# keystone user-role-add --user=cinder --tenant=service --role=admin
4.5 向 Identity Service 註冊 Cinder 服務 & API 服務端點
首先要修改設定檔 /etc/cinder/cinder.conf,加入設定內容如下:
[keystone_authtoken]
auth_uri = http://controller:5000
auth_host = controller
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = cinder
admin_password = CINDER_PASS
向 Identity Service(Keystone) 註冊 Service & API endpoint (version1):
#註冊 Cinder service (version 1)
controller# keystone service-create --name=cinder --type=volume --description="OpenStack Block Storage"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | 0b1d7ff1bb3f4136be58e32bc73e89bc |
| name | cinder |
| type | volume |
+-------------+----------------------------------+
#註冊 Cinder API endpoint (version 1)
controller# keystone endpoint-create --service-id=$(keystone service-list | awk '/ volume / {print $2}') --publicurl=http://controller:8776/v1/%\(tenant_id\)s --adminurl=http://controller:8776/v1/%\(tenant_id\)s
+------------+-----------------------------------------+
| Property | Value |
+------------+-----------------------------------------+
| adminurl | http://controller:8776/v1/%(tenant_id)s |
| id | 5a58ee0f46ca4721aaa28be98520dec3 |
| publicurl | http://controller:8776/v1/%(tenant_id)s |
| region | regionOne |
| service_id | 0b1d7ff1bb3f4136be58e32bc73e89bc |
+------------+-----------------------------------------+
接著向 Identity Service(Keystone) 註冊 Service & API endpoint (version2):
#註冊 Cinder service (version 2)
controller# keystone service-create --name=cinderv2 --type=volumev2 --description="OpenStack Block Storage v2"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage v2 |
| enabled | True |
| id | 6e20dad30957436fb142c20d1848ce91 |
| name | cinderv2 |
| type | volumev2 |
+-------------+----------------------------------+
#註冊 Cinder API endpoint (version 2)
controller# keystone endpoint-create --service-id=$(keystone service-list | awk '/ volumev2 / {print $2}') --publicurl=http://controller:8776/v2/%\(tenant_id\)s --internalurl=http://controller:8776/v2/%\(tenant_id\)s --adminurl=http://controller:8776/v2/%\(tenant_id\)s
+-------------+-----------------------------------------+
| Property | Value |
+-------------+-----------------------------------------+
| adminurl | http://controller:8776/v2/%(tenant_id)s |
| id | 39d9a5060449490fbd1016cbcd1f4904 |
| internalurl | http://controller:8776/v2/%(tenant_id)s |
| publicurl | http://controller:8776/v2/%(tenant_id)s |
| region | regionOne |
| service_id | 6e20dad30957436fb142c20d1848ce91 |
+-------------+-----------------------------------------+
4.6 啟動服務
最後啟動 controller 上的 cinder-scheduler & cinder-api 服務:
controller# service cinder-scheduler restart
controller# service cinder-api restart
5、安裝 &設定 Block Storage Service node
5.1 Block Storage Node 環境說明
controller 安裝完畢後,接著要安裝實際提供磁碟存取空間的 service 到擁有磁碟空間的 storage node 上。
這邊準備了另外一台電腦(block1),除了以下是目前磁碟的狀況:
block1# # fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
…..
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 14680063 7339008 83 Linux
/dev/sda2 14682110 16775167 1046529 5 Extended
/dev/sda5 14682112 16775167 1046528 82 Linux swap / SolarisDisk /dev/sdb: 17.2 GB, 17179869184 bytes
…..
Disk /dev/sdb doesn’t contain a valid partition tableDisk /dev/sdc: 17.2 GB, 17179869184 bytes
…..
Disk /dev/sdc doesn’t contain a valid partition table
這邊將會以兩個空白的磁碟作 LVM 來提供磁碟空間的服務。
網路設定在前面的安裝環境說明有提供。
5.2 建立 LVM 磁區
首先安裝 LVM 所需套件:
block1# apt-get install lvm2
5.3 建立 LVM Physical Volumes & Logical Volumes
#建立 physical volume
block1# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
#建立 physical volume
block1# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created
#建立 logical volume
block1# vgcreate cinder-volumes /dev/sdb /dev/sdc
Volume group "cinder-volumes" successfully created
修改設定檔 /etc/lvm/lvm.conf,確認 filter 設定有包含上述的 /dev/sdb & /dev/sdc:
#預設是允許所有 device
filter = [ "a/.*/" ]
最後確認 PV & LV 的狀態:
#physical volume 狀態
block1# # pvdisplay
--- Physical volume ---
PV Name /dev/sdb
VG Name cinder-volumes
PV Size 16.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 4095
Free PE 4095
Allocated PE 0
PV UUID peJ31b-ef8x-2x60-3uZS-ovGA-dTLb-1WfpBL
--- Physical volume ---
PV Name /dev/sdc
VG Name cinder-volumes
PV Size 16.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 4095
Free PE 4095
Allocated PE 0
PV UUID 191rYU-Tfdp-7Sop-x76M-o1cn-F4Mp-S7QhoF
#logical volume 狀態
block1# vgdisplay
--- Volume group ---
VG Name cinder-volumes
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 31.99 GiB
PE Size 4.00 MiB
Total PE 8190
Alloc PE / Size 0 / 0
Free PE / Size 8190 / 31.99 GiB
VG UUID ii5kLD-8K94-wqZw-W1CN-nqSq-tLkW-0l74oZ
若想更了解 LVM,可參考「紐菲斯的部落格 » 好用的Linux LVM 管理」一文。
5.4 安裝 & 設定 Block Storage service
5.4.1 安裝套件
除了 cinder-volume 要裝之外,python-mysqldb 也別忘記裝了,否則 cinder-volume service 無法與 controller 的 MySQL service 互動
block1# apt-get install cinder-volume python-mysqldb
5.4.2 設定檔調整
修改設定檔 /etc/cinder/cinder.conf,要加入的設定包含四個部分,分別是:
- Identity Service(Keystone)、
- Message Broker (RabbitMQ)
- Database
- Image Service (Glance)
加入的設定內容如下:
#Identity Service (Keystone)
[keystone_authtoken]
auth_uri = http://controller:5000
auth_host = controller
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = cinder
admin_password = CINDER_PASSWORD
#Message Broker (RabbitMQ)
[DEFAULT]
rpc_backend = rabbit
rabbit_host = controller
rabbit_port = 5672
rabbit_userid = guest
rabbit_password = YOUR_RABBITMQ_PASS
#Database
[database]
connection = mysql://cinder:YOUR_CINDER_DBPASSWORD@controller/cinder
#Image Service(Glance)
[DEFAULT]
glance_host = controller
最後啟動相關服務即可:
block1# service cinder-volume restart
block1# service tgt restart
6、驗證安裝是否成功
controller# source ~/OpenStack/demo-openrc.sh
controller# cinder create --display-name myVolume 1
+---------------------+--------------------------------------+
| Property | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| created_at | 2014-10-07T21:19:50.061350 |
| display_description | None |
| display_name | myVolume |
| encrypted | False |
| id | d92f805d-7bdb-4280-80c1-ba562de405cc |
| metadata | {} |
| size | 1 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| volume_type | None |
+---------------------+--------------------------------------+
#顯示剛剛建立的 volume 資訊,若是看到 available 就表示成功囉!
controller# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| d92f805d-7bdb-4280-80c1-ba562de405cc | available | myVolume | 1 | None | false | |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
登入 Horizon 之後同樣也可以看的到:
7. 障礙排除
一開始按照官網文件設定好時,建立好的 volume 的狀態都是 error,於是檢查了一下位於 controller 上的 log 資訊 (/var/log/cinder/cinder-scheduler.log),出現以下訊息:
2014-10-07 21:51:51.378 16282 INFO oslo.messaging._drivers.impl_rabbit [req-a51641a5-f260-4540-86f1-88afe19d796f - - - - -] Reconnecting to AMQP server on localhost:5672
2014-10-07 21:51:51.379 16282 INFO oslo.messaging._drivers.impl_rabbit [req-a51641a5-f260-4540-86f1-88afe19d796f - - - - -] Delaying reconnect for 1.0 seconds…
2014-10-07 21:51:55.393 16282 ERROR oslo.messaging._drivers.impl_rabbit [req-a51641a5-f260-4540-86f1-88afe19d796f - - - - -] AMQP server on localhost:5672 is unreachable: Socket closed. Trying again in 30 seconds.
2014-10-07 21:52:25.420 16282 INFO oslo.messaging._drivers.impl_rabbit [req-a51641a5-f260-4540-86f1-88afe19d796f - - - - -] Reconnecting to AMQP server on localhost:5672
2014-10-07 21:52:25.420 16282 INFO oslo.messaging._drivers.impl_rabbit [req-a51641a5-f260-4540-86f1-88afe19d796f - - - - -] Delaying reconnect for 1.0 seconds…
2014-10-07 21:52:29.440 16282 ERROR oslo.messaging._drivers.impl_rabbit [req-a51641a5-f260-4540-86f1-88afe19d796f - - - - -] AMQP server on localhost:5672 is unreachable: Socket closed. Trying again in 30 seconds.
2014-10-07 21:52:41.508 16282 INFO cinder.openstack.common.service [-] Caught SIGTERM, exiting
2014-10-07 21:52:42.284 8458 AUDIT cinder.service [-] Starting cinder-scheduler node (version 2014.1.2)
2014-10-07 21:52:42.299 8458 INFO oslo.messaging._drivers.impl_rabbit [req-8e0f3895-d447-4f27-a3b4-f5789f02b9f8 - - - - -] Connected to AMQP server on controller:5672
2014-10-07 21:52:43.055 8458 INFO oslo.messaging._drivers.impl_rabbit [-] Connected to AMQP server on controller:5672
2014-10-07 21:52:58.305 8458 WARNING cinder.context [-] Arguments dropped when creating context: {‘user’: u’bc1ae50e167f45edb064e582702c5792’, ‘tenant’: u’7539436331ca4f9783bf93163e2a2e0f’, ‘user_identity’: u’bc1ae50e167f45edb064e582702c5792 7539436331ca4f9783bf93163e2a2e0f - - -‘}
2014-10-07 21:52:58.399 8458 ERROR cinder.scheduler.flows.create_volume [req-6c3a8fac-3f20-46d5-bd59-a7689bca561f bc1ae50e167f45edb064e582702c5792 7539436331ca4f9783bf93163e2a2e0f - - -] Failed to schedule_create_volume: No valid host was found.
從上述資訊可知,cinder-scheduler 服務找不到提供 cinder-volume service 的 node,因此朝向 block1 主機沒有正確的加入 OpenStack 環境中的方向來尋找問題。
於是到 block1 主機上檢查 Log (/var/log/cinder/cinder-volume.log ),出現以下錯誤訊息:
2014-10-08 05:15:04.936 6422 ERROR cinder.openstack.common.threadgroup [-] No module named MySQLdb
2014-10-08 05:15:06.388 6432 ERROR cinder.openstack.common.threadgroup [-] No module named MySQLdb
2014-10-08 05:15:06.842 6442 ERROR cinder.openstack.common.threadgroup [-] No module named MySQLdb
2014-10-08 05:15:08.290 6452 ERROR cinder.openstack.common.threadgroup [-] No module named MySQLdb
2014-10-08 05:15:08.734 6462 ERROR cinder.openstack.common.threadgroup [-] No module named MySQLdb
2014-10-08 05:15:10.183 6472 ERROR cinder.openstack.common.threadgroup [-] No module named MySQLdb
看起來是少裝了 python 與 MySQL 相關的 package,找了一下網路資料,原來要補裝 python-mysqldb,所以只要在 block1 主機上補裝這個套件,再重新啟動 cinder-volume 服務即可。
前面的安裝過程中已經補上,如果按照前面操作下來,應該是不會遇到跟我相同的錯誤。
沒有留言:
張貼留言