1. 程式人生 > >Openstack(十七)部署快存儲cinder

Openstack(十七)部署快存儲cinder

添加 true oslo 卸載 驅動 username 登錄 uid st2

官方部署文檔:https://docs.openstack.org/ocata/zh_CN/install-guide-rdo/cinder.html

OpenStack的存儲組件—Cinder和Swift—讓你在你的私有雲裏構建塊存儲和對象的存儲系統,Openstack從Folsom開始使用Cinder替換原來的Nova-Volume服務,為Openstack雲平臺提供塊存儲服務,Cinder接口提供了一些標準功能,允許創建和附加塊設備到虛擬機,如“創建卷”,“刪除卷”和“附加卷”。還有更多高級的功能,支持擴展容量的能力,快照和創建虛擬機鏡像克隆,主要涉及到的組件如下:

cinder-api:接受API請求,並將其路由到“cinder-volume“執行,即請求cinder要先請求此對外API。

cinder-volume:與塊存儲服務和例如“cinder-scheduler“的進程進行直接交互。它也可以與這些進程通過一個消息隊列進行交互。“cinder-volume“服務響應送到塊存儲服務的讀寫請求來維持狀態。它也可以和多種存儲提供者在驅動架構下進行交互。

cinder-scheduler守護進程:選擇最優存儲提供節點來創建卷。其與“nova-scheduler“組件類似。

cinder-backup守護進程:“cinder-backup“服務提供任何種類備份卷到一個備份存儲提供者。就像“cinder-volume“服務,它與多種存儲提供者在驅動架構下進行交互。

消息隊列:在塊存儲的進程之間路由信息。

17.1創建cinder數據庫

# mysql -uroot –p

> CREATE DATABASE cinder;

> GRANT ALL PRIVILEGES ON cinder.* TO ‘cinder‘@‘%‘ IDENTIFIED BY ‘cinde

r123‘;

> flush privileges;

17.2控制端數據訪問驗證

# mysql -ucinder -h192.168.10.100 -pcinder123

技術分享圖片

17.3控制端cinder服務註冊

17.3.1創建cinder用戶並授權

# source admin-ocata.sh

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

User Password:

Repeat User Password:

+---------------------+----------------------------------+

| Field | Value |

+---------------------+----------------------------------+

| domain_id | 81672c29064942aea8fb754820ddb76a |

| enabled | True |

| id | f12af1d5583e4b179354c3b4d8d0d778 |

| name | cinder |

| options | {} |

| password_expires_at | None |

+---------------------+----------------------------------+

#授權admin權限

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

17.3.2創建服務

# v2,v3版本創建

# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2

# v2,v3版本創建

# openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3

17.3.3註冊V2版本endpoint

#公共端點:

# openstack endpoint create --region RegionOne volumev2 public http://192.168.10.100:8776/v2/%\(project_id\)s

+--------------+----------------------------------------------+

| Field | Value |

+--------------+----------------------------------------------+

| enabled | True |

| id | cf87da53a7754996972b7ef2baf73933 |

| interface | public |

| region | RegionOne |

| region_id | RegionOne |

| service_id | 8077b7de84fc4b32a288306459bad10b |

| service_name | cinderv2 |

| service_type | volumev2 |

| url | http://192.168.10.100:8776/v2/%(project_id)s |

+--------------+----------------------------------------------+

#私有端點:

# openstack endpoint create --region RegionOne volumev2 internal http://192.168.10.100:8776/v2/%\(project_id\)s

+--------------+----------------------------------------------+

| Field | Value |

+--------------+----------------------------------------------+

| enabled | True |

| id | 4d8cfb82cd4a4015876df6aafc8bb219 |

| interface | internal |

| region | RegionOne |

| region_id | RegionOne |

| service_id | 8077b7de84fc4b32a288306459bad10b |

| service_name | cinderv2 |

| service_type | volumev2 |

| url | http://192.168.10.100:8776/v2/%(project_id)s |

+--------------+----------------------------------------------+

#管理端點:

# openstack endpoint create --region RegionOne volumev2 admin http://192.168.10.100:8776/v2/%\(project_id\)s

