作者:【吴业亮】云计算开发工程师
博客:http://blog.csdn.net/wylfengyujiancheng
1、创建cinder数据库
# mysql -uroot -pChangeme_123 -e "CREATE DATABASE cinder;"
注意:Changeme_123为数据库root密码
2、创建数据库用户并赋予权限
# mysql -uroot -pChangeme_123 -e "GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'Changeme_123';"
# mysql -uroot -pChangeme_123 -e "GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'Changeme_123';"
注意:Changeme_123为数据库root密码
3、创建cinder用户并赋予admin权限
# openstack user create --domain default cinder --password Changeme_123 # openstack role add --project service --user cinder admin
4、创建volume服务
# openstack service create --name cinder --description "OpenStack Block Storage" volume
# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
5、创建endpoint
# openstack endpoint create --region RegionOne volume public http://${HOSTNAME}:8776/v1/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volume internal http://${HOSTNAME}:8776/v1/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volume admin http://${HOSTNAME}:8776/v1/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volumev2 public http://${HOSTNAME}:8776/v2/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volumev2 internal http://${HOSTNAME}:8776/v2/%\(tenant_id\)s
# openstack endpoint create --region RegionOne volumev2 admin http://${HOSTNAME}:8776/v2/%\(tenant_id\)s
6、安装cinder相关服务
# yum install openstack-cinder python-cinderclient -y
7、复制/usr/share/cinder/cinder-dist.conf为/etc/cinder/cinder.conf
# cp /usr/share/cinder/cinder-dist.conf /etc/cinder/cinder.conf
# chown -R cinder:cinder /etc/cinder/cinder.conf
8、配置cinder配置文件
# openstack-config --set /etc/cinder/cinder.conf database connection mysql://cinder:Changeme_123@${HOSTNAME}/cinder
# openstack-config --set /etc/cinder/cinder.conf DEFAULT rpc_backend rabbit
# openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_host ${HOSTNAME}
# openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_userid openstack
# openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_password Changeme_123
# openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://${HOSTNAME}:5000
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://${HOSTNAME}:35357
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_plugin password
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_domain_id default
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken user_domain_id default
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_name service
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken username cinder
# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken password Changeme_123
# openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip ETH0_IP
# openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
# openstack-config --set /etc/cinder/cinder.conf DEFAULT verbose True
注意替换Changeme_123为自己的密码,将ETH0_IP替换为eth0的IP
9、同步数据库
# su -s /bin/sh -c "cinder-manage db sync" cinder
10、配置nova配置文件
# openstack-config --set /etc/nova/nova.conf cinder os_region_name RegionOne
11、重启nova服务
# systemctl restart openstack-nova-api.service
12、启动cinder服务,并设置开机启动
# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
13、安装qemu和 lvm2
yum install qemu lvm2 -y
14、启动lvm2-lvmetad和设置开机前启动
# systemctl enable lvm2-lvmetad.service
# systemctl start lvm2-lvmetad.service
15、创建lvm
# pvcreate /dev/sdb
# vgcreate cinder-volumes /dev/sdb
注意:此处需要系统新增分区或磁盘。
16、安装openstack-cinder、targetcli 和python-oslo-policy
yum install openstack-cinder targetcli python-oslo-policy -y
17、配置cinder配置文件
# openstack-config --set /etc/cinder/cinder.conf lvm volume_driver cinder.volume.drivers.lvm.LVMVolumeDriver
# openstack-config --set /etc/cinder/cinder.conf lvm volume_group cinder-volumes
# openstack-config --set /etc/cinder/cinder.conf lvm iscsi_protocol iscsi
# openstack-config --set /etc/cinder/cinder.conf lvm iscsi_helper lioadm
# openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_host ${HOSTNAME}
# openstack-config --set /etc/cinder/cinder.conf DEFAULT enabled_backends lvm
# openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
18、启动openstack-cinder-volume和target并设置开机启动
# systemctl enable openstack-cinder-volume.service target.service
# systemctl start openstack-cinder-volume.service target.service
19、验证
# source /root/admin-openrc.sh
# cinder service-list