OpenStack block storage service (Cinder)

1) Basic concepts

Cinder is a component that provides block storage services in OpenStack. Its main function is to provide virtual disk management services for virtual machine instances. The predecessor of Cinder is the "nova-volume" component in Nova, and it will be separated from Nova after the OpenStack F version as an independent OpenStack component.

1. File storage

File storage relies on the file system to store files. Files are stored directly on the file system and accessed through services such as FTP and network file systems. It is characterized by simple use and good compatibility, but the response speed and storage capacity are average.

2. Block Storage

The "block" in block storage refers to a whole piece of storage device used by the storage system, just like a hard disk. Block storage technology generally refers to the technology used when the entire raw disk space is mapped to the host. Therefore, the block storage can virtualize the entire hard disk for the cloud host to use, which is the mounted physical hard disk for the operating system of the cloud host. It is characterized by extremely fast response speed, high stability and reliability, but limited by hardware capacity, its capacity is not large.

3. Object storage

Object storage manages data in the form of objects (encapsulation). The biggest difference between an object and a file is that the object adds metadata on the basis of the file.
Object data can be divided into two parts:

  • Data, stored in the object storage server
  • The corresponding metadata is stored in the metadata server

The data are usually unstructured books, such as pictures, videos, etc. Metadata should be related to the description of the data, such as the size of the picture, the location information of the data storage, etc. When an object needs to be accessed, the metadata server is first queried to obtain specific location information, and then the specific data is obtained from the object storage server.
Object storage is mainly used for distributed storage, and its storage capacity is huge, but its speed is relatively slow.

2) Component Architecture

In block storage, raw hard disks are usually called volumes, and Cinder's task is to manage volumes, including creating and deleting volumes.
image.png
The main modules and functions of Cinder are as follows:

module Function Description
cinder-api This module is used to receive and respond to external requests, and is also the only entrance that can be used externally to manage Cinder
cinder-volume This module is a module for managing volumes in the Cinder project
cinder-scheduler This module is responsible for selecting the most suitable node from multiple storage node servers through a scheduling algorithm to create volumes
volume-provider This module is responsible for implementing specific operations on volumes by invoking a specific volume management system through the driver. It supports a variety of volume management systems, including LVM, NFS, Ceph, etc.
volume-backup This module provides backup services for volumes

3) Basic workflow

The main function of the Cinder component is to create and manage volumes.
image.png
The process is as follows:

  • After "cinder-api" receives the volume creation request initiated by the user through the management interface or the command line, it completes the necessary processing and sends it to the message queue.
  • After "cinder-scheduler" obtains the request and data from the message queue, it selects a node from several storage nodes that can store the modified volume, and sends the message to the message queue.
  • After "cinder-volume" obtains the request from the message queue, it calls the specific volume management system through "volume-provider" to create a volume on the storage device.

4) Project implementation

1. Install and configure the Ciner service on the control node

The following operations are all run on the controller node

a - Install the Cinder package
yum -y install openstack-cinder

The installed "openstack-cinder" package includes the "cinder-api" and "cinder-scheduler" modules.
View user information:

cat /etc/passwd | grep cinder

image.png
View user group information:

cat /etc/group | grep cinder

image.png

b-Create Cinder's database and authorize

There is only one database supporting the Cinder component, and it is generally named "cinder".
The first step is to enter the database

mysql -u root -p 000000

The second step is to create a new "cinder" database

create database cinder;

The third step is to authorize the database

grant all pribileges on cinder.* to 'cinder'@'localhost' identified by '000000';
grant all pribileges on cinder.* to 'cinder'@'%' identified by '000000';

Among them, @ represents any remote host, and localhost represents the local host.
The fourth step is to launch the database

quit#记得按回车
c-Modify the Cinder configuration file

Cinder's configuration file is "/etc/cinder/cinder.conf". By modifying it, the connection between Cinder and the database and Keystone can be realized. Since the configuration file has too many comments, for convenience, we can remove the comments and blank lines first.
(1) Remove the comments and blank lines in the configuration file

