问题导读: 1.cinder如何创建数据库? 2.如何配置数据库? 3.如何添加角色到admin? 4.如何添加一台存储节点,并添加一块硬盘? 须知: 在生产环境中,所有虚拟机磁盘镜像是存在NAS存储架构中的,这样做保证了数据的可靠性,提高性能,可动态迁移。在早期的Openstack版本,用来卷存储的服务是nova-volume,是Nova的一部分,从F版本后,已经独立出来一个核心组件Cinder,首先你要知道Cinder本身不是来提供存储的,它是为后端的存储服务器,提供一个统一的Api来管理,它不去考虑后端存储是什么样的架构,它只需知道后端存储技术使用什么协议来工作的,这样存储技术有:LVM、NFS、iSCSI-SAN、P-SAN、FC-SAN、分布式文件系统,还包括硬件存储厂商Netapp、EMC、IBM都已经支持Openstack。通过这个管理接口,我们可以轻松的管理云硬盘。下面就来部署下Cinder,后端存储技术采用LVM,也是Cinder默认的块存储。
################################################################ Configure Controller Node
一、块存储Cinder服务安装与配置 1.安装块存储服务控制器
- # yum install openstack-cinder
复制代码
2.配置数据库
- # openstack-config --set /etc/cinder/cinder.conf database connection mysql://cinder:CINDER_DBPASS@contro
复制代码
3.创建数据库
- # mysql -u root -p
- mysql> CREATE DATABASEcinder;
- mysql> GRANT ALLPRIVILEGES ON cinder.* TO 'cinder'@'localhost'
- IDENTIFIED BY'CINDER_DBPASS';
- mysql> GRANT ALLPRIVILEGES ON cinder.* TO 'cinder'@'%'
- IDENTIFIED BY'CINDER_DBPASS';
- mysql> exit;
复制代码
4.导入数据库
复制代码
5.创建用户并添加到角色admin
- #keystone user-create --name=cinder --pass=cinder --email=cinder@example.com
- #keystone user-role-add --user=cinder --tenant=service --role=admin
复制代码
6.配置token认证信息
- 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
复制代码
7.配置消息队列qpid
- openstack-config --set /etc/cinder/cinder.conf DEFAULT rpc_backend cinder.openstack.common.rpc.impl_qpid
- openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_hostname controller
- openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_host controller
复制代码
7.1修改/etc/cinder/cinder.conf
- [DEFAULT]
- osapi_volume_listen=0.0.0.0
- state_path=/var/lib/cinder
- volumes_dir=/var/lib/cinder/volumes
复制代码
8.创建cinder服务标识
- # keystone service-create --name=cinder --type=volume --description="OpenStack Block Storage"
- # keystone service-create --name=cinderv2 --type=volumev2 --description="OpenStack Block Storagev2"
复制代码
9.创建Cinder API版本1和版本2接口URL
- # 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 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
复制代码
10.重启服务并设置自启动
- service openstack-cinder-api start
- service openstack-cinder-scheduler start
- service openstack-cinder-volume start
- service tgtd start
- chkconfig openstack-cinder-volume on
- chkconfig tgtd on
- chkconfig openstack-cinder-api on
- chkconfig openstack-cinder-scheduler on
- Configure Storage Node
复制代码
二、添加一台存储节点,并添加一块硬盘
1.ip地址设置为192.168.1.33
2.控制节点和存储节点添加对应host记录
复制代码
3.创建LVM卷
- # pvcreate /dev/sdb
- # vgcreate cinder-volumes/dev/sdb
复制代码
4.安装块存储服务
- # yum installopenstack-cinder scsi-target-utils
复制代码
5.配置token认证信息
- openstack-config --set /etc/cinder/cinder.confDEFAULT auth_strategy keystone
- openstack-config --set /etc/cinder/cinder.conf keystone_authtoken
- auth_urihttp://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
复制代码
6.配置消息队列qpid
- openstack-config --set /etc/cinder/cinder.confDEFAULT
- rpc_backendcinder.openstack.common.rpc.impl_qpid
- openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_hostname controller
复制代码
7.配置连接数据库
- # openstack-config --set /etc/cinder/cinder.conf database
- connection mysql://cinder:CINDER_DBPASS@controller/cinder
复制代码
8.配置glance服务位置
- # openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_host controller
复制代码
9.配置iSCSI目标发现块存储,使用iSCSI协议时使用
- # vi /etc/tgt/targets.conf
- include /etc/cinder/volumes/*
复制代码
10.启动服务并设置自启动
- service openstack-cinder-volume start
- service tgtd start
- chkconfig openstack-cinder-volume on
- chkconfig tgtd on
复制代码
11.创建一个10G的卷
- # source admin-openrc.sh
- # cinder create--display-name myVolume 10
复制代码
12.查看创建的卷,下面是我实验后的
13.登录Horizon查看 配置完成后,dashboard上面会生成一个云硬盘选项
|