须知:
根据上次基础环境部署,已经可以使用dashboard创建和管理虚拟机了。在生产环境中,所有虚拟机磁盘镜像是存在NAS存储架构中的,这样做保证了数据的可靠性,提高性能,可动态迁移。在早期的Openstack版本,用来卷存储的服务是nova-volume,是Nova的一部分,从F版本后,已经独立出来一个核心组件Cinder,首先你要知道Cinder本身不是来提供存储的,它是为后端的存储服务器,提供一个统一的Api来管理,它不去考虑后端存储是什么样的架构,它只需知道后端存储技术使用什么协议来工作的,这样存储技术有:LVM、NFS、IP-SAN、FC-SAN、分布式文件系统等,还包括硬件存储厂商NetApp、EMC、IBM都已经支持Openstack。通过这个管理接口,我们可以轻松的管理云硬盘。
下面就来部署下Cinder,后端存储技术采用LVM卷和iSCSI共享存储,也是Cinder默认的块存储。
#########################################################################################
Configure Controller Node
一、块存储Cinder服务安装与配置
1.安装块存储服务控制器
# yum install openstack-cinder
2.配置数据库
# openstack-config --set /etc/cinder/cinder.conf database connection mysql://cinder:CINDER_DBPASS@controller/cinder
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.导入数据库
# cinder-manage db sync
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认证信息
1
2
3
4
5
6
7
8
|
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
1
2
3
|
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
1
2
3
4
5
|
# 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
|
1
2
3
4
5
|
# 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.重启服务并设置自启动
1
2
3
4
5
6
7
8
|
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
|
博客地址:http://lizhenliang.blog.51cto.com
Configure Storage Node
二、添加一台存储节点,并添加一块硬盘
1.ip地址设置为192.168.1.33
2.控制节点和存储节点添加对应host记录
192.168.1.33 storage
3.创建LVM卷
# pvcreate /dev/sdb
# vgcreate cinder-volumes/dev/sdb
4.安装块存储服务
# yum install openstack-cinder scsi-target-utils
5.配置token认证信息
1
2
3
4
5
6
7
8
9
10
|
openstack-config --
set
/etc/cinder/cinder
.conf DEFAULT 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
1
2
3
|
openstack-config --
set
/etc/cinder/cinder
.conf DEFAULT
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.启动服务并设置自启动
1
2
3
4
|
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.查看创建的卷,下面是我实验后的
配置完成后,dashboard上面会生成一个云硬盘选项
本文转自 李振良OK 51CTO博客,原文链接:http://blog.51cto.com/lizhenliang/1436963,如需转载请自行联系原作者