概述
OpenStack块存储服务(cinder)为虚拟机添加持久的存储,块存储提供一个基础设施为了管理卷,以及和OpenStack计算服务交互,为实例提供卷。此服务也会激活管理卷的快照和卷类型的功能。
块存储服务通常包含下列组件:
-
cinder-api
接受API请求,并将其路由到
cinder-volume
执行。 -
cinder-volume
与块存储服务和例如
cinder-scheduler
的进程进行直接交互。它也可以与这些进程通过一个消息队列进行交互。cinder-volume
服务响应送到块存储服务的读写请求来维持状态。它也可以和多种存储提供者在驱动架构下进行交互。 -
cinder-scheduler守护进程
选择最优存储提供节点来创建卷。其与
nova-scheduler
组件类似。 -
cinder-backup daemon
cinder-backup
服务提供任何种类备份卷到一个备份存储提供者。就像cinder-volume
服务,它与多种存储提供者在驱动架构下进行交互。 -
消息队列
在块存储的进程之间路由信息。
安装并配置控制节点
先决条件
1、创建数据库
root
用户连接到数据库服务器
mysql -u root -p000000
- 创建
cinder
数据库
CREATE DATABASE cinder;
- 允许
cinder
数据库的cinder
用户访问权限:
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY '000000';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY '000000';
2、获取 admin 凭证
. admin-openrc
3、创建服务证书
- 创建一个
cinder
用户
openstack user create --domain default --password 000000 cinder
- 添加
admin
角色到cinder
用户上
openstack role add --project service --user cinder admin
- 创建服务实体
openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
- 创建服务API
openstack endpoint create --region RegionOne \
volumev2 public http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne \
volumev2 internal http://controller:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne \
volumev2 admin http://controller:8776/v2/%\(project_id\)s
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
openstack endpoint create --region RegionOne \
volumev3 admin http://controller:8776/v3/%\(project_id\)s
[root@openstack ~]# mysql -u root -p000000
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 379
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE cinder;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \
-> IDENTIFIED BY '000000';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \
-> IDENTIFIED BY '000000';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
[root@openstack ~]# . admin-openrc
[root@openstack ~]# openstack user create --domain default --password 000000 cinder
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 15c1c62c21f543d984563abe5c063726 |
| name | cinder |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[root@openstack ~]# openstack role add --project service --user cinder admin
[root@openstack ~]# openstack service create --name cinderv2 \
> --description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | 052ab471e8ed4e5ca687bd73537935b5 |
| name | cinderv2 |
| type | volumev2 |
+-------------+----------------------------------+
[root@openstack ~]# openstack service create --name cinderv3 \
> --description "OpenStack Block Storage" volumev3
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | af52c95327614d1e9fb70286fcb552ea |
| name | cinderv3 |
| type | volumev3 |
+-------------+----------------------------------+
[root@openstack ~]# openstack endpoint create --region RegionOne \
> volumev2 public http://controller:8776/v2/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | 2c3e428aa796442696e7f5919175c1e2 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 052ab471e8ed4e5ca687bd73537935b5 |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(project_id)s |
+--------------+------------------------------------------+
[root@openstack ~]# openstack endpoint create --region RegionOne \
> volumev2 internal http://controller:8776/v2/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | c25695b19d1b4e33a9ea2d4c023b8732 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 052ab471e8ed4e5ca687bd73537935b5 |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(project_id)s |
+--------------+------------------------------------------+
[root@openstack ~]# openstack endpoint create --region RegionOne \
> volumev2 admin http://controller:8776/v2/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | 2928643fb2ac4bd99aa8cc795b55f7e1 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 052ab471e8ed4e5ca687bd73537935b5 |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(project_id)s |
+--------------+------------------------------------------+
[root@openstack ~]# openstack endpoint create --region RegionOne \
> volumev3 public http://controller:8776/v3/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | a63b291e2ed4450e91ee574e4f9b4a7a |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | af52c95327614d1e9fb70286fcb552ea |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller:8776/v3/%(project_id)s |
+--------------+------------------------------------------+
[root@openstack ~]# openstack endpoint create --region RegionOne \
> volumev3 internal http://controller:8776/v3/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | f47bd12c58af41298cdc7c5fe76cb8d4 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | af52c95327614d1e9fb70286fcb552ea |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller:8776/v3/%(project_id)s |
+--------------+------------------------------------------+
[root@openstack ~]# openstack endpoint create --region RegionOne \
> volumev3 admin http://controller:8776/v3/%\(project_id\)s
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| enabled | True |
| id | 6dd9f8c300754f32abecf2b77e241d5d |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | af52c95327614d1e9fb70286fcb552ea |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller:8776/v3/%(project_id)s |
+--------------+------------------------------------------+
{/collapse-item}
安装并配置组件
1、安装软件包
yum install -y openstack-cinder
2、配置 cinder.conf
# sed -i.bak '/^#/d;/^$/d' /etc/cinder/cinder.conf
# vim /etc/cinder/cinder.conf
[database]
# 配置数据库访问
connection = mysql+pymysql://cinder:000000@controller/cinder
[DEFAULT]
# 配置RabbitMQ 消息队列访问
transport_url = rabbit://openstack:000000@controller
# 配置身份服务访问
auth_strategy = keystone
# 控制器节点的管理接口 IP 地址
my_ip = 178.120.2.100
[keystone_authtoken]
# 配置身份服务访问
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = 000000
[oslo_concurrency]
# 配置锁定路径
lock_path = /var/lib/cinder/tmp
3、同步数据库
# su -s /bin/sh -c "cinder-manage db sync" cinder
配置计算节点使用块设备存储
配置 nova.conf
# vim /etc/nova/nova.conf
[cinder]
os_region_name = RegionOne
完成安装
1、重启计算API服务
systemctl restart openstack-nova-api.service
2、启动设备块存储服务并设置开机自启
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
安装并配置存储节点
先决条件
1、安装支持工具包
yum install -y lvm2 device-mapper-persistent-data
systemctl enable lvm2-lvmetad.service && systemctl start lvm2-lvmetad.service
2、创建LVM物理卷
pvcreate /dev/sdb
3、创建LVM卷组
vgcreate cinder-volumes /dev/sdb
4、添加过滤器
# vim /etc/lvm/lvm.conf
filter = [ "a/vdb/", "r/.*/"]
[root@storage_node ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 252:0 0 30G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 29G 0 part
└─centos-root 253:0 0 29G 0 lvm /
vdb 252:16 0 100G 0 disk
vdc 252:32 0 100G 0 disk
[root@storage_node ~]# pvcreate /dev/vdb
Physical volume "/dev/vdb" successfully created.
[root@storage_node ~]# vgcreate cinder-volumes /dev/vdb
Volume group "cinder-volumes" successfully create
{/collapse-item}
安装并配置组件
1、安装软件包
yum install -y openstack-cinder targetcli python-keystone
2、配置 cinder.conf
# sed -i.bak '/^#/d;/^$/d' /etc/cinder/cinder.conf
# vim /etc/cinder/cinder.conf
[database]
# 配置数据库访问
connection = mysql+pymysql://cinder:000000@controller/cinder
[DEFAULT]
# RabbitMQ 消息队列访问
transport_url = rabbit://openstack:000000@controller
# 配置身份服务访问
auth_strategy = keystone
# 存储节点上管理网络接口的 IP 地址
my_ip = 178.120.2.192
# 启用 LVM 后端
enabled_backends = lvm
# 配置镜像服务 API 的位置
glance_api_servers = http://controller:9292
[keystone_authtoken]
# 配置身份服务访问
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = 000000
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm
[oslo_concurrency]
# 配置锁定路径
lock_path = /var/lib/cinder/tmp
完成安装
启动存储卷服务,设置开机自启
systemctl enable openstack-cinder-volume.service target.service
systemctl start openstack-cinder-volume.service target.service
评论