1.創建存儲池
在ceph節點中執行如下語句。
#ceph osd pool create volumes 128
2.配置 OPENSTACK 的 CEPH 客戶端
在ceph節點兩次執行如下語句,兩次{your-openstack-server}分別填控制節點和計算節點IP。
如果顯示在控制節點和計算節點中沒有ceph文件夾,則在兩節點中創建對應文件夾。
#ssh {your-openstack-server} sudo tee /etc/ceph/ceph.conf < /etc/ceph/ceph.conf
3.安裝 CEPH 客戶端軟件包
控制節點上進行librbd的 Python 綁定
#yum install python-rbd
計算節點和控制節點進行安裝 Python 綁定和客戶端命令行工具
#yum install ceph-common
#yum install ceph
4.配置 CEPH 客戶端認證
在ceph節點為Cinder創建新用戶
#ceph auth get-or-create client.cinder mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=volumes'
在ceph節點把 client.cinder的密鑰環復制到控制節點,並更改所有權,{your-volume-server}和{your-cinder-volume-server}處填控制節點IP。
#ceph auth get-or-create client.cinder | ssh {your-volume-server} sudo tee /etc/ceph/ceph.client.cinder.keyring #ssh {your-cinder-volume-server} sudo chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring
在ceph節點執行如下語句{your-nova-compute-server}為計算節點IP。
#ceph auth get-or-create client.cinder | ssh {your-nova-compute-server} sudo tee /etc/ceph/ceph.client.cinder.keyring
在ceph節點把client.cinder用戶的密鑰存進libvirt。libvirt 進程從 Cinder 掛載塊設備時要用它訪問集群,在運行 nova-compute 的節點上創建一個密鑰的臨時副本。
{your-compute-node}為計算節點IP。
#ceph auth get-key client.cinder | ssh {your-compute-node} tee /etc/ceph/client.cinder.key
在計算節點上執行如下語句,把密鑰加進 libvirt 、然后刪除臨時副本。
#uuidgen
記錄下產生的數字,將下面的UUIDGEN替換為該數字,並在計算節點執行下列語句
cat > secret.xml <<EOF <secret ephemeral='no' private='no'> <uuid>UUIDGEN</uuid> <usage type='ceph'> <name>client.cinder secret</name> </usage> </secret> EOF
#sudo virsh secret-define --file secret.xml #sudo virsh secret-set-value --secret 457eb676-33da-42ec-9a8c-9293d545c337 --base64 $(cat client.cinder.key) && rm client.cinder.key secret.xml
執行完后,記錄好上面產生的uuidgen,下面還會用到。
5.安裝並配置控制節點
5.1先決條件
在控制節點完成下面的步驟以創建數據庫:
用數據庫連接客戶端以 root 用戶連接到數據庫服務器:
#mysql -u root -p
創建cinde數據庫
#CREATE DATABASE cinder;
配置 cinder 數據庫的訪問權限,下列CINDER_DBPASS用合適的密碼替換。
#GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \ IDENTIFIED BY 'CINDER_DBPASS'; #GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \ IDENTIFIED BY 'CINDER_DBPASS';
退出數據庫。
獲得 admin 憑證來獲取只有管理員能執行的命令的訪問權限:
# . admin-openrc
創建服務證書:
創建一個 cinder 用戶:
#openstack user create --domain default --password-prompt cinder
添加 admin 角色到 cinder 用戶上。
#openstack role add --project service --user cinder admin
創建 cinder 和 cinderv2 服務實體:
#openstack service create --name cinder \ --description "OpenStack Block Storage" volume #openstack service create --name cinderv2 \ --description "OpenStack Block Storage" volumev2
創建塊設備存儲服務的 API 入口點:
#openstack endpoint create --region RegionOne \ volume public http://controller:8776/v1/%\(tenant_id\)s #openstack endpoint create --region RegionOne \ volume internal http://controller:8776/v1/%\(tenant_id\)s #openstack endpoint create --region RegionOne \ volume admin http://controller:8776/v1/%\(tenant_id\)s #openstack endpoint create --region RegionOne \ volumev2 public http://controller:8776/v2/%\(tenant_id\)s #openstack endpoint create --region RegionOne \ volumev2 internal http://controller:8776/v2/%\(tenant_id\)s #openstack endpoint create --region RegionOne \ volumev2 admin http://controller:8776/v2/%\(tenant_id\)s
5.2安裝並配置組件
安裝軟件包
# yum install openstack-cinder
#yum install openstack-cinder targetcli python-keystone
在控制節點上編輯cinder.conf。
#vi /etc/cinder/cinder.conf
添加如下內容:
注意:
1.如果你為 cinder 配置了多后端, [DEFAULT] 節中必須有 glance_api_version = 2
2.[ceph]中的rbd_secret_uuid后面對應填的剛剛記錄的uuid。
[DEFAULT] transport_url = rabbit://openstack:RABBIT_PASS@controller auth_strategy = keystone my_ip = 控制節點管理網絡的IP enabled_backends = ceph glance_api_servers = http://controller:9292 [database] connection = mysql+pymysql://cinder:CINDER_PASS@controller/cinder [keystone_authtoken] auth_uri = http://controller:5000 auth_url = http://controller:35357 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = cinder password = CINDER_PASS [oslo_concurrency] lock_path = /var/lib/cinder/tmp [ceph] volume_driver = cinder.volume.drivers.rbd.RBDDriver rbd_pool = volumes rbd_ceph_conf = /etc/ceph/ceph.conf rbd_flatten_volume_from_snapshot = false rbd_max_clone_depth = 5 rbd_store_chunk_size = 4 rados_connect_timeout = -1 glance_api_version = 2 rbd_user = cinder rbd_secret_uuid = a852df2b-55e1-4c1b-9fa2-61e77feaf30f
編輯/etc/nova/nova.conf 添加如下內容:
[cinder]
os_region_name = RegionOne
6.重啟 OPENSTACK
在控制節點重啟計算API 服務:
# systemctl restart openstack-nova-api.service
啟動塊設備存儲服務,並將其配置為開機自啟:
# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
啟動塊存儲卷服務及其依賴的服務,並將其配置為隨系統啟動:
# systemctl enable openstack-cinder-volume.service target.service
# systemctl start openstack-cinder-volume.service target.service
7.驗證
在控制節點獲得 admin 憑證來獲取只有管理員能執行的命令的訪問權限:
# . admin-openrc
列出服務組件以驗證是否每個進程都成功啟動:
# cinder service-list
並且登錄界面后可以創建卷