+--------------+----------------------------------------------+

| Field | Value |

+--------------+----------------------------------------------+

| enabled | True |

| id | 686d554b483a4a52b36c6b6a6c3a2feb |

| interface | admin |

| region | RegionOne |

| region_id | RegionOne |

| service_id | 8077b7de84fc4b32a288306459bad10b |

| service_name | cinderv2 |

| service_type | volumev2 |

| url | http://192.168.10.100:8776/v2/%(project_id)s |

+--------------+----------------------------------------------+

17.3.4註冊V3版本endpoint

#公共端點:

# openstack endpoint create --region RegionOne volumev3 public http://192.168.10.100:8776/v3/%\(project_id\)s

+--------------+----------------------------------------------+

| Field | Value |

+--------------+----------------------------------------------+

| enabled | True |

| id | 729e23316e964ff6bc6315f4d95e590a |

| interface | public |

| region | RegionOne |

| region_id | RegionOne |

| service_id | 4234b69629ac4e6bbabcd72c8bb0ab81 |

| service_name | cinderv3 |

| service_type | volumev3 |

| url | http://192.168.10.100:8776/v3/%(project_id)s |

+--------------+----------------------------------------------+

#私有端點:

# openstack endpoint create --region RegionOne volumev3 internal http://192.168.10.100:8776/v3/%\(project_id\)s

+--------------+----------------------------------------------+

| Field | Value |

+--------------+----------------------------------------------+

| enabled | True |

| id | 0541cfdf2d99477fb4105aac045f0399 |

| interface | internal |

| region | RegionOne |

| region_id | RegionOne |

| service_id | 4234b69629ac4e6bbabcd72c8bb0ab81 |

| service_name | cinderv3 |

| service_type | volumev3 |

| url | http://192.168.10.100:8776/v3/%(project_id)s |

+--------------+----------------------------------------------+

#管理端點:

# openstack endpoint create --region RegionOne volumev3 admin http://192.168.10.100:8776/v3/%\(project_id\)s

+--------------+----------------------------------------------+

| Field | Value |

+--------------+----------------------------------------------+

| enabled | True |

| id | 3b45ed17bb724479a49df89e49a0e2ae |

| interface | admin |

| region | RegionOne |

| region_id | RegionOne |

| service_id | 4234b69629ac4e6bbabcd72c8bb0ab81 |

| service_name | cinderv3 |

| service_type | volumev3 |

| url | http://192.168.10.100:8776/v3/%(project_id)s |

+--------------+----------------------------------------------+

17.4配置haproxy負載

# vim /etc/haproxy/haproxy.cfg

listen cinder

bind 192.168.10.100:8776

mode tcp

log global

balance source

server cinder-server 192.168.10.201:8776 check inter 5000 rise 3 fall 3

# systemctl reload haproxy.service

17.5安裝並配置cinder組件

17.5.1控制端安裝cinder

# yum install openstack-cinder –y

17.5.2編輯配置文件cinder.conf

# vim /etc/cinder/cinder.conf

1:[DEFAULT]

263:my_ip = 192.168.10.201

376:auth_strategy = keystone

3243:transport_url = rabbit://openstack:[email protected]

3518:[database]

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

3767:[keystone_authtoken]

3768:auth_uri = http://192.168.10.100:5000

3769:auth_url = http://192.168.10.100:35357

3770:memcached_servers = 192.168.10.100:11211

3771:auth_type = password

3772:project_domain_name = default

3773:user_domain_name = default

3774:project_name = service

3775:username = cinder

3776:password = cinder

3996:[oslo_concurrency]

4012:lock_path = /var/lib/cinder/tmp

17.5.3同步並驗證數據庫

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

17.5.4驗證數據庫同步成功

# mysql -ucinder -h192.168.10.100 -pcinder123

技術分享圖片

17.5.5控制端重啟nova-api服務

# systemctl restart openstack-nova-api.service

17.5.6啟動塊存儲服務cinder

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

# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service

17.5.7驗證cinder日誌

# tail -f /var/log/cinder/*.log

技術分享圖片

17.6配置計算節點使用cinder存儲

