概览:
cinder-api:接收和响应外部有关块存储的请求
cinder-volume:提供真实存储空间
cinder-scheduler:调度器,决定将要分配的空间由哪个cinder-volume提供

1、建库授权

CREATE DATABASE cinder;
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'CINDER_DBPASS';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'CINDER_DBPASS';

2、创建用户、项目、绑定角色

openstack user create --domain default --password CINDER_PASS 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 #为了版本兼容创建了两个版本的service

3、创建endpoint(v2和v3都要创建)

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

OpenStack Train版操作笔记(12) --- 安装cinder块存储服务(控制节点)_第1张图片
OpenStack Train版操作笔记(12) --- 安装cinder块存储服务(控制节点)_第2张图片
4、安装配置服务

yum install openstack-cinder -y

修改配置文件 /etc/cinder/cinder.conf:

[database]
# ...
connection = mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder

[DEFAULT]
# ...
transport_url = rabbit://openstack:RABBIT_PASS@controller
auth_strategy = keystone
my_ip = 10.150.165.101
glance_api_servers = http://controller:9292 #官方文档没加,一定要加,不然后面添加卷的时候会有报错

[keystone_authtoken]
# ...
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = CINDER_PASS

[oslo_concurrency]
# ...
lock_path = /var/lib/cinder/tmp

同步数据库:

su -s /bin/sh -c "cinder-manage db sync" cinder #有一条输出内容,在网上搜了一下说是可忽略

OpenStack Train版操作笔记(12) --- 安装cinder块存储服务(控制节点)

修改配置文件 /etc/nova/nova.conf:

[cinder]
os_region_name = RegionOne

启动服务并设置开机自启动:

systemctl restart openstack-nova-api.service

systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service

5、验证

cinder service-list

OpenStack Train版操作笔记(12) --- 安装cinder块存储服务(控制节点)