安装和配置控制器节点¶
本节描述了如何在控制器节点上安装和配置块存储服务,代号为 cinder。此服务需要至少一个额外的存储节点来为实例提供卷。
先决条件¶
在安装和配置块存储服务之前,您必须创建数据库、服务凭证和 API 端点。
要创建数据库,请完成以下步骤
使用数据库访问客户端以
root用户身份连接到数据库服务器# mysql创建
cinder数据库MariaDB [(none)]> CREATE DATABASE cinder;授予对
cinder数据库的适当访问权限MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \ IDENTIFIED BY 'CINDER_DBPASS'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \ IDENTIFIED BY 'CINDER_DBPASS';
将
CINDER_DBPASS替换为合适的密码。退出数据库访问客户端。
激活
admin凭证以访问仅管理员可用的 CLI 命令$ . admin-openrc
要创建服务凭证,请完成以下步骤
创建一个
cinder用户$ openstack user create --domain default --password-prompt cinder User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 9d7e33de3e1a498390353819bc7d245d | | name | cinder | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
将
admin角色添加到cinder用户$ openstack role add --project service --user cinder admin
注意
此命令不会产生任何输出。
创建
cinderv3服务实体$ openstack service create --name cinderv3 \ --description "OpenStack Block Storage" volumev3 +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Block Storage | | enabled | True | | id | ab3bbbef780845a1a283490d281e7fda | | name | cinderv3 | | type | volumev3 | +-------------+----------------------------------+
注意
从 Xena 版本开始,块存储服务只需要一个服务实体。对于早期版本,请参阅该特定版本的文档。
创建块存储服务 API 端点
$ openstack endpoint create --region RegionOne \ volumev3 public http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 03fa2c90153546c295bf30ca86b1344b | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | ab3bbbef780845a1a283490d281e7fda | | service_name | cinderv3 | | service_type | volumev3 | | url | http://controller:8776/v3/%(project_id)s | +--------------+------------------------------------------+ $ openstack endpoint create --region RegionOne \ volumev3 internal http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 94f684395d1b41068c70e4ecb11364b2 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | ab3bbbef780845a1a283490d281e7fda | | service_name | cinderv3 | | service_type | volumev3 | | url | http://controller:8776/v3/%(project_id)s | +--------------+------------------------------------------+ $ openstack endpoint create --region RegionOne \ volumev3 admin http://controller:8776/v3/%\(project_id\)s +--------------+------------------------------------------+ | Field | Value | +--------------+------------------------------------------+ | enabled | True | | id | 4511c28a0f9840c78bacb25f10f62c98 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | ab3bbbef780845a1a283490d281e7fda | | service_name | cinderv3 | | service_type | volumev3 | | url | http://controller:8776/v3/%(project_id)s | +--------------+------------------------------------------+
安装和配置组件¶
安装软件包
# apt install cinder-api cinder-scheduler
编辑
/etc/cinder/cinder.conf文件并完成以下操作在
[database]部分,配置数据库访问[database] # ... connection = mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder
将
CINDER_DBPASS替换为您为块存储数据库选择的密码。在
[DEFAULT]部分中,配置RabbitMQ消息队列访问[DEFAULT] # ... transport_url = rabbit://openstack:RABBIT_PASS@controller
将
RABBIT_PASS替换为您为RabbitMQ中的openstack帐户选择的密码。在
[DEFAULT]和[keystone_authtoken]部分中,配置身份服务访问[DEFAULT] # ... auth_strategy = keystone [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
将
CINDER_PASS替换为您在身份服务中为cinder用户选择的密码。注意
注释掉或删除
[keystone_authtoken]部分中的任何其他选项。在
[DEFAULT]部分中,配置my_ip选项以使用控制器节点的管理接口 IP 地址[DEFAULT] # ... my_ip = 10.0.0.11
在
[oslo_concurrency]部分中,配置锁路径[oslo_concurrency] # ... lock_path = /var/lib/cinder/tmp
填充块存储数据库
# su -s /bin/sh -c "cinder-manage db sync" cinder
注意
忽略此输出中的任何弃用消息。
配置 Compute 使用块存储¶
编辑
/etc/nova/nova.conf文件并向其中添加以下内容[cinder] os_region_name = RegionOne
完成安装¶
重新启动 Compute API 服务
# service nova-api restart
重启块存储服务
# service cinder-scheduler restart # service apache2 restart