7.1 通过脚本安装Cinder服务
7.2-7.12块存储服务的操作命令已经编写成shell脚本,通过脚本进行一键安装。如下:
#Controller
执行脚本iaas-install-cinder-controller.sh进行安装
#Compute节点
执行脚本iaas-install-cinder-compute.sh进行安装
7.2 安装Cinder块存储服务软件包
# yum install openstack-cinder
7.3 创建数据库
# mysql -u root -p
mysql> CREATE DATABASE cinder;
mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY '$CINDER_DBPASS';
mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY '$CINDER_DBPASS';
7.4 创建用户
# openstack user create --domain $DOMAIN_NAME --password $CINDER_PASS cinder
# openstack role add --project service --user cinder admin
7.5 创建Endpoint和API端点
# openstack service create --name cinder --description "OpenStack Block Store" volume
# openstack service create --name cinderv2 --description "OpenStack Block Store" volumev2
# openstack service create --name cinderv3 --description "OpenStack Block Store" volumev3
# openstack endpoint create --region RegionOne volume public http://$HOST_NAME:8776/v1/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volume internal http://$HOST_NAME:8776/v1/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volume admin http://$HOST_NAME:8776/v1/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volumev2 public http://$HOST_NAME:8776/v2/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volumev2 internal http://$HOST_NAME:8776/v2/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volumev2 admin http://$HOST_NAME:8776/v2/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volumev3 public http://$HOST_NAME:8776/v3/%\(tenant_id\)s
#openstack endpoint create --region RegionOne volumev3 internal http://$HOST_NAME:8776/v3/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volumev3 admin http://$HOST_NAME:8776/v3/%\(tenant_id\)s
7.6 配置Cinder服务
# crudini --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:$CINDER_DBPASS@$HOST_NAME/cinder
# crudini --set /etc/cinder/cinder.conf DEFAULT rpc_backend rabbit
# crudini --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_host $HOST_NAME
# crudini --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_userid $RABBIT_USER
# crudini --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_password $RABBIT_PASS
# crudini --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
# crudini --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://$HOST_NAME:5000
# crudini --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://$HOST_NAME:35357
# crudini --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers $HOST_NAME:11211
# crudini --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
# crudini --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name $DOMAIN_NAME
# crudini --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name $DOMAIN_NAME
# crudini --set /etc/cinder/cinder.conf keystone_authtoken project_name service
# crudini --set /etc/cinder/cinder.conf keystone_authtoken username cinder
# crudini --set /etc/cinder/cinder.conf keystone_authtoken password $CINDER_PASS
# crudini --set /etc/cinder/cinder.conf DEFAULT my_ip $HOST_IP
# crudini --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
# crudini --set /etc/nova/nova.conf cinder os_region_name RegionOne
7.7 创建数据库
# su -s /bin/sh -c "cinder-manage db sync" cinder
7.8 启动服务
# systemctl restart openstack-nova-api.service
# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
# systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service
7.9 安装块存储软件
#compute
# yum install lvm2 device-mapper-persistent-data openstack-cinder targetcli python-keystone -y
# systemctl enable lvm2-lvmetad.service
# systemctl restart lvm2-lvmetad.service
7.10 创建LVM物理和逻辑卷
以磁盘/dev/sda为例
# pvcreate –f /dev/sda
# vgcreate cinder-volumes /dev/sda
7.11 修改Cinder配置文件
# crudini --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:$CINDER_DBPASS@$HOST_NAME/cinder
# crudini --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://$RABBIT_USER:$RABBIT_PASS@$HOST_NAME
# crudini --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
# crudini --set /etc/cinder/cinder.conf DEFAULT enabled_backends lvm
# crudini --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://$HOST_NAME:5000
# crudini --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://$HOST_NAME:35357
# crudini --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers $HOST_NAME:11211
# crudini --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
# crudini --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name $DOMAIN_NAME
# crudini --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name $DOMAIN_NAME
# crudini --set /etc/cinder/cinder.conf keystone_authtoken project_name service
# crudini --set /etc/cinder/cinder.conf keystone_authtoken username cinder
# crudini --set /etc/cinder/cinder.conf keystone_authtoken password $CINDER_PASS
# crudini --set /etc/cinder/cinder.conf DEFAULT my_ip $HOST_IP_NODE
# crudini --set /etc/cinder/cinder.conf lvm volume_driver cinder.volume.drivers.lvm.LVMVolumeDriver
# crudini --set /etc/cinder/cinder.conf lvm volume_group cinder-volumes
# crudini --set /etc/cinder/cinder.conf lvm iscsi_protocol iscsi
# crudini --set /etc/cinder/cinder.conf lvm iscsi_helper lioadm
# crudini --set /etc/cinder/cinder.conf DEFAULT glance_api_servers http://$HOST_NAME:9292
# crudini --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
7.12 重启服务
# systemctl enable openstack-cinder-volume.service target.service
# systemctl restart openstack-cinder-volume.service target.service
7.13 验证
#Controller
使用cinder create 创建一个新的卷
# cinder create --display-name myVolume 1
通过cinder list 命令查看是否正确创建
# cinder list