天天看點

OpenStack離線Train版安裝系列—11.2存儲節點-Cinder存儲服務元件11.2存儲節點-Cinder存儲服務元件

本系列文章包含從OpenStack離線源制作到完成OpenStack安裝的全部過程。

在本系列教程中使用的OpenStack的安裝版本為第20個版本Train(簡稱T版本),2020年5月13日,OpenStack社群釋出了第21個版本Ussuri(簡稱U版本)。

OpenStack部署系列文章

OpenStack Victoria版 安裝部署系列教程

OpenStack Ussuri版 離線安裝部署系列教程(全)

OpenStack Train版 離線安裝部署系列教程(全)

歡迎留言溝通,共同進步。

文章目錄

  • 11.2存儲節點-Cinder存儲服務元件
    • 一、存儲節點準備好儲存設備
      • 0.磁盤挂載
      • 1.安裝LVM相關軟體包
      • 2.建立LVM實體卷
      • 3.建立 LVM 卷組 cinder-volumes
      • 4.配置過濾器,隻有執行個體可以通路塊存儲卷組,防止系統出錯
    • 二、存儲節點cinder相關軟體安裝與配置
      • 1.安裝相關軟體
      • 2.存儲節點快速修改cinder配置
      • 3.存儲節點啟動cinder服務并配置開機自啟動
    • 至此存儲節點的cinder服務安裝完畢
    • 三、(可選)安裝和配置備份服務

11.2存儲節點-Cinder存儲服務元件

在存儲節點伺服器安裝cinder存儲服務

官方參考:

https://docs.openstack.org/install-guide/openstack-services.html

https://docs.openstack.org/train/install/

https://docs.openstack.org/cinder/train/install/

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

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

(可選服務)

https://docs.openstack.org/cinder/train/install/cinder-backup-install-rdo.html

存儲節點,安裝和配置備份服務,在“塊存儲”節點上執行這些步驟。

部落格:

https://yinwucheng.com/?p=491

https://www.cnblogs.com/tssc/p/9877026.html

https://www.cnblogs.com/wanlipenghtml/p/10721845.html

https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/cinder-storage-install.html

  • 存儲節點建議單獨部署伺服器(最好是實體機),測試時也可以部署在控制節點或者計算節點
  • 在本文,存儲節點使用LVM邏輯卷提供服務,需要提供一塊空的磁盤用以建立LVM邏輯卷
  • 這裡在VMware虛拟機增加一塊100GB的磁盤
  • 在部署之前準備好儲存設備。

一、存儲節點準備好儲存設備

0.磁盤挂載

在搭建的過程中使用的是VMware Workstation虛拟機來完成的,需要給存儲節點新添加一個虛拟磁盤,并将磁盤挂載到虛拟機。

(1).分區

增加了空間的硬碟是 /dev/sdb

[[email protected] ~]# fdisk -l

Disk /dev/sda: 68.7 GB, 68719476736 bytes, 134217728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a0797

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   134217727    66059264   8e  Linux LVM

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-root: 42.7 GB, 42651877376 bytes, 83304448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-swap: 4160 MB, 4160749568 bytes, 8126464 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-home: 20.8 GB, 20824719360 bytes, 40673280 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[[email protected] ~]#

           

(2).分區

[[email protected] ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xfa73ca8f

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 3
First sector (2048-41943039, default 2048): #回車
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): #回車
Using default value 41943039
Partition 3 of type Linux and of size 20 GiB is set

Command (m for help): t
Selected partition 3
Hex code (type L to list all codes): w
Changed type of partition 'Linux' to 'unknown'

Command (m for help): q

[[email protected] ~]# cd /dev/
[[email protected] dev]# partprobe
[[email protected] dev]# ls sd*
sda  sda1  sda2  sdb
[[email protected] dev]#

           

(3).格式化

[[email protected] dev]# mkfs.ext3 /dev/sdb
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

[[email protected] dev]#

           

1.安裝LVM相關軟體包

安裝LVM包

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

啟動LVM的metadata服務并配置開機自啟動

systemctl start lvm2-lvmetad.service
systemctl status lvm2-lvmetad.service

systemctl enable lvm2-lvmetad.service
systemctl list-unit-files |grep lvm2-lvmetad |grep enabled
           

2.建立LVM實體卷

建立LVM實體卷/dev/sdb

# 檢查磁盤狀态
[[email protected] ~]# fdisk -l

