天天看點

openstack queens版本 環境搭建(十):安裝cinder塊存儲服務

目錄

安裝和配置(控制節點)

先決條件

安裝和配置元件

完成安裝

安裝和配置(備份服務)

安裝和配置(塊存儲節點)

先決條件

安裝和配置元件

完成安裝

結束安裝并驗證

OpenStack塊存儲服務(Cinder)将持久性存儲添加到虛拟機。塊存儲為管理卷提供基礎架構,并與OpenStack Compute進行互動以提供執行個體卷。該服務還支援管理卷快照和卷類型。

安裝和配置(控制節點)

先決條件

初始化資料庫,建立cinder使用者、cinder 資料庫

# su - xiao

$ mysql -u root -p

CREATE DATABASE cinder;

GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \

  IDENTIFIED BY 'CINDER_DBPASS';

GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \

  IDENTIFIED BY 'CINDER_DBPASS';

##驗證

select host,user from mysql.user where user like '%cinder%';

MariaDB [(none)]> exit

建立cinder使用者

$ . /etc/openstack/admin-openrc

openstack user create --domain default --password-prompt cinder

User Password:你的密碼

将admin角色綁定給cinder使用者

openstack role add --project service --user cinder admin

##驗證

openstack role assignment list

建立cinderv2和cinderv3兩個服務執行個體

openstack service create --name cinderv2 \

  --description "OpenStack Block Storage" volumev2

openstack service create --name cinderv3 \

  --description "OpenStack Block Storage" volumev3

##驗證

openstack service list |grep cinder

建立cinder服務的endpoint(cinderv2和v3都要建立)

openstack endpoint create --region RegionOne \

  volumev2 public http://controller-150:8776/v2/%\(project_id\)s

openstack endpoint create --region RegionOne \

  volumev2 internal http://controller-150:8776/v2/%\(project_id\)s

openstack endpoint create --region RegionOne \

  volumev2 admin http://controller-150:8776/v2/%\(project_id\)s



openstack endpoint create --region RegionOne \

  volumev3 public http://controller-150:8776/v3/%\(project_id\)s

openstack endpoint create --region RegionOne \

  volumev3 internal http://controller-150:8776/v3/%\(project_id\)s

openstack endpoint create --region RegionOne \

  volumev3 admin http://controller-150:8776/v3/%\(project_id\)s
           

##驗證

openstack endpoint list --service cinderv2

openstack endpoint list --service cinderv3

安裝和配置元件

安裝元件

yum install openstack-cinder -y

配置元件

vi /etc/cinder/cinder.conf

[DEFAULT]

my_ip使用管理接口ip位址

# ...

transport_url = rabbit://openstack:RABBIT_PASS@controller-150

auth_strategy = keystone

my_ip = 192.168.11.150

[database]

# ...

connection = mysql+pymysql://cinder:CINDER_DBPASS@controller-150/cinder

[keystone_authtoken]

auth_uri已經被棄用,使用www_authenticate_uri替代

# ...

www_authenticate_uri = http://controller-150:5000

auth_url = http://controller-150:5000

memcached_servers = controller-150:11211

auth_type = password

project_domain_id = default

user_domain_id = default

project_name = service

username = cinder

password = 你的密碼

[oslo_concurrency]

# ...

lock_path = /var/lib/cinder/tmp

導入資料到cinder資料庫

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

--忽略deprecation資訊

配置compute服務使用block存儲

vi /etc/nova/nova.conf

[cinder]

os_region_name = RegionOne

完成安裝

重新開機compute服務

systemctl restart openstack-nova-api.service && systemctl status 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 status openstack-cinder-api.service openstack-cinder-scheduler.service

添加防火牆政策

cinder-api: 8776

# firewall-cmd --add-port 8776/tcp --permanent

# firewall-cmd --reload && firewall-cmd --list-port

具體參見:

https://docs.openstack.org/cinder/queens/install/cinder-controller-install-rdo.html

安裝和配置(備份服務)

具體參見:

https://docs.openstack.org/cinder/queens/install/index-rdo.html

安裝和配置(塊存儲節點)

先決條件

安裝支援的工具包(LVM)

如果安裝作業系統使用LVM分區,預設會安裝并運作下面的服務

yum install lvm2 device-mapper-persistent-data -y

# systemctl enable lvm2-lvmetad.service

# systemctl start lvm2-lvmetad.service

建立LVM實體卷、卷組(要求在做OS時就要挂載一個塊空的磁盤)

# lsblk –l

sdb       8:16   0    1T  0 disk

# pvcreate /dev/sdb

  Physical volume "/dev/sdb" successfully created.

# vgcreate cinder-volumes /dev/sdb

Block服務将在cinder-volumes VG下建立LV。

重要内容來襲

編輯vi /etc/lvm/lvm.conf   重新定義filter,避免lvm掃描器将底層作業系統的block裝置掃描出來,被instance使用。這将導緻底層操系統崩潰。

devices {

...

filter = [ "a/sdb/", "r/.*/"]

以a開頭接受,以r/.*/結束以拒絕剩餘的所有裝置。

注意:

如果compute節點使用了LVM,如果os在/dev/sda上,需要在計算節點上配置如下内容

filter = [ "a/sda/", "r/.*/"]

到vi /etc/lvm/lvm.conf

如果block節點上使用了LVM,如果os在/dev/sda上,那麼上面的filter需要修改成下面的:

filter = [ "a/sda/", "a/sdb/", "r/.*/"]

安裝和配置元件

安裝軟體包

yum install openstack-cinder targetcli python-keystone -y

配置元件

vi /etc/cinder/cinder.conf

[DEFAULT]

# ...MANAGEMENT_INTERFACE_IP_ADDRESS使用block節點的管理IP

transport_url = rabbit://openstack:RABBIT_PASS@controller-150

auth_strategy = keystone

my_ip = 192.168.11.152

enabled_backends = lvm

glance_api_servers = http://controller-150:9292

[database]

# ...

connection = mysql+pymysql://cinder:CINDER_DBPASS@controller-150/cinder

[keystone_authtoken]

# ...auth_uri 被www_authenticate_uri替代了

www_authenticate_uri = http://controller-150:5000

auth_url = http://controller-150:5000

memcached_servers = controller-150:11211

auth_type = password

project_domain_id = default

user_domain_id = default

project_name = service

username = cinder

password = 你的密碼

If the [lvm] section does not exist, create it:

[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

完成安裝

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

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

# systemctl status openstack-cinder-volume.service target.service

具體參見:

https://docs.openstack.org/cinder/queens/install/cinder-storage-install-rdo.html

結束安裝并驗證

$ . /etc/openstack/admin-openrc

$ openstack volume service list

openstack queens版本 環境搭建(十):安裝cinder塊存儲服務

具體參見:

https://docs.openstack.org/cinder/queens/install/index-rdo.html

繼續閱讀