cp /etc/cinder/cinder.conf /etc/cinder/cinder.bak #备份配置文件
grep -Ev '^$|#' /etc/cinder/cinder.bak > /etc/cinder/cinder.conf #去掉配置文件中的注释和空行,生成新的配置文件

(2) Edit the new configuration file

#打开配置文件
vi /etc/cinder/cinder.conf

#修改[database]部分,实现与数据库“cinder”的连接
[database]
connection = mysql+pymysql://cinder:airen070321@controller/cinder

#修改[DEFAULT][keystone_authtoken]部分,实现与Keystone的交互
[DEFAULT]
auth_strategy = keystone

[keystone_authtoken]
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = project
username = cinder
password = 000000

#修改[oslo_concurrency]部分,配置锁路径
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp#这里的路径是在安装软件时“cinder”用户创建的,不要随意更改该路径

#修改[DEFAULT]部分,实现与消息队列的连接
[DEFAULT]
transport_url=rabbit://rabbitmq:airen070321@controller:5672
d- Modify the Nova configuration file
#打开配置文件
vi /etc/nova/nova.conf

#修改[cinder]部分,增加以下内容
[cinder]
os_region_name=RegionOne
e - Initialize the database
su cinder -s /bin/bash -c "cinder-manage db sync"

After the synchronization is over, we can enter the database to view the table information in the database. If there is the following information, the database synchronization is successful.
image.png

2. Cinder component initialization

The following operations are all on the controller node

a- Create Cinder users and assign roles

(1) Create a "cinder" user for the Openstack cloud computing platform

#导入环境变量模拟登录
source admin-login

#在Openstack云计算平台中创建用户“cinder”
openstack user create --domain default --password 000000 cinder
#这里的用户名与密码一定要与cinder.conf中的[keystone_authtoken]中的用户名和密码一致

(2) Assign the admin role to the user "cinder"

openstack role add --project project --user cinder admin
b-Create Cinder service and service endpoint

(1) Create a service

#OpenStack(Train版本) Cinder支持的卷是第三个版本
openstack service create --name cinder3 volume3

(2) Create service endpoints
There are three service endpoints for openstack components, corresponding to public users, internal components, and admin user service addresses

#创建公共用户访问的端点
openstack endpoint create --region RegionOne volumev3 public http://controller:8776/v3/%\(project_id\)s

#创建内部组件访问的端点
openstack endpoint create --region RegionOne volumev3 internal http://controller:8776/v3/%\(project_id\)s

#创建Admin用户访问的端点
openstack endpoint create --region RegionOne volumev3 admin http://controller:8776/v3/%\(project_id\)s
c-Start the Cinder service on the control node
#重启Nova服务
systemctl restart openstack-nova-api

#设置“cinder-api”和“cinder-scheduler”模块开机启动
systemctl enable openstack-cinder-api openstack-cinder-scheduler

#立即启动Cinder服务
systemctl start openstack-cinder-api openstack-cinder-scheduler
3. Detect the Cinder service on the control node

Here are two ways

a- Check the port occupancy
 netstat -nutpl|grep 8776

image.png

b- View the list of storage services
openstack volume service list

image.png
The "cinder-scheduler" module on the control node is displayed in the UP state, which means the service is normal

4. Build storage nodes
a-Add hard disks for computing nodes

Add a new hard disk on the computing node to serve the storage node.
The first step is to enter the virtual machine setting dialog box of the computing node, and then select the setting of the computing node. The
image.png
second step is to add the corresponding storage hard disk for it, as follows.
image.png
image.png
image.png
image.png
image.png
After the setting is completed, restart the computing node.
2. Create a volume group
Logical volume management is A mechanism for managing disk partitions in the Linux environment, which can combine several disks to form a storage pool or volume group. LVM can create new logical devices by dividing logical volumes of different sizes from the volume group each time. Cinder can use Lvm to manage block devices.

b- Check the system hard disk mount status
lsblk#查看挂载信息

image.png
We can check the specifics in /dev/

c- create LVM physical volume group

