controller:

yum install openstack-cinder


配置cinder服务的数据库连接

openstack-config --set /etc/cinder/cinder.conf database connection mysql://cinder:openstack@controller/cinder


初始化cinder数据库

mysql -u root -popenstack

mysql> CREATE DATABASE cinder;

mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \

IDENTIFIED BY 'openstack';

mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \

IDENTIFIED BY 'openstack';


创建cinder数据库表

su -s /bin/sh -c "cinder-manage db sync" cinder


创建cinder用户并赋予管理员角色

keystone user-create --name=cinder --pass=cinder [email protected]

keystone user-role-add --user=cinder --tenant=service --role=admin


配置cinder认证服务

openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://controller:5000

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_host controller

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_protocol http

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_port 35357

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_user cinder

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_tenant_name service

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_password cinder


配置cinder服务的消息代理

openstack-config --set /etc/cinder/cinder.conf DEFAULT rpc_backend qpid

openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_hostname controller


创建cinder服务和端口

keystone service-create --name=cinder --type=volume --description="OpenStack Block Storage"

keystone endpoint-create \

--service-id=$(keystone service-list | awk '/ volume / {print $2}') \

--publicurl=http://controller:8776/v1/%\(tenant_id\)s \

--internalurl=http://controller:8776/v1/%\(tenant_id\)s \

--adminurl=http://controller:8776/v1/%\(tenant_id\)s


keystone service-create --name=cinderv2 --type=volumev2 --description="OpenStack Block Storage v2"

keystone endpoint-create \

--service-id=$(keystone service-list | awk '/ volumev2 / {print $2}') \

--publicurl=http://controller:8776/v2/%\(tenant_id\)s \

--internalurl=http://controller:8776/v2/%\(tenant_id\)s \

--adminurl=http://controller:8776/v2/%\(tenant_id\)s


启动服务,并且加入到开机启动

service openstack-cinder-api restart

service openstack-cinder-scheduler restart

chkconfig openstack-cinder-api on

chkconfig openstack-cinder-scheduler on


block1(主机名)


安装相关包

yum install openstack-cinder scsi-target-utils


创建物理卷和逻辑卷

pvcreate /dev/sdb

vgcreate cinder-volumes /dev/sdb


vim /etc/lvm/lvm.conf

devices {

...

filter = [ "a/sda1/", "a/sdb/", "r/.*/" ]

...

}




配置cinder服务的认证


openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://controller:5000

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_host controller

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_protocol http

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_port 35357

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_user cinder

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_tenant_name service

openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_password cinder


配置cinder服务的消息代理


openstack-config --set /etc/cinder/cinder.conf DEFAULT rpc_backend qpid

openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_hostname controller


配置cinder服务的数据库连接


openstack-config --set /etc/cinder/cinder.conf database connection mysql://cinder:openstack@controller/cinder


配置块存储使用tgtadm iSCSI service

openstack-config --set /etc/cinder/cinder.conf DEFAULT iscsi_helper tgtadm


配置cinder服务使用Image服务

openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_host controller


openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 10.0.0.41


配置iSCS目标服务发现块存储的卷

vim /etc/tgt/targets.conf

include /etc/cinder/volumes/*


启动服务并且加入到开机启动

service openstack-cinder-volume restart

service tgtd restart

chkconfig openstack-cinder-volume on

chkconfig tgtd on


验证cinder服务

source demo-openrc.sh


创建一个新的volume

cinder create --display-name myVolume 1


创建卷失败,查看 vim /var/log/cinder/scheduler.log 提示找不到服务

36e931b4bb304ef0898b6393e30bf481] Failed to schedule_create_volume: No valid host was found.


cinder-manage service list

cinder-volume    cinder                nova             enabled    XXX   2015-07-16 23:51:15



解决办法:

block1节点: date

controller节点: date

配置ntp服务,使时间一致,重启有关cinder的各种服务,再次创建成功。


查看volume的列表

cinder list