官方部署文档:https://docs.openstack.org/ocata/zh_CN/install-guide-rdo/cinder.htmlhtml
OpenStack的存储组件—Cinder和Swift—让你在你的私有云里构建块存储和对象的存储系统,Openstack从Folsom开始使用Cinder替换原来的Nova-Volume服务,为Openstack云平台提供块存储服务,Cinder接口提供了一些标准功能,容许建立和附加块设备到虚拟机,如“建立卷”,“删除卷”和“附加卷”。还有更多高级的功能,支持扩展容量的能力,快照和建立虚拟机镜像克隆,主要涉及到的组件以下:python
cinder-api:接受API请求,并将其路由到“cinder-volume“执行,即请求cinder要先请求此对外API。mysql
cinder-volume:与块存储服务和例如“cinder-scheduler“的进程进行直接交互。它也能够与这些进程经过一个消息队列进行交互。“cinder-volume“服务响应送到块存储服务的读写请求来维持状态。它也能够和多种存储提供者在驱动架构下进行交互。sql
cinder-scheduler守护进程:选择最优存储提供节点来建立卷。其与“nova-scheduler“组件相似。数据库
cinder-backup守护进程:“cinder-backup“服务提供任何种类备份卷到一个备份存储提供者。就像“cinder-volume“服务,它与多种存储提供者在驱动架构下进行交互。vim
消息队列:在块存储的进程之间路由信息。api
# mysql -uroot –p服务器
> CREATE DATABASE cinder;架构
> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'cindedom
r123';
> flush privileges;
# mysql -ucinder -h192.168.10.100 -pcinder123
# source admin-ocata.sh
# openstack user create --domain default --password-prompt cinder
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | 81672c29064942aea8fb754820ddb76a |
| enabled | True |
| id | f12af1d5583e4b179354c3b4d8d0d778 |
| name | cinder |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
#受权admin权限
# openstack role add --project service --user cinder admin
# v2,v3版本建立
# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
# v2,v3版本建立
# openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
#公共端点:
# openstack endpoint create --region RegionOne volumev2 public http://192.168.10.100:8776/v2/%\(project_id\)s
+--------------+----------------------------------------------+
| Field | Value |
+--------------+----------------------------------------------+
| enabled | True |
| id | cf87da53a7754996972b7ef2baf73933 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8077b7de84fc4b32a288306459bad10b |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://192.168.10.100:8776/v2/%(project_id)s |
+--------------+----------------------------------------------+
#私有端点:
# openstack endpoint create --region RegionOne volumev2 internal http://192.168.10.100:8776/v2/%\(project_id\)s
+--------------+----------------------------------------------+
| Field | Value |
+--------------+----------------------------------------------+
| enabled | True |
| id | 4d8cfb82cd4a4015876df6aafc8bb219 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8077b7de84fc4b32a288306459bad10b |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://192.168.10.100:8776/v2/%(project_id)s |
+--------------+----------------------------------------------+
#管理端点:
# openstack endpoint create --region RegionOne volumev2 admin http://192.168.10.100:8776/v2/%\(project_id\)s
+--------------+----------------------------------------------+
| Field | Value |
+--------------+----------------------------------------------+
| enabled | True |
| id | 686d554b483a4a52b36c6b6a6c3a2feb |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8077b7de84fc4b32a288306459bad10b |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://192.168.10.100:8776/v2/%(project_id)s |
+--------------+----------------------------------------------+
#公共端点:
# openstack endpoint create --region RegionOne volumev3 public http://192.168.10.100:8776/v3/%\(project_id\)s
+--------------+----------------------------------------------+
| Field | Value |
+--------------+----------------------------------------------+
| enabled | True |
| id | 729e23316e964ff6bc6315f4d95e590a |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 4234b69629ac4e6bbabcd72c8bb0ab81 |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://192.168.10.100:8776/v3/%(project_id)s |
+--------------+----------------------------------------------+
#私有端点:
# openstack endpoint create --region RegionOne volumev3 internal http://192.168.10.100:8776/v3/%\(project_id\)s
+--------------+----------------------------------------------+
| Field | Value |
+--------------+----------------------------------------------+
| enabled | True |
| id | 0541cfdf2d99477fb4105aac045f0399 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 4234b69629ac4e6bbabcd72c8bb0ab81 |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://192.168.10.100:8776/v3/%(project_id)s |
+--------------+----------------------------------------------+
#管理端点:
# openstack endpoint create --region RegionOne volumev3 admin http://192.168.10.100:8776/v3/%\(project_id\)s
+--------------+----------------------------------------------+
| Field | Value |
+--------------+----------------------------------------------+
| enabled | True |
| id | 3b45ed17bb724479a49df89e49a0e2ae |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 4234b69629ac4e6bbabcd72c8bb0ab81 |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://192.168.10.100:8776/v3/%(project_id)s |
+--------------+----------------------------------------------+
# vim /etc/haproxy/haproxy.cfg
listen cinder
bind 192.168.10.100:8776
mode tcp
log global
balance source
server cinder-server 192.168.10.201:8776 check inter 5000 rise 3 fall 3
# systemctl reload haproxy.service
# yum install openstack-cinder –y
# vim /etc/cinder/cinder.conf
1:[DEFAULT]
263:my_ip = 192.168.10.201
376:auth_strategy = keystone
3243:transport_url = rabbit://openstack:123456@192.168.10.205
3518:[database]
3546:connection = mysql+pymysql://cinder:cinder123@192.168.10.100/cinder
3767:[keystone_authtoken]
3768:auth_uri = http://192.168.10.100:5000
3769:auth_url = http://192.168.10.100:35357
3770:memcached_servers = 192.168.10.100:11211
3771:auth_type = password
3772:project_domain_name = default
3773:user_domain_name = default
3774:project_name = service
3775:username = cinder
3776:password = cinder
3996:[oslo_concurrency]
4012:lock_path = /var/lib/cinder/tmp
# su -s /bin/sh -c "cinder-manage db sync" cinder
# mysql -ucinder -h192.168.10.100 -pcinder123
# 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
# tail -f /var/log/cinder/*.log
# vim /etc/nova/nova.conf
3982 [cinder]
4031 os_region_name=RegionOne
# systemctl restart libvirtd.service openstack-nova-compute.service
# openstack volume service list
在负载服务器(或其余指定服务器)新添加一块50G的磁盘而后点肯定:
# yum install lvm2 –y
# systemctl enable lvm2-lvmetad.service
# systemctl start lvm2-lvmetad.service
# ll /sys/class/scsi_host/host
host0/ host1/ host2/
# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "- - -" > /sys/class/scsi_host/host1/scan
# echo "- - -" > /sys/class/scsi_host/host2/scan
#fdisk -l
# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
# vgcreate cinder-volumes /dev/sdb
Volume group "cinder-volumes" successfully created
在负载服务器安装配置
# yum install openstack-cinder targetcli python-keystone –y
# vim /etc/cinder/cinder.conf
1:[DEFAULT]
283:my_ip = 192.168.10.205
288:glance_api_servers = http://192.168.10.100:9292
400:auth_strategy = keystone
404:enabled_backends = lvm
1210:transport_url = rabbit://openstack:123456@192.168.10.205
3730:[database]
3749:connection = mysql+pymysql://cinder:cinder123@192.168.10.100/cinder
3973:[keystone_authtoken]
3974:auth_uri = http://192.168.10.100:5000
3975:auth_url = http://192.168.10.100:35357
3976:memcached_servers = 192.168.10.100:11211
3977:auth_type = password
3978:project_domain_name = default
3979:user_domain_name = default
3980:project_name = service
3981:username = cinder
3982:password = cinder
4249:[oslo_concurrency]
4263:lock_path = /var/lib/cinder/tmp
4904:[lvm]
4905:volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
4906:volume_group = cinder-volumes
4907:iscsi_protocol = iscsi
4908:iscsi_helper = lioadm
4909:volume_backend_name=Openstack-lvm
# systemctl enable openstack-cinder-volume.service target.service
# systemctl start openstack-cinder-volume.service target.service
# openstack volume service list
使用admin或者demo用户登陆到管理界面,点击卷—建立卷:
# mkfs.ext4 /dev/vdb
新建立一个虚拟机,用于将上一步关联的卷分离后挂载到新的虚拟机上进行测试。
在以前的虚拟机将卷卸载。
点击项目-卷-管理链接:
在管理链接界面,将卷关联至test-vm2:
验证能够挂载关联的磁盘并能够查看以前的数据