OpenStack块存储服务(cinder)为虚拟机添加持久的存储,块存储提供一个基础设施为了管理卷,以及和OpenStack计算服务交互,为实例提供卷。此服务也会激活管理卷的快照和卷类型的功能。
块存储服务(cinder)为实例提供块存储。存储的分配和消耗是由块存储驱动器,或者多后端配置的驱动器决定的。还有不少驱动程序可用:NAS/SAN,NFS,ISCSI,Ceph等。
典型状况下,块服务API和调度器服务运行在控制节点上。取决于使用的驱动,卷服务器能够运行在控制节点、计算节点或单独的存储节点。python
- cinder-api
接受API请求,并将其路由到cinder-volume
执行。- cinder-volume
与块存储服务和例如cinder-scheduler
的进程进行直接交互。它也能够与这些进程经过一个消息队列进行交互。cinder-volume
服务响应送到块存储服务的读写请求来维持状态。它也能够和多种存储提供者在驱动架构下进行交互。- cinder-scheduler守护进程
选择最优存储提供节点来建立卷。其与nova-scheduler
组件相似。- cinder-backup守护进程
cinder-backup
服务提供任何种类备份卷到一个备份存储提供者。就像cinder-volume
服务,它与多种存储提供者在驱动架构下进行交互。- 消息队列
在块存储的进程之间路由信息。
这个部分描述如何在控制节点上安装和配置块设备存储服务,即 cinder。这个服务须要至少一个额外的存储节点,以向实例提供卷。
mysql
新添加一块磁盘sql
# fdisk /dev/sdb (而后输入 n p 1 回车 回车 回车 w)
建立LVM物理逻辑卷/dev/sdb数据库
# pvcreate /dev/sdb1
建立cinder-volumes逻辑卷组vim
# vgcreate cinder-volumes /dev/sdb1
安装软件包后端
# yum install openstack-cinder targetcli python-keystone -y # vim /etc/cinder/cinder.conf [DEFAULT] //1302 transport_url = rabbit://openstack:RABBIT_PASS@controller /399 auth_strategy = keystone //291 my_ip = 192.168.200.143 //403 enabled_backends = lvm //296 glance_api_servers = http://controller:9292 [database] //3586 connection = mysql+pymysql://cinder:123456@controller/cinder [keystone_authtoken] //3850 auth_uri = http://controller:5000 auth_url = http://controller:35357 //3901 memcached_servers = controller:11211 //4008 auth_type = password project_domain_id = default user_domain_id = default project_name = service username = cinder password = 123456 [oslo_concurrency] //4126 lock_path = /var/lib/cinder/tmp 在[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 # systemctl enable openstack-cinder-volume.service target.service # systemctl start openstack-cinder-volume.service target.service
配置数据库api
# mysql -u root -p > CREATE DATABASE cinder; > GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY '123456'; > GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY '123456'; # source ~/admin-openrc
建立用户服务器
# openstack user create --domain default --password-prompt cinder User Password: //密码123456 Repeat User Password: //密码123456
添加角色架构
# openstack role add --project service --user cinder admin
建立cinderv2和cinderv3服务实体dom
# 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
安装openstack-cinder软件包
# yum install openstack-cinder -y # vim /etc/cinder/cinder.conf [database] //3586 connection = mysql+pymysql://cinder:123456@controller/cinder [DEFAULT] //1302 transport_url = rabbit://openstack:RABBIT_PASS@controller //399 auth_strategy = keystone //291 my_ip = 192.168.200.133 [keystone_authtoken] //3850 auth_uri = http://controller:5000 auth_url = http://controller:35357 //3901 memcached_servers = controller:11211 //4008 auth_type = password project_domain_id = default user_domain_id = default project_name = service username = cinder password = 123456 [oslo_concurrency] //4126 lock_path = /var/lib/cinder/tmp
同步数据库
# su -s /bin/sh -c "cinder-manage db sync" cinder
# vim /etc/nova/nova.conf [cinder] //4237 os_region_name = RegionOne # systemctl restart openstack-nova-api.service //重启nova-api
设置开机自启动并启动服务
# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service # systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service