Openstack(十七)部署快存儲cinder

 

 

 

 

 

 

 

 

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

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

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

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

cinder-scheduler守護進程:選擇最優存儲提供節點來建立卷。其與「nova-scheduler「組件相似。數據庫

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

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

17.1建立cinder數據庫

# mysql -uroot –p服務器

> CREATE DATABASE cinder;架構

> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%'  IDENTIFIED BY 'cindedom

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:123456@192.168.10.205

3518:[database]

3546:connection = mysql+pymysql://cinder:cinder123@192.168.10.100/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:123456@192.168.10.205

3730:[database]

3749:connection = mysql+pymysql://cinder:cinder123@192.168.10.100/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新實例驗證磁盤

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

相關文章
相關標籤/搜索