# 建立LVM 實體卷 /dev/sdb
[[email protected] ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created.
           

3.建立 LVM 卷組 cinder-volumes

(1)塊存儲服務會在這個卷組中建立邏輯卷

[[email protected] ~]# vgcreate cinder-volumes /dev/sdb
  Volume group "cinder-volumes" successfully created
[[email protected] ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               <63.00 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              16127
  Free PE               1
  Allocated PE          16126
  PV UUID               aTMOV5-l175-850d-vuur-0LRK-HGiz-JBLcwZ
  --- Physical volume ---
  PV Name               /dev/sdb
  VG Name               cinder-volumes
  PV Size               20.00 GiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              5119
  Free PE               5119
  Allocated PE          0
  PV UUID               2GmNUZ-03a6-I2dH-hG0W-4ISc-5Liy-30XbrO

[[email protected] ~]#

           

4.配置過濾器,隻有執行個體可以通路塊存儲卷組,防止系統出錯

(1)新增磁盤sdb為LVM卷組

  • 預設隻會有openstack執行個體通路塊存儲卷組,不過,底層的作業系統也會管理這些裝置并嘗試将邏輯卷與系統關聯。
  • 預設情況下LVM卷掃描工具會掃描整個/dev目錄,查找所有包含lvm卷的塊儲存設備。如果其他項目在某個磁盤裝置sda,sdc等上使用了lvm卷,那麼掃描工具檢測到這些卷時會嘗試緩存這些lvm卷,可能導緻底層作業系統或者其他服務無法正常調用他們的lvm卷組,進而産生各種問題,需要手動配置LVM,讓LVM卷掃描工具隻掃描包含"cinder-volume"卷組的裝置/dev/sdb,我這邊磁盤分區都是格式化的手工分區,目前不存在這個問題,以下是配置示範

将LVM重新配置為僅掃描包含cinder-volumes卷組的裝置

vim /etc/lvm/lvm.conf
-----------------------------
devices {
filter = [ "a/sdb/", "r/.*/"]
}
-----------------------------
           

在devices部分中,添加一個接受/dev/sdb裝置并拒絕所有其他裝置的過濾器:

  • 配置規則:
  • a用于接受,r用于拒絕。
  • 每個過濾器組中的元素都以a開頭accept接受,或以 r 開頭reject拒絕,後面連接配接裝置名稱的正規表達式規則。
  • 過濾器組必須以"r/.*/"結束,過濾所有保留裝置。
  • 可以使用指令:vgs -vvvv來測試過濾器。

(2)、檢視系統磁盤卷類型

[[email protected] ~]# vgdisplay
  WARNING: Device for PV aTMOV5-l175-850d-vuur-0LRK-HGiz-JBLcwZ not found or rejected by a filter.
  Couldn't find device with uuid aTMOV5-l175-850d-vuur-0LRK-HGiz-JBLcwZ.
  WARNING: Couldn't find all devices for LV centos/swap while checking used and assumed devices.
  WARNING: Couldn't find all devices for LV centos/home while checking used and assumed devices.
  WARNING: Couldn't find all devices for LV centos/root while checking used and assumed devices.
  --- Volume group ---
  VG Name               centos
  System ID
  Format                lvm2
  Metadata Areas        0
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                0
  VG Size               <63.00 GiB
  PE Size               4.00 MiB
  Total PE              16127
  Alloc PE / Size       16126 / 62.99 GiB
  Free  PE / Size       1 / 4.00 MiB
  VG UUID               Ws4wQS-K0VZ-vp9q-TB9Y-sLP9-OKyb-SZbTd8

  --- Volume group ---
  VG Name               cinder-volumes
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  18
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <20.00 GiB
  PE Size               4.00 MiB
  Total PE              5119
  Alloc PE / Size       4874 / <19.04 GiB
  Free  PE / Size       245 / 980.00 MiB
  VG UUID               AOqwgQ-yYNb-7anP-1tr4-1e3m-Bxth-b3R9rP

[[email protected] ~]#

           
  • 注意:
  • 如果存儲節點的作業系統磁盤/dev/sda使用的是LVM卷組,也需要将該裝置添加到過濾器中,配置檔案/etc/lvm/lvm.conf添加如下:
devices {
  ......
filter = [ "a/sda/", "a/sdb/", "r/.*/"]
  ......
}
           
  • 如果計算節點的作業系統磁盤/dev/sda使用的是LVM卷組,也需要将該裝置添加到過濾器中,配置檔案/etc/lvm/lvm.conf添加如下:
devices {
  ......
filter = [ "a/sda/", "r/.*/"]
  ......
}
           

二、存儲節點cinder相關軟體安裝與配置

1.安裝相關軟體

yum install openstack-cinder targetcli python-keystone -y
#用于快速配置
yum install openstack-utils -y
           

2.存儲節點快速修改cinder配置

/etc/cinder/cinder.conf

cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
grep -Ev '#|^$' /etc/cinder/cinder.conf.bak>/etc/cinder/cinder.conf
           
openstack-config --set  /etc/cinder/cinder.conf database connection  mysql+pymysql://cinder:[email protected]/cinder
openstack-config --set  /etc/cinder/cinder.conf DEFAULT transport_url  rabbit://openstack:[email protected]
openstack-config --set  /etc/cinder/cinder.conf DEFAULT auth_strategy  keystone
openstack-config --set  /etc/cinder/cinder.conf keystone_authtoken www_authenticate_uri  http://controller:5000
openstack-config --set  /etc/cinder/cinder.conf keystone_authtoken auth_url  http://controller:5000
openstack-config --set  /etc/cinder/cinder.conf keystone_authtoken memcached_servers  controller:11211
openstack-config --set  /etc/cinder/cinder.conf keystone_authtoken auth_type  password
openstack-config --set  /etc/cinder/cinder.conf keystone_authtoken project_domain_name  default
openstack-config --set  /etc/cinder/cinder.conf keystone_authtoken user_domain_name  default
openstack-config --set  /etc/cinder/cinder.conf keystone_authtoken project_name  service
openstack-config --set  /etc/cinder/cinder.conf keystone_authtoken username  cinder
openstack-config --set  /etc/cinder/cinder.conf keystone_authtoken password  CINDER_PASS
openstack-config --set  /etc/cinder/cinder.conf DEFAULT my_ip 10.0.0.41
openstack-config --set  /etc/cinder/cinder.conf DEFAULT enabled_backends  lvm
openstack-config --set  /etc/cinder/cinder.conf DEFAULT glance_api_servers  http://controller:9292
openstack-config --set  /etc/cinder/cinder.conf lvm volume_driver cinder.volume.drivers.lvm.LVMVolumeDriver
openstack-config --set  /etc/cinder/cinder.conf lvm volume_group cinder-volumes
openstack-config --set  /etc/cinder/cinder.conf lvm target_protocol  iscsi
openstack-config --set  /etc/cinder/cinder.conf lvm target_helper  lioadm
openstack-config --set  /etc/cinder/cinder.conf oslo_concurrency lock_path  /var/lib/cinder/tmp

#Replace RABBIT_PASS with the password you chose for the openstack account in RabbitMQ.
#Replace MANAGEMENT_INTERFACE_IP_ADDRESS with the IP address of the management network interface on your storage node, typically 10.0.0.41 for the first node.

#注意具體配置與之前版本有所變更
#[lvm]
# volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
# volume_group = cinder-volumes
# target_protocol = iscsi
# target_helper = lioadm

egrep -v "^#|^$" /etc/cinder/cinder.conf
grep '^[a-z]' /etc/cinder/cinder.conf

           

3.存儲節點啟動cinder服務并配置開機自啟動

需要啟動2個服務

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

systemctl enable openstack-cinder-volume.service target.service
systemctl list-unit-files |grep openstack-cinder |grep enabled
systemctl list-unit-files |grep target.service |grep enabled
           

至此存儲節點的cinder服務安裝完畢

至此,在存儲節點安裝cinder服務就完成了

三、(可選)安裝和配置備份服務

#安裝軟體包:
yum install openstack-cinder

#編輯/etc/cinder/cinder.conf檔案并完成以下操作
---------------------------------------------------------------
[DEFAULT]
# ...
backup_driver = cinder.backup.drivers.swift.SwiftBackupDriver
backup_swift_url = SWIFT_URL
---------------------------------------------------------------
#替換SWIFT_URL為對象存儲服務的URL。可以通過顯示對象庫API端點來找到URL:

openstack catalog show object-store

#确定安裝,啟動塊存儲備份服務,并将其配置為在系統啟動時啟動:
systemctl start openstack-cinder-backup.service
systemctl status openstack-cinder-backup.service
systemctl enable openstack-cinder-backup.service
systemctl list-unit-files |grep openstack-cinder-backup.service |grep enabled
           

繼續閱讀