17.6.1編輯配置文件nova.conf

# vim /etc/nova/nova.conf

3982 [cinder]

4031 os_region_name=RegionOne

17.6.2重啟nova服務

# systemctl restart libvirtd.service openstack-nova-compute.service

17.6.3驗證cinder控制端

# openstack volume service list

技術分享圖片

17.7配置存儲節點

17.7.1添加磁盤

在負載服務器(或其他指定服務器)新添加一塊50G的磁盤然後點確定:

技術分享圖片

17.7.2安裝LVM包

# yum install lvm2 –y

17.7.3啟動LVM並設置為開機啟動

# systemctl enable lvm2-lvmetad.service

# systemctl start lvm2-lvmetad.service

17.7.4動態識別新磁盤

# ll /sys/class/scsi_host/host

host0/ host1/ host2/

# echo "- - -" > /sys/class/scsi_host/host0/scan

# echo "- - -" > /sys/class/scsi_host/host1/scan

# echo "- - -" > /sys/class/scsi_host/host2/scan

17.7.5驗證磁盤

#fdisk -l

技術分享圖片

17.7.6創建物理卷和卷組

# pvcreate /dev/sdb

Physical volume "/dev/sdb" successfully created.

# vgcreate cinder-volumes /dev/sdb

Volume group "cinder-volumes" successfully created

17.8存儲安裝並配置組件

在負載服務器安裝配置

17.8.1安裝組件

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

17.8.2編輯配置文件cinder.conf

# vim /etc/cinder/cinder.conf

1:[DEFAULT]

283:my_ip = 192.168.10.205

288:glance_api_servers = http://192.168.10.100:9292

400:auth_strategy = keystone

404:enabled_backends = lvm

1210:transport_url = rabbit://openstack:[email protected]

3730:[database]

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

3973:[keystone_authtoken]

3974:auth_uri = http://192.168.10.100:5000

3975:auth_url = http://192.168.10.100:35357

3976:memcached_servers = 192.168.10.100:11211

3977:auth_type = password

3978:project_domain_name = default

3979:user_domain_name = default

3980:project_name = service

3981:username = cinder

3982:password = cinder

4249:[oslo_concurrency]

4263:lock_path = /var/lib/cinder/tmp

4904:[lvm]

4905:volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver

4906:volume_group = cinder-volumes

4907:iscsi_protocol = iscsi

4908:iscsi_helper = lioadm

4909:volume_backend_name=Openstack-lvm

17.8.3啟動服務並設置為開機啟動

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

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

17.8.4驗證日誌

技術分享圖片

17.8.5控制端驗證cinder註冊

# openstack volume service list

技術分享圖片

17.9驗證卷使用

17.9.1創建卷

使用admin或者demo用戶登錄到管理界面,點擊卷—創建卷:

技術分享圖片

17.9.2填寫卷信息

技術分享圖片

17.9.3查看卷狀態

技術分享圖片

17.9.4關聯到虛擬機

技術分享圖片

17.9.5關聯到目標虛擬機

技術分享圖片

17.9.6連接後的卷狀態

技術分享圖片

17.9.7虛擬機驗證磁盤

技術分享圖片

17.9.8格式化磁盤

# mkfs.ext4 /dev/vdb

技術分享圖片

17.9.9掛載磁盤並復制數據

技術分享圖片

17.9.10磁盤掛載至其他虛擬機

新創建一個虛擬機,用於將上一步關聯的卷分離後掛載到新的虛擬機上進行測試。

17.9.10.1卸載卷

在之前的虛擬機將卷卸載。

技術分享圖片

17.9.10.2磁盤分離

點擊項目-卷-管理連接:

技術分享圖片

17.9.10.3分離卷

技術分享圖片

17.9.10.4確認分離

技術分享圖片

17.9.10.5掛載至新實例

在管理連接界面,將卷關聯至test-vm2:

技術分享圖片

17.9.10.6關聯成功

技術分享圖片

17.9.10.7新實例驗證磁盤

驗證可以掛載關聯的磁盤並可以查看之前的數據

技術分享圖片

Openstack(十七)部署快存儲cinder