1. 程式人生 > >OpenStack—M Cinder(塊儲存服務)

OpenStack—M Cinder(塊儲存服務)

一、 資料庫配置

Controller節點

# mysql -uroot -p123456
MariaDB [(none)]> create database cinder;
MariaDB [(none)]> grant all privileges on cinder.* to 'cinder'@'localhost' identified by '123456';
MariaDB [(none)]> grant all privileges on cinder.* to 'cinder'@'%' identified by '123456';
MariaDB [(none)]> exit

二、 建立服務憑證和API端點

Controller節點

1.生效環境變數

# . admin-openrc

2.建立服務憑證

# openstack user create --domain default --password-prompt cinder
# openstack role add --project service --user cinder admin
# openstack service create --name cinder --description "OpenStack Block Storage" volume
# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2

在這裡插入圖片描述 3. 建立API端點

# openstack endpoint create --region RegionOne volume public 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 volume internal http://controller:8776/v1/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(tenant_id\)s

在這裡插入圖片描述

# openstack endpoint create --region RegionOne volume admin http://controller:8776/v1/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(tenant_id\)s

在這裡插入圖片描述

三、 安裝並配置Cinder元件

Controller節點

1.安裝Cinder元件所需軟體包

# yum install -y openstack-cinder

2.配置Cinder所需元件 編輯/etc/cinder/cinder.conf檔案

# vi /etc/cinder/cinder.conf
[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 192.168.100.10

[database]
connection = mysql+pymysql://cinder:[email protected]/cinder

[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = 123456

[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 = 123456

[oslo_concurrency]
lock_path = /var/lib/cinder/tmp

3.同步資料庫

# su -s /bin/sh -c "cinder-manage db sync" cinder

:Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A 表示有資料表,同步資料庫成功 在這裡插入圖片描述 4.配置Nova服務使用Cinder 編輯/etc/nova/nova.conf檔案

# vi /etc/nova/nova.conf
[cinder]
os_region_name = RegionOne

5.啟動Cinder服務並設定開機自啟

# systemctl restart openstack-nova-api.service
# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
# systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service

四、安裝配置儲存節點

Compute節點

1.安裝並啟動lvm2

# yum install -y lvm2
# systemctl enable lvm2-lvmetad.service
# systemctl start lvm2-lvmetad.service

2.新增一塊10G的虛擬硬碟 1)點選Compute節點的虛擬機器設定—新增—硬碟—下一步 在這裡插入圖片描述 2)選擇SCSI—下一步 在這裡插入圖片描述 3)選擇“建立新虛擬磁碟”—下一步 在這裡插入圖片描述 4)磁碟大小選擇10G 在這裡插入圖片描述 5)下一步—完成,新增後需重啟虛擬機器

# reboot

3.檢視虛擬硬碟是否新增 :/dev/sdb為我們所新增的硬碟

# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb

4.建立物理卷/dev/sdb

# pvcreate /dev/sdb

5.建立卷組cinder-volumes

# pvcreate /dev/sdb

6.檢視磁碟

# fdisk -l

在這裡插入圖片描述 6.配置lvm2元件 編輯/etc/lvm/lvm.conf檔案 編輯# Configuration section devices部分

# vi /etc/lvm/lvm.conf
devices {
...
#新增
filter = [ "a/sdb","r/.*/" ]

7.安裝並配置元件 1)安裝Cinder元件所需軟體包

# yum install -y openstack-cinder targetcli python-keystone

2)配置Cinder所需元件 編輯/etc/cinder/cinder.conf檔案

# vi /etc/cinder/cinder.conf
[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 192.168.100.20
enabled_backends = lvm
glance_api_servers = http://controller:9292

[database]
connection = mysql+pymysql://cinder:[email protected]/cinder

[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = 123456

[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 = 123456

[oslo_concurrency]
lock_path = /var/lib/cinder/tmp

若配置檔案中沒有[lvm]選項,則需自己新增

[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm

在這裡插入圖片描述 8.啟動Cinder服務並設定開機自啟

# systemctl enable openstack-cinder-volume.service target.service
# systemctl start openstack-cinder-volume.service target.service

五、驗證Cinder服務

Controller節點

# . admin-openrc
# cinder service-list

在這裡插入圖片描述

# cinder create --display-name myVolume 1
# cinder list

在這裡插入圖片描述