A volume group is a whole composed of several physical volumes. For users, a volume group is a large disk, which is easy to re-partition and use.
The first step is to initialize the hard disk as a physical volume

pvcreate /dev/sdb

The second step is to merge the physical volumes into volume groups.
The creation command of the LVM volume group is "vgcreate", as follows

vgcreate <卷组名><物理卷1><物理卷1>

We name the volume group as ""cinder-volumes"

vgcreate cinder-volumes /dev/sdb

The third step is to configure the device scanned by the LVM volume group

#打开LVM的配置文件
vi /etc/lvm/lvm.conf

#修改配置文件的“devices”部分,添加一个接受“/dev/sdb”磁盘并拒绝其他设备的过滤器
devices {
    
    
        filter = ["a/sdb/","r/.*/"]
.......
}
#以上代码中a表示接受,r表示拒绝
d-Start the LVM metadata service

When LVM scans the disk, it will search for all relevant physical volumes and read the metadata of the volume group. This process is very time-consuming. If the metadata of the volume group is read into the cache at one time, there is no need to do this time-consuming scan every time. . lvmetad is a service for handling metadata cache in LVM.

#设置开机启动该服务
systemctl enable lvm2-lvmetad
#立即启动服务
systemctl start lvm2-lvmetad
5. Install and configure storage nodes
a- Install Cinder related packages
yum -y install openstack-cinder targetcli python-keystone
b- Modify the Cinder configuration file

Cinder's configuration file is "/etc/cinder/cinder.conf"

#将配置文件中的注释和空行去掉
cp /etc/cinder/cinder.conf /etc/cinder/cinder.bak
#去掉配置文件中的所有注释和空行,生成新的配置文件
grep -Ev '^$|#' /etc/cinder/cinder.bak > /etc/cinder/cinder.conf

#打开配置文件
vi /etc/cinder/cinder.conf
#修改[database]部分,实现与数据库“cinder”的连接
[database]
connection = mysql+pymysql://cinder:airen070321@controller/cinder
#修改[DEFAULT][keystone_authtoken]部分,实现与keystone的交互
[DEFAULT]
auth_strategy = keystone

[keystone_authtoken]
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = project
username = cinder
password = 000000

#修改[oslo——concurrency]部分,配置锁路径
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
#这里的路径不可随意修改

#修改[DEFAULT],实现与消息队列和Glance的连接
[DEFAULT]
transport_url = rabbit://rabbitmq:000000@controller:5672
glance_api_servers = http://controller:9292

#修改[DEFALUT],并增加[lvm]部分以设置LVM
[DEFAULT]
enabled_backends = lvm
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
target_protocol = iscsi
target_helper = lioadm
6. Start the Cinder service on the compute node
#设置开机启动服务
systemctl enable openstack-cinder-volume target
#立即启动服务
systemctl start openstack-cinder-volume target

5) Project detection

Here are two detection methods

1. View the list of storage services
openstack volume service list

image.png
You can see that the two modules of cinder-scheduler and cinder-volume are in the up (startup) state.

2. View volume overview through Dashboard

After logging in to OpenStack with Dashboard, if the Cinder service is normal, the [Volume] option will appear on the left navigation bar, and you can see the three pies of "Volume", "Volume Snapshot" and "Volume Storage" in the [Overview] interface Figure, as follows
image.png

6) Create a volume with Cinder

Here are two ways to create volumes

1. Create a volume using command mode

The first step is to initiate a command on the control node to create an 8GB volume and name it "volume1"

openstack volume create --size 8 volume1

The second step is to view the volume list

openstack volume list

image.png

2. Create volumes using Dashboard

The first step is to enter the volume list. After logging in to Dashboard, go to [Volume] -> [Volume] option in the menu bar to enter the following interface.
image.png
We can see volume1, which is the volume created by our command.
The second step is to create a volume. We You can click the [Create Volume] button, as follows
image.png
Note that the total capacity of all volumes should not exceed the capacity of the volume group.
After the creation is complete, we can see the information of the newly created volume in the [Volume] interface.

Guess you like

Origin blog.csdn.net/xiaoyu070321/article/details/131538888