前面一段时间已经完成了Keystone、Swift、Glance、Nova、Horizon的升级,官网文档已经明确表示“NOVA-VOLUMES IS DEPRECATED Please migrate to cinder as soon as possible”。 需要注意的是迁移只能从F版的nova-volume到F版的Cinder,如果是E版的nova-volume需要先升级到F版再迁移。在我的安装中,10.61.2.12做为控制节点,将运行cinder-api及cinder-scheduler服务, 另外mysql及qpid也运行在该节点上,10.61.2.13-15作为存储节点将运行cinder-volume服务。注意因为我这里是完成从nova-volume到cinder的迁移,cinder所需的依赖包已经安装了,这里就不作讨论了, 如果有缺少的话根据运行cinder相关服务的出错提示安装相关依赖即可。
目前Cinder的安装文档比较少,在官方文档中我只找到以下两个比较有价值的:
http://wiki.openstack.org/MigrateToCinderhttp://docs.openstack.org/trunk/openstack-compute/install/apt/content/osfolubuntu-cinder.html 下面首先安装控制节点。
下载并安装Cinder
[root@stackcc update_cinder]# wget https://launchpad.net/cinder/folsom/2012.2.1/+download/cinder-2012.2.1.tar.gz
[root@stackcc update_cinder]# tar -xzf cinder-2012.2.1.tar.gz
[root@stackcc update_cinder]# cd cinder-2012.2.1
[root@stackcc cinder-2012.2.1]# python setup.py install > ../install.log
配置Cinder
[root@stackcc cinder-2012.2.1]# cp -R etc/cinder /etc/
修改api-paste.ini文件,注意将我这里设置的service、cinder、service123改成你希望设置的tenant name、user、password,或者保持默认也可。
[root@stackcc cinder-2012.2.1]# sed -i -e 's/127.0.0.1/10.61.2.12/' \
-e 's/\(admin_tenant_name = \).*/\1service/' \
-e 's/\(admin_user = \).*/\1cinder/' \
-e 's/\(admin_password = \).*/\1service123/' \
/etc/cinder/api-paste.ini
创建cinder.conf文件
[root@stackcc cinder-2012.2.1]# cat /etc/cinder/cinder.conf
[DEFAULT]
# LOGS/STATE
#verbose=True
logdir=/var/log/cinder
state_path=/var/lib/cinder
lock_path=/var/lock/cinder
api_paste_config=/etc/cinder/api-paste.ini
# AUTHENTICATION
auth_strategy=keystone
# VOLUMES
volume_group=nova-volumes
volume_name_template=volume-%s
iscsi_helper=tgtadm
# NETWORK
my_ip=10.61.2.12
# DATABASE
sql_connection=mysql://cinder:cinder@10.61.2.12/cinder
# QPID
rpc_backend=cinder.openstack.common.rpc.impl_qpid
qpid_hostname=10.61.2.12
# SUDO
rootwrap_config=/etc/cinder/rootwrap.conf
创建cinder用户的sudo文件,注意文件的权限及所有者
[root@stackcc cinder-2012.2.1]# ll /etc/sudoers.d/cinder
-r--r----- 1 root root 112 Dec 14 19:35 /etc/sudoers.d/cinder
[root@stackcc cinder-2012.2.1]# cat /etc/sudoers.d/cinder
Defaults:cinder !requiretty
cinder ALL = (root) NOPASSWD: /usr/bin/cinder-rootwrap /etc/cinder/rootwrap.conf *
创建相关目录及系统用户
[root@stackcc cinder-2012.2.1]# mkdir -p /var/lib/cinder/volumes
[root@stackcc cinder-2012.2.1]# mkdir -p /var/lock/cinder
[root@stackcc cinder-2012.2.1]# mkdir -p /var/run/cinder
[root@stackcc cinder-2012.2.1]# mkdir -p /var/log/cinder
[root@stackcc cinder-2012.2.1]# useradd -d /var/lib/cinder -r -s /sbin/nologin -M cinder
[root@stackcc cinder-2012.2.1]# chown -R cinder:cinder /var/*/cinder
[root@stackcc cinder-2012.2.1]# chown -R cinder:cinder /etc/cinder
[root@stackcc cinder-2012.2.1]# chmod -R 640 /etc/cinder/*
[root@stackcc cinder-2012.2.1]# chown -R root:root /etc/cinder/rootwrap.*
[root@stackcc cinder-2012.2.1]# chmod 755 /etc/cinder/rootwrap.d
创建数据库及用户
[root@stackcc cinder-2012.2.1]# mysql -uroot -p -e "create database cinder"
[root@stackcc cinder-2012.2.1]# mysql -uroot -p -e "grant all privileges on cinder.* to 'cinder'@'%' identified by 'cinder'"
[root@stackcc cinder-2012.2.1]# cinder-manage db sync
cinder-manage migrate import_db --src=mysql://nova:nova@10.61.2.12 --dest=mysql://cinder:cinder@10.61.2.12
修改nova配置
修改/etc/nova/nova.conf文件,添加或重置以下两个选项,并删除其它与volume有关的配置项,然后重启nova-api,注意:所有的nova-compute节点的配置文件也都要修改并重启服务, 并且nova-compute现在依赖python-cinderclient了,如果以前没有安装的话可以通过pip install python-cinderclient安装。
volume_api_class=nova.volume.cinder.API
enabled_apis=ec2,osapi_compute,metadata
创建Keystone用户
[root@stackcc cinder-2012.2.1]# keystone user-create --name cinder --pass service123 --email cinder@example.com
[root@stackcc cinder-2012.2.1]# keystone user-list
+----------------------------------+--------+---------+--------------------+
| id | name | enabled | email |
+----------------------------------+--------+---------+--------------------+
| e33c18e721de4ba5beeab5f69adfb185 | cinder | True | cinder@example.com |
+----------------------------------+--------+---------+--------------------+
[root@stackcc cinder-2012.2.1]# keystone role-list
+----------------------------------+----------------------+
| id | name |
+----------------------------------+----------------------+
| f5210621c1e7402c8ca94c085848faf2 | admin |
+----------------------------------+----------------------+
[root@stackcc cinder-2012.2.1]# keystone tenant-list
+----------------------------------+---------+---------+
| id | name | enabled |
+----------------------------------+---------+---------+
| b61cec3f3a47403e9cfeb49c12af29ab | service | True |
+----------------------------------+---------+---------+
[root@stackcc cinder-2012.2.1]# keystone user-role-add \
--user-id e33c18e721de4ba5beeab5f69adfb185 \
--role-id f5210621c1e7402c8ca94c085848faf2 \
--tenant-id b61cec3f3a47403e9cfeb49c12af29ab
创建init脚本
init脚本来源于elep源中的openstack Folsom版,只是去掉了openstack-前缀,有了init脚本就可以通过service管理cinder了,如service cinder-api start。
[root@stackcc cinder-2012.2.1]# cat /etc/rc.d/init.d/cinder-api
#!/bin/sh
#
# cinder-api OpenStack cinder API Server
#
# chkconfig: - 98 02
# description: At the heart of the cloud framework is an API Server. \
# This API Server makes command and control of the \
# hypervisor, storage, and networking programmatically \
# available to users in realization of the definition \
# of cloud computing.
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $syslog
# Default-Stop: 0 1 6
# Short-Description: OpenStack cinder API Server
# Description: At the heart of the cloud framework is an API Server.
# This API Server makes command and control of the
# hypervisor, storage, and networking programmatically
# available to users in realization of the definition
# of cloud computing.
### END INIT INFO
. /etc/rc.d/init.d/functions
suffix=api
prog=cinder-$suffix
exec="/usr/bin/cinder-$suffix"
config="/etc/cinder/cinder.conf"
pidfile="/var/run/cinder/cinder-$suffix.pid"
logfile="/var/log/cinder/$suffix.log"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon --user cinder --pidfile $pidfile "$exec --config-file $config --logfile $logfile &>/dev/null & echo \$! > $pidfile"
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
[root@stackcc cinder-2012.2.1]# cat /etc/rc.d/init.d/cinder-scheduler
#!/bin/sh
#
# cinder-scheduler OpenStack cinder Scheduler
#
# chkconfig: - 98 02
# description: Determines which physical hardware to allocate to a virtual resource
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $syslog
# Default-Stop: 0 1 6
# Short-Description: OpenStack cinder Scheduler
# Description: Determines which physical hardware to allocate to a virtual resource
### END INIT INFO
. /etc/rc.d/init.d/functions
suffix=scheduler
prog=cinder-$suffix
exec="/usr/bin/cinder-$suffix"
config="/etc/cinder/cinder.conf"
pidfile="/var/run/cinder/cinder-$suffix.pid"
logfile="/var/log/cinder/$suffix.log"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon --user cinder --pidfile $pidfile "$exec --config-file $config --logfile $logfile &>/dev/null & echo \$! > $pidfile"
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
现在可以在控制节点启动cinder-api和cinder-scheduler了
[root@stackcc cinder-2012.2.1]# chkconfig cinder-api on && service cinder-api start
[root@stackcc cinder-2012.2.1]# chkconfig cinder-scheduler on && service cinder-scheduler status
安装存储节点
存储节点的安装基本同上,只是不再需要在Mysql和Keystone中创建相关信息,另外还要修改tgtd服务的配置,CentOS下是修改如下:
[root@stackcc cinder-2012.2.1]# sed -i '/volumes/d' /etc/tgt/targets.conf
[root@stackcc cinder-2012.2.1]# sed -i '/^#include/a\include /var/lib/cinder/volumes/\*' /etc/tgt/targets.conf
为了方便管理服务,创建以下init脚本:
[root@stackcc cinder-2012.2.1]# cat /etc/rc.d/init.d/cinder-volume
#!/bin/sh
#
# cinder-volume OpenStack cinder Volume Worker
#
# chkconfig: - 98 02
# description: Volume Workers interact with iSCSI storage to manage \
# LVM-based instance volumes. Specific functions include: \
# * Create Volumes \
# * Delete Volumes \
# * Establish Compute volumes
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $syslog
# Default-Stop: 0 1 6
# Short-Description: OpenStack cinder Volume Worker
# Description: Volume Workers interact with iSCSI storage to manage
# LVM-based instance volumes. Specific functions include:
# * Create Volumes
# * Delete Volumes
# * Establish Compute volumes
### END INIT INFO
. /etc/rc.d/init.d/functions
suffix=volume
prog=cinder-$suffix
exec="/usr/bin/cinder-$suffix"
config="/etc/cinder/cinder.conf"
pidfile="/var/run/cinder/cinder-$suffix.pid"
logfile="/var/log/cinder/$suffix.log"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon --user cinder --pidfile $pidfile "$exec --config-file $config --logfile $logfile &>/dev/null & echo \$! > $pidfile"
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?
到这里Cinder的安装算是完成了,但是如果你是从Essex升级到Folsom,然后再从nova-volume迁移到Cinder的话,原来在Essex下创建的volume还有一些问题,暂时还不可用,这个我下次再写。。。
姜永