OpenStack Block Storage服務(Cinder)將持久存儲添加到虛擬機。塊存儲提供用於管理卷的基礎結構,並與OpenStack Compute交互以為實例提供卷。該服務還可以管理卷快照和卷類型。
塊存儲服務包含以下組件:
- cinderAPI
-
接受API請求,並將它們路由到
cinder-volumefor操作。 - cinder卷
-
直接與Block Storage服務以及諸如之后的進程交互
cinder-scheduler。它還通過消息隊列與這些進程交互。該cinder-volume服務響應發送到塊存儲服務的讀寫請求以維持狀態。它可以通過驅動程序體系結構與各種存儲提供程序進行交互。 - cinder-scheduler守護進程
-
選擇要在其上創建卷的最佳存儲提供程序節點。一個類似的組成部分
nova-scheduler。 - cinder-backup守護進程
-
該
cinder-backup服務為備份存儲提供程序提供任何類型的備份卷。與cinder-volume服務一樣,它可以通過驅動程序體系結構與各種存儲提供程序進行交互。 - 消息隊列
- 消息隊列在塊存儲進程之間路由信息。
- 我們需要在存儲節點添加一塊硬盤sdb
- 我們先配置控制節點
- 1.創建cinder數據庫;
mysql> CREATE DATABASE cinder; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \ -> IDENTIFIED BY '123'; Query OK, 0 rows affected, 1 warning (0.15 sec) mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \ -> IDENTIFIED BY '123'; Query OK, 0 rows affected, 1 warning (0.00 sec)
2.創建cinder用戶;
[root@sxb1 ~]# openstack user create --domain default --password-prompt cinder User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | c14cbc9906274a968452fbe7a3f67474 | | name | cinder | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
3.將admin角色添加到cinder用戶;
[root@sxb1 ~]# openstack role add --project service --user cinder admin
4.創建cinder服務cinderv2、cinderv3(因為有兩個版本);
[root@sxb1 ~]# openstack service create --name cinderv2 \ > --description "OpenStack Block Storage" volumev2 +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Block Storage | | enabled | True | | id | 049c3b344b134b5695a7223658a0c625 | | name | cinderv2 | | type | volumev2 | +-------------+----------------------------------+
[root@sxb1 ~]# openstack service create --name cinderv3 \ > --description "OpenStack Block Storage" volumev3 +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Block Storage | | enabled | True | | id | 896ebdd517f44b45bc9c5beb9e7e3192 | | name | cinderv3 | | type | volumev3 | +-------------+----------------------------------+
5.創建Block Storage服務API端點;
卷2
[root@sxb1 ~]# openstack endpoint create --region RegionOne volumev2 public http://192.168.88.101:8776/v2/%\(project_id\)s^C [root@sxb1 ~]# openstack endpoint create --region RegionOne volumev2 internal http://192.168.88.101:8776/v2/%\(project_id\)s^C [root@sxb1 ~]# openstack endpoint create --region RegionOne volumev2 admin http://192.168.88.101:8776/v2/%\(project_id\)s
卷3
[root@sxb1 ~]# openstack endpoint create --region RegionOne volumev3 public http://192.168.88.101:8776/v3/%\(project_id\)s^C [root@sxb1 ~]# openstack endpoint create --region RegionOne volumev3 internal http://192.168.88.101:8776/v3/%\(project_id\)s^C [root@sxb1 ~]# openstack endpoint create --region RegionOne volumev3 admin http://192.168.88.101:8776/v3/%\(project_id\)s
6.安裝cinder相關組件;
[root@sxb1 ~]# yum install openstack-cinder -y
7.配置cinder文件;
[root@sxb1 ~]# vim /etc/cinder/cinder.conf [DEFAULT] transport_url = rabbit://openstack:123@192.168.88.101 auth_strategy = keystone [database] connection = mysql+pymysql://cinder:123@192.168.88.101/cinder [keystone_authtoken] www_authenticate_uri = http://192.168.88.101:5000 auth_url = http://192.168.88.101:5000 memcached_servers = 192.168.88.101:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = cinder password = 123 [oslo_concurrency] lock_path = /var/lib/cinder/tmp
8.初始化數據庫(返回信息不用管);
[root@sxb1 ~]# su -s /bin/sh -c "cinder-manage db sync" cinder Deprecated: Option "logdir" from group "DEFAULT" is deprecated. Use option "log-dir" from group "DEFAULT".
9.配置nova文件;
[root@sxb1 ~]# vim /etc/nova/nova.conf
[cinder]
os_region_name = RegionOne
10.重啟nova服務;
[root@sxb1 ~]# systemctl restart openstack-nova-api.service
11.啟動控制節點cinder服務(status查看服務狀態);
[root@sxb1 ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-cinder-api.service to /usr/lib/systemd/system/openstack-cinder-api.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-cinder-scheduler.service to /usr/lib/systemd/system/openstack-cinder-scheduler.service. [root@sxb1 ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
我們來配置存儲節點
1.安裝cinder相關組件;
[root@sxb3 ~]# yum install lvm2 device-mapper-persistent-data -y
2.啟動cinder服務;
[root@sxb3 ~]# systemctl enable lvm2-lvmetad.service [root@sxb3 ~]# systemctl start lvm2-lvmetad.service [root@sxb3 ~]# systemctl status lvm2-lvmetad.service ● lvm2-lvmetad.service - LVM2 metadata daemon Loaded: loaded (/usr/lib/systemd/system/lvm2-lvmetad.service; static; vendor preset: enabled) Active: active (running) since Mon 2019-09-09 07:28:32 EDT; 47min ago Docs: man:lvmetad(8) Main PID: 519 (lvmetad) CGroup: /system.slice/lvm2-lvmetad.service └─519 /usr/sbin/lvmetad -f Sep 09 07:28:32 sxb3.103.com systemd[1]: Started LVM2 metadata daemon.
3.創建一個LVM;
[root@sxb3 ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created. [root@sxb3 ~]# vgcreate cinder-volumes /dev/sdb Volume group "cinder-volumes" successfully created
4.配置lvm文件;
[root@sxb3 ~]# vim /etc/lvm/lvm.conf devices { filter = [ "a/sdb/", "r/.*/"]
5.安裝組件;
[root@sxb3 ~]# yum install openstack-cinder targetcli python-keystone -y
6.配置cinder文件;
[lvm] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-volumes target_protocol = iscsi target_helper = lioadm [DEFAULT] transport_url = rabbit://openstack:123@192.168.88.101 auth_strategy = keystone my_ip = 192.168.88.103 enabled_backends = lvm glance_api_servers = http://192.168.88.101:9292 [database] connection = mysql+pymysql://cinder:123@192.168.88.101/cinder [keystone_authtoken] www_authenticate_uri = http://192.168.88.101:5000 auth_url = http://192.168.88.101:5000 memcached_servers = 192.168.88.101:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = cinder password = 123 [oslo_concurrency] lock_path = /var/lib/cinder/tmp
7.啟動cinder服務(status查看服務狀態);
[root@sxb3 ~]# systemctl enable openstack-cinder-volume.service target.service Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-cinder-volume.service to /usr/lib/systemd/system/openstack-cinder-volume.service. Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service. [root@sxb3 ~]# systemctl start openstack-cinder-volume.service target.service [root@sxb3 ~]# systemctl status openstack-cinder-volume.service target.service ● openstack-cinder-volume.service - OpenStack Cinder Volume Server Loaded: loaded (/usr/lib/systemd/system/openstack-cinder-volume.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2019-09-09 08:53:33 EDT; 7s ago Main PID: 2592 (cinder-volume) CGroup: /system.slice/openstack-cinder-volume.service ├─2592 /usr/bin/python2 /usr/bin/cinder-volume --config-file /usr/sha... └─2631 /usr/bin/python2 /usr/bin/cinder-volume --config-file /usr/sha... Sep 09 08:53:33 sxb3.103.com systemd[1]: Started OpenStack Cinder Volume Server. Sep 09 08:53:37 sxb3.103.com cinder-volume[2592]: Deprecated: Option "logdir" f.... Sep 09 08:53:39 sxb3.103.com sudo[2632]: cinder : TTY=unknown ; PWD=/ ; USER...on Sep 09 08:53:39 sxb3.103.com sudo[2640]: cinder : TTY=unknown ; PWD=/ ; USER...es Sep 09 08:53:39 sxb3.103.com sudo[2649]: cinder : TTY=unknown ; PWD=/ ; USER...ol Sep 09 08:53:39 sxb3.103.com sudo[2658]: cinder : TTY=unknown ; PWD=/ ; USER...on Sep 09 08:53:40 sxb3.103.com sudo[2668]: cinder : TTY=unknown ; PWD=/ ; USER...es Sep 09 08:53:40 sxb3.103.com sudo[2677]: cinder : TTY=unknown ; PWD=/ ; USER...ol ● target.service - Restore LIO kernel target configuration Loaded: loaded (/usr/lib/systemd/system/target.service; enabled; vendor preset: disabled) Active: active (exited) since Mon 2019-09-09 08:53:33 EDT; 7s ago Process: 2593 ExecStart=/usr/bin/targetctl restore (code=exited, status=0/SUCCESS) Main PID: 2593 (code=exited, status=0/SUCCESS) Sep 09 08:53:33 sxb3.103.com systemd[1]: Starting Restore LIO kernel target co..... Sep 09 08:53:33 sxb3.103.com target[2593]: No saved config file at /etc/target/...g Sep 09 08:53:33 sxb3.103.com systemd[1]: Started Restore LIO kernel target con...n. Hint: Some lines were ellipsized, use -l to show in full.
驗證:
[root@sxb1 ~]# openstack volume service list +------------------+------------------+------+---------+-------+----------------------------+ | Binary | Host | Zone | Status | State | Updated At | +------------------+------------------+------+---------+-------+----------------------------+ | cinder-scheduler | sxb1.101.com | nova | enabled | up | 2019-09-09T13:31:14.000000 | | cinder-volume | sxb3.103.com@lvm | nova | enabled | up | 2019-09-09T13:31:18.000000 | +------------------+------------------+------+---------+-------+----------------------------+
