OpenStack之Queen版本安装cinder服务
cinder节点配置安装
该服务使用LVM驱动程序在该设备上配置逻辑卷,并通过iSCSI传输将其提供给实例。 您可以按照这些说明进行小的修改,以便使用其他存储节点水平扩展您的环境。
1.安装支持的软件包
安装LVM,
yum install lvm2 device-mapper-persistent-data
编辑/etc/lvm/lvm.conf
devices {
filter = [ "a/sda/", "a/sdb/", "r/.*/"] //devices大括号中 添加这行
设置LVM服务开机启动
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service
2.创建LVM物理逻辑卷/dev/sdb
先给cinder节点加第二块硬盘,我设置的大小是30G。
然后对硬盘进行格式化以及分配。
可参考
fdisk /dev/vdb //分区
partprobe //刷新到内核
分区完成后再执行pvcreate和vgcreate。
[root@cinder ~]# pvcreate /dev/sdb1
Device /dev/sdb not found (or ignored by filtering).
解决方案:
编辑 vim /etc/lvm/lvm.conf,找到global_filter一行,配置如下
global_filter = [ "a|.*/|","a|sdb1|"]
之后再执行pvcreate命令,问题解决。
[root@cinder ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
3.创建cinder-volumes逻辑卷组
[root@cinder ~]# vgcreate cinder-volumes /dev/sdb1
Volume group "cinder-volumes" successfully created
4.安装和配置组件
安装软件包
yum install openstack-cinder targetcli python-keystone -y
编辑/etc/cinder/cinder.conf
[DEFAULT]
transport_url = rabbit://openstack:123456@controller
auth_strategy = keystone
my_ip = 172.17.168.130
enabled_backends = lvm
glance_api_servers = http://controller:9292
[database]
connection = mysql+pymysql://cinder:123456@controller/cinder
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = service
username = cinder
password = 123456
在[lvm]部分中,使用LVM驱动程序,cinder-volumes卷组,iSCSI协议和相应的iSCSI服务配置LVM后端。 如果[lvm]部分不存在,请创建它:
[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
控制节点
1. 创建cinder数据库
# 在任意控制节点创建数据库,后台数据自动同步,以controller01节点为例;
[root@controller01 ~]# mysql -uroot -pmysql_pass
MariaDB [(none)]> CREATE DATABASE cinder;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY '123456';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY '123456';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
2. 创建cinder-api
# 在任意控制节点操作,以controller01节点为例;
# 调用cinder服务需要认证信息,加载环境变量脚本即可
[root@controller ~]# . admin-openrc
1)创建cinder用户
# service项目已在glance章节创建;
# neutron用户在”default” domain中
[root@controller ~]# openstack user create --domain default --password=cinder_pass cinder
2)cinder赋权
# 为cinder用户赋予admin权限
[root@controller ~]# openstack role add --project service --user cinder admin
3)创建cinder服务实体
# cinder服务实体类型”volume”;
# 创建v2/v3两个服务实体
[root@controller ~]# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
[root@controller ~]# openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
4)创建cinder-api
# 注意--region与初始化admin用户时生成的region一致;
# api地址统一采用vip,如果public/internal/admin分别使用不同的vip,请注意区分;
# cinder-api 服务类型为volume;
# cinder-api后缀为用户project-id,可通过”openstack project list”查看
# v2 public api
[root@controller ~]# openstack endpoint create --region RegionTest volumev2 public http://controller:8776/v2/%\(project_id\)s
# v2 internal api
[root@controller ~]# openstack endpoint create --region RegionTest volumev2 internal http://controller:8776/v2/%\(project_id\)s
# v2 admin api
[root@controller ~]# openstack endpoint create --region RegionTest volumev2 admin http://controller:8776/v2/%\(project_id\)s
# v3 public api
[root@controller ~]# openstack endpoint create --region RegionTest volumev3 public http://controller:8776/v3/%\(project_id\)s
# v3 internal api
[root@controller ~]# openstack endpoint create --region RegionTest volumev3 internal http://controller:8776/v3/%\(project_id\)s
# v3 admin api
[root@controller ~]# openstack endpoint create --region RegionTest volumev3 admin http://controller:8776/v3/%\(project_id\)s
3. 安装cinder
# 在全部控制节点安装cinder服务,以controller01节点为例
[root@controller ~]# yum install openstack-cinder -y
4. 配置cinder.conf
[DEFAULT]
rpc_backend = rabbit
enabled_backends = lvm
auth_strategy = keystone
report_interval = 10
[backend]
[backend_defaults]
[barbican]
[brcd_fabric_example]
[cisco_fabric_example]
[coordination]
[cors]
[database]
connection = mysql+pymysql://cinder:123456@controller/cinder
[fc-zone-manager]
[healthcheck]
[key_manager]
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = service
username = cinder
password = 123456
[nova]
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = 123456
[oslo_middleware]
[oslo_policy]
[oslo_reports]
[oslo_versionedobjects]
[privsep]
[profiler]
[sample_castellan_source]
[sample_remote_file_source]
[service_user]
[ssl]
[vault]
[lvm]
volume_group = centos
5. 配置nova.conf
# 在全部控制节点操作,以controller01节点为例;
# 配置只涉及nova.conf的”[cinder]”字段;
# 加入对应regiong
[root@controller ~]# vim /etc/nova/nova.conf
[cinder]
os_region_name=RegionTest
6. 同步cinder数据库
# 任意控制节点操作;
# 忽略部分”deprecation”信息
[root@controller ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
## 验证
[root@controller ~]# mysql -h controller -ucinder -p123456 -e "use cinder;show tables;"
7. 启动服务
# 全部控制节点操作;
# 变更nova配置文件,首先需要重启nova服务
[root@controller ~]# systemctl restart openstack-nova-api.service
### 开机启动
[root@controller ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
### 启动
[root@controller ~]# systemctl restart openstack-cinder-api.service
[root@controller ~]# systemctl restart openstack-cinder-scheduler.service
8. 验证
[root@controller ~]# . admin-openrc
查看agent服务;
[root@controller ~]# openstack volume service list # 或:cinder service-list