本節(jié)教程將介紹如何在塊控制器節(jié)點(diǎn)上安裝和配置名為 Cinder 的存儲(chǔ)服務(wù)。該服務(wù)至少需要一個(gè)額外的存儲(chǔ)節(jié)點(diǎn),以便提供卷的復(fù)制功能到實(shí)例。
一、先決條件
在安裝和配置 Block Storage 服務(wù)之前,需要完成以下步驟以創(chuàng)建數(shù)據(jù)庫、服務(wù)憑證和 API 終端節(jié)點(diǎn)。
1、創(chuàng)建數(shù)據(jù)庫
使用數(shù)據(jù)庫訪問客戶端連接到數(shù)據(jù)庫服務(wù)器,作為用戶 “root”:
mysql -u root -p
創(chuàng)建數(shù)據(jù)庫:
MariaDB [(none)]> CREATE DATABASE cinder;
授予對數(shù)據(jù)庫的適當(dāng)訪問權(quán)限:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \ IDENTIFIED BY 'CINDER_DBPASS'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \ IDENTIFIED BY 'CINDER_DBPASS';
請將 “CINDER_DBPASS” 替換為選擇的合適密碼。然后退出數(shù)據(jù)庫訪問客戶端。
2、獲取管理員訪問憑據(jù)
在命令行中獲取管理員憑據(jù):
. admin-openrc
3、創(chuàng)建服務(wù)憑證
完成以下步驟以創(chuàng)建 Cinder 服務(wù)憑證:
創(chuàng)建用戶 “cinder”:
openstack?user?create?--domain?default?--password-prompt?cinder User?Password: Repeat?User?Password: +---------------------+----------------------------------+ |?Field???????????????|?Value????????????????????????????| +---------------------+----------------------------------+ |?domain_id???????????|?default??????????????????????????| |?enabled?????????????|?True?????????????????????????????| |?id??????????????????|?9d7e33de3e1a498390353819bc7d245d?| |?name????????????????|?cinder???????????????????????????| |?options?????????????|?{}???????????????????????????????| |?password_expires_at?|?None?????????????????????????????| +---------------------+----------------------------------+
輸入用戶密碼并確認(rèn)。
將角色 “admin” 添加到用戶 “cinder”:
openstack role add --project service --user cinder admin
注意:此命令執(zhí)行后不會(huì)提供任何輸出。
創(chuàng)建服務(wù)實(shí)體 “cinderv3″:
openstack?service?create?--name?cinderv3?\ ??--description?"OpenStack?Block?Storage"?volumev3 +-------------+----------------------------------+ |?Field???????|?Value????????????????????????????| +-------------+----------------------------------+ |?description?|?OpenStack?Block?Storage??????????| |?enabled?????|?True?????????????????????????????| |?id??????????|?ab3bbbef780845a1a283490d281e7fda?| |?name????????|?cinderv3?????????????????????????| |?type????????|?volumev3?????????????????????????| +-------------+----------------------------------+
注意:從 Xena 版本開始,塊存儲(chǔ)服務(wù)僅需要一個(gè)服務(wù)實(shí)體。對于以前的版本,請查看該特定版本的文檔。
4、創(chuàng)建 Block Storage 服務(wù) API 端點(diǎn):
openstack?endpoint?create?--region?RegionOne?\ ??volumev3?public?http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ |?Field????????|?Value????????????????????????????????????| +--------------+------------------------------------------+ |?enabled??????|?True?????????????????????????????????????| |?id???????????|?03fa2c90153546c295bf30ca86b1344b?????????| |?interface????|?public???????????????????????????????????| |?region???????|?RegionOne????????????????????????????????| |?region_id????|?RegionOne????????????????????????????????| |?service_id???|?ab3bbbef780845a1a283490d281e7fda?????????| |?service_name?|?cinderv3?????????????????????????????????| |?service_type?|?volumev3?????????????????????????????????| |?url??????????|?http://controller:8776/v3/%(project_id)s?| +--------------+------------------------------------------+ $?openstack?endpoint?create?--region?RegionOne?\ ??volumev3?internal?http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ |?Field????????|?Value????????????????????????????????????| +--------------+------------------------------------------+ |?enabled??????|?True?????????????????????????????????????| |?id???????????|?94f684395d1b41068c70e4ecb11364b2?????????| |?interface????|?internal?????????????????????????????????| |?region???????|?RegionOne????????????????????????????????| |?region_id????|?RegionOne????????????????????????????????| |?service_id???|?ab3bbbef780845a1a283490d281e7fda?????????| |?service_name?|?cinderv3?????????????????????????????????| |?service_type?|?volumev3?????????????????????????????????| |?url??????????|?http://controller:8776/v3/%(project_id)s?| +--------------+------------------------------------------+ $?openstack?endpoint?create?--region?RegionOne?\ ??volumev3?admin?http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ |?Field????????|?Value????????????????????????????????????| +--------------+------------------------------------------+ |?enabled??????|?True?????????????????????????????????????| |?id???????????|?4511c28a0f9840c78bacb25f10f62c98?????????| |?interface????|?admin????????????????????????????????????| |?region???????|?RegionOne????????????????????????????????| |?region_id????|?RegionOne????????????????????????????????| |?service_id???|?ab3bbbef780845a1a283490d281e7fda?????????| |?service_name?|?cinderv3?????????????????????????????????| |?service_type?|?volumev3?????????????????????????????????| |?url??????????|?http://controller:8776/v3/%(project_id)s?| +--------------+------------------------------------------+
二、安裝和配置組件
1、安裝所需軟件包:
zypper install openstack-cinder-api openstack-cinder-scheduler
2、編輯配置文件 “/etc/cinder/cinder.conf”,并完成以下部分:
配置數(shù)據(jù)庫訪問:
[database] # ... connection = mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder
替換 “CINDER_DBPASS” 為為 Block Storage 數(shù)據(jù)庫設(shè)置的密碼。
配置消息隊(duì)列訪問:
[DEFAULT] # ... transport_url = rabbit://openstack:RABBIT_PASS@controller
替換 “RABBIT_PASS” 為在 RabbitMQ 中為 “openstack” 帳戶選擇的密碼。
配置 Identity Service 訪問:
[DEFAULT] # ... auth_strategy = keystone [keystone_authtoken] # ... www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = cinder password = CINDER_PASS
替換 “CINDER_PASS” 為 Identity 服務(wù)中的用戶 “cinder” 的密碼。
注意:請確保注釋掉或刪除 “[keystone_authtoken]” 部分中的任何其他選項(xiàng)。
配置控制器節(jié)點(diǎn)的管理接口 IP 地址:
[DEFAULT] # ... my_ip = 10.0.0.11
配置鎖定路徑:
[oslo_concurrency] # ... lock_path = /var/lib/cinder/tmp
三、配置Compute以使用Block Storage
編輯文件 “/etc/nova/nova.conf” 并添加以下內(nèi)容:
[cinder] os_region_name = RegionOne
四、完成安裝
1、重新啟動(dòng) Compute API 服務(wù):
systemctl restart openstack-nova-api.service
2、啟動(dòng) Block Storage 服務(wù)并將其配置為在系統(tǒng)啟動(dòng)時(shí)自動(dòng)啟動(dòng):
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service