OpenStack—M Cinder(塊儲存服務)
阿新 • • 發佈:2018-12-19
一、 資料庫配置
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