快速入門Openstack,無腦多節點部署Mitaka(7)--cinder部署
什麼是Cinder?
1.簡介
Cinder從Openstack的Folsom版本(2012年9月釋出)開始出現,用以替代Nova-Volume服務,Cinder為Openstack提供了管理卷(volunme)的基礎設施。
Cinder是受請求得到、自助化訪問的塊儲存服務,即Cinder有兩個顯著地特點,第一,必須使用者提出請求,才能得到該服務;第二,使用者可以自定義的半自動化服務。Cinder實現LVM(邏輯卷管理),用以呈現儲存資源給能夠被Nova呼叫的端使用者。簡而言之,Cinder虛擬化塊儲存裝置池,提供端使用者自助服務的API用以請求和使用這些塊資源,並且不用瞭解儲存的位置或裝置資訊。
2.虛擬機器對儲存的要求
下面是我們建立虛擬機器例項時需要呼叫儲存服務的流程:
3.相關元件
1.cinder-api:
Accepts API requests, and routes them to the cinder-volume for action.
2.cinder-volume:
Interacts directly with the Block Storage service, and processes such as the cinder-scheduler. It also interacts with these processes through a message queue. The cinder-volume service responds to read and write requests sent to the Block Storage service to maintain state. It can interact with a variety of storage providers through a driver architecture.
3.cinder-scheduler daemon:
Selects the optimal storage provider node on which to create the volume. A similar component to the nova-scheduler.
4.cinder-backup daemon:
The cinder-backup service provides backing up volumes of any type to a backup storage provider. Like the cinder-volume service, it can interact with a variety of storage providers through a driver architecture.
5.Messaging queue:
Routes information between the Block Storage processes.
懶得翻譯了,反正感覺也沒有什麼人在看,就當做是自己的筆記了….
簡要說下三個主要組成部分:
–cinder-api 元件負責向外提供Cinder REST API
–cinder-scheduler 元件負責分配儲存資源
–cinder-volume 元件負責封裝driver,不同的driver負責控制不同的後端儲存
cinder-controller部署
注意:以下操作是在controller節點上執行。因為跟之前安裝的服務都是大同小異,我只對不同部分做介紹,如果有不明白的,可以留言問我,或者翻翻之前的部落格。
1.建立資料庫
建立cinder資料庫和cinder管理員:
command:
mysql -u root -p123456
CREATE DATABASE cinder;
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \
IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \
IDENTIFIED BY '123456';
exit
outPut:
[[email protected] ~]# mysql -u root -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 365
Server version: 10.1.12-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE cinder;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \
-> IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \
-> IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
2.建立cinder使用者
在openstack中建立cinder使用者,並設定為service tenant的管理員:
[[email protected] ~]# source ~/admin-openrc
[[email protected] ~]# openstack user create --domain default --password-prompt cinder
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | 098b1a4d36d241ed87e979ec86d32722 |
| enabled | True |
| id | 897788ab549f4490aa6cf6e93efb3b09 |
| name | cinder |
+-----------+----------------------------------+
[[email protected] ~]# openstack role add --project service --user cinder admin
[[email protected] ~]#
3.建立API埠
建立cinder and cinderv2 service entities,並建立相對應埠
[[email protected] ~]# openstack service create --name cinder \
> --description "OpenStack Block Storage" volume
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | ac05b107e8744008878aedc102bfbe0b |
| name | cinder |
| type | volume |
+-------------+----------------------------------+
[[email protected] ~]# openstack service create --name cinderv2 \
> --description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | ebe25d2e0527457ba8ce2f117b0225fd |
| name | cinderv2 |
| type | volumev2 |
+-------------+----------------------------------+
[[email protected] ~]#
[[email protected] ~]# openstack endpoint create --region RegionOne \
> volume public http://controller.example.com:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------------------+
| Field | Value |
+--------------+-----------------------------------------------------+
| enabled | True |
| id | b96b9d92e36d41f0a921b9b59292eb0e |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ac05b107e8744008878aedc102bfbe0b |
| service_name | cinder |
| service_type | volume |
| url | http://controller.example.com:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne \
> volume internal http://controller.example.com:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------------------+
| Field | Value |
+--------------+-----------------------------------------------------+
| enabled | True |
| id | 89940a77b9034b4a9a0d7685d3021e3c |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ac05b107e8744008878aedc102bfbe0b |
| service_name | cinder |
| service_type | volume |
| url | http://controller.example.com:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne \
> volume admin http://controller.example.com:8776/v1/%\(tenant_id\)s
+--------------+-----------------------------------------------------+
| Field | Value |
+--------------+-----------------------------------------------------+
| enabled | True |
| id | 6cda84d1a57247699d304b0eeeb916a9 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ac05b107e8744008878aedc102bfbe0b |
| service_name | cinder |
| service_type | volume |
| url | http://controller.example.com:8776/v1/%(tenant_id)s |
+--------------+-----------------------------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne \
> volumev2 public http://controller.example.com:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------------------+
| Field | Value |
+--------------+-----------------------------------------------------+
| enabled | True |
| id | f20f4a5536eb491d9cd1101066745ea9 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ebe25d2e0527457ba8ce2f117b0225fd |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller.example.com:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne \
> volumev2 internal http://controller.example.com:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------------------+
| Field | Value |
+--------------+-----------------------------------------------------+
| enabled | True |
| id | b24401cc22c34943b5b4819bbc3988ad |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ebe25d2e0527457ba8ce2f117b0225fd |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller.example.com:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne \
> volumev2 admin http://controller.example.com:8776/v2/%\(tenant_id\)s
+--------------+-----------------------------------------------------+
| Field | Value |
+--------------+-----------------------------------------------------+
| enabled | True |
| id | eeb0c5598c8c4a63860fb432f56a2be7 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ebe25d2e0527457ba8ce2f117b0225fd |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller.example.com:8776/v2/%(tenant_id)s |
+--------------+-----------------------------------------------------+
[[email protected] ~]#
4.安裝相關元件
1.安裝
yum install openstack-cinder -y
2.修改配置檔案
cp -p /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
vim /etc/cinder/cinder.conf
[DEFAULT]
...
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 192.168.0.17
[oslo_messaging_rabbit]
...
rabbit_host = controller.example.com
rabbit_userid = openstack
rabbit_password = henry
[database]
...
connection = mysql+pymysql://cinder:123456@controller.example.com/cinder
[keystone_authtoken]
...
auth_uri = http://controller.example.com:5000
auth_url = http://controller.example.com:35357
memcached_servers = controller.example.com:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = 123456
[oslo_concurrency]
...
lock_path = /var/lib/cinder/tmp
5.同步資料庫
su -s /bin/sh -c "cinder-manage db sync" cinder
忽略掉有關棄用的輸出
6.配置計算節點去使用Cinder
vim /etc/nova/nova.conf
[cinder]
os_region_name = RegionOne
7.相關服務
1.重啟openstack-nova-api.service
systemctl restart openstack-nova-api.service
2.啟動openstack-cinder-api和openstack-cinder-scheduler,並設定為開機自啟
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
controller-block配置
注意,以下操作均在storage節點中執行
1.安裝lvm2元件
yum install lvm2 -y
2.啟動服務並設定為開機自啟
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service
3.建立卷組
/dev/vdb是我額外新增的一塊新的硬碟,不是作業系統盤。
1.建立物理卷:
[root@storage ~]# pvcreate /dev/vdb
Physical volume "/dev/vdb" successfully created
[root@storage ~]#
2.建立cinder-volumes卷組:
[root@storage ~]# vgcreate cinder-volumes /dev/vdb
Volume group "cinder-volumes" successfully created
[root@storage ~]#
3.編輯/etc/lvm/lvm.conf檔案
新增過濾規則,允許訪問/dev/vdb,拒絕其他裝置。
vim /etc/lvm/lvm.conf
devices {
...
filter = [ "a/vdb/", "r/.*/"]
4.安裝其他元件
1.安裝openstack-cinder和targetcli
yum install openstack-cinder targetcli -y
2.編輯/etc/cinder/cinder.conf
cp -p /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
vim /etc/cinder/cinder.conf
[DEFAULT]
...
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 192.168.0.19
enabled_backends = lvm
glance_api_servers = http://controller.example.com:9292
[oslo_messaging_rabbit]
...
rabbit_host = controller.example.com
rabbit_userid = openstack
rabbit_password = henry
[database]
...
connection = mysql+pymysql://cinder:123456@controller.example.com/cinder
[keystone_authtoken]
...
auth_uri = http://controller.example.com:5000
auth_url = http://controller.example.com:35357
memcached_servers = controller.example.com:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = 123456
[lvm] #原檔案沒有該模組,手動新增至尾行
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm
[oslo_concurrency]
...
lock_path = /var/lib/cinder/tmp
總覽:
[[email protected] ~]# cat /etc/cinder/cinder.conf | grep -v ^# | grep -v ^$
[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 192.168.0.19
enabled_backends = lvm
glance_api_servers = http://controller.example.com:9292
[BACKEND]
[BRCD_FABRIC_EXAMPLE]
[CISCO_FABRIC_EXAMPLE]
[COORDINATION]
[FC-ZONE-MANAGER]
[KEYMGR]
[cors]
[cors.subdomain]
[database]
connection = mysql+pymysql://cinder:[email protected]/cinder
[keystone_authtoken]
auth_uri = http://controller.example.com:5000
auth_url = http://controller.example.com:35357
memcached_servers = controller.example.com:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = 123456
[matchmaker_redis]
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[oslo_messaging_amqp]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
rabbit_host = controller.example.com
rabbit_userid = openstack
rabbit_password = henry
[oslo_middleware]
[oslo_policy]
[oslo_reports]
[oslo_versionedobjects]
[ssl]
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm
[[email protected] ~]#
5.啟動相關服務
啟動相關服務並設定為開機自啟
systemctl enable openstack-cinder-volume.service target.service
systemctl start openstack-cinder-volume.service target.service
哈哈,雲主機被黑了,還被植入了後門程式,懶得弄了,所以直接關機了。因為沒有打快照,所以部署教程就到此結束了。其實到這裡大家可以建立個虛擬機器玩玩了。