OpenStack版本升级之Glance

F版的一些变化

对依赖库的变化主要是添加了一个jsonschema并去掉了对xattr、pysendfile及swift1.4.8的依赖,如果采用swift作为存储后端需要有python-swiftclient,另外还需要F版的Keystone。配置方面主要把认证中间件的配置从paste配置中移到了server配置中。功能上添加了V2版的api接口。

备份与安装

停止现有服务,并备份数据

[root@stackcc update_glance]# service glance-api stop
[root@stackcc update_glance]# service glance-registry stop
[root@stackcc update_glance]# cp -R /etc/glance ./glance-etc
[root@stackcc update_glance]# mysqldump -uglance -p glance > glance.sql

下载并安装相关软件,因为我之前已经升级完了Keystone及Swift,这里只要安装jsonschema及Glance就可以了。

[root@stackcc update_glance]# pip install jsonschema
[root@stackcc update_glance]# git clone git://github.com/openstack/glance.git
[root@stackcc update_glance]# cd glance
[root@stackcc glance]# git checkout -b folsom origin/stable/folsom
[root@stackcc glance]# python setup.py install > install.info

补充:如果还要在这台服务器上安装python-glanceclient的话,这里用pip install jsonschema==0.2安装就好,不然也会被删除重装的。原本采用以下方式安装glance的,安装后版本号不对成了0.0.0,我提了个bug在这(详情)

[root@stackcc update_glance]# wget https://github.com/openstack/glance/archive/stable/folsom.zip
[root@stackcc update_glance]# unzip folsom 
[root@stackcc update_glance]# cd glance-stable-folsom/
[root@stackcc glance-stable-folsom]# python setup.py install
[root@stackcc glance-stable-folsom]# ll /usr/lib/python2.6/site-packages/ | grep glance
drwxr-xr-x 4 root root 4096 Nov 14 17:00 glance-0.0.0-py2.6.egg
drwxr-xr-x. 4 root root 4096 Jun 2 21:56 glance-2012.1-py2.6.egg

配置Glance

将F的配置文件拷入到/etc/glance下替换掉原来的文件并修改相关配置,我的修改如下:

[root@stackcc etc]# for file in *; do diff -u $file /etc/glance/$file; done
--- glance-api.conf    2012-11-14 19:12:12.011623218 +0800
+++ /etc/glance/glance-api.conf    2012-11-16 09:44:37.534701521 +0800
@@ -9,7 +9,7 @@
 # in a request to add a new image to Glance? Known schemes are determined
 # by the known_stores option below.
 # Default: 'file'
-default_store = file
+default_store = swift
 
 # List of which store classes and store class locations are
 # currently known to glance at startup.
@@ -46,7 +46,7 @@
 # SQLAlchemy connection string for the reference implementation
 # registry server. Any valid SQLAlchemy connection string is fine.
 # See: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine
-sql_connection = sqlite:///glance.sqlite
+sql_connection = mysql://glance:glance@localhost/glance
 
 # Period in seconds after which SQLAlchemy should reestablish its connection
 # to the database.
@@ -137,7 +137,7 @@
 # There are three methods of sending notifications, logging (via the
 # log_file directive), rabbit (via a rabbitmq queue), qpid (via a Qpid
 # message queue), or noop (no notifications sent, the default)
-notifier_strategy = noop
+notifier_strategy = qpid
 
 # Configuration options if sending notifications via rabbitmq (these are
 # the defaults)
@@ -192,7 +192,7 @@
 # If you use Swift authentication service, set it to 'account':'user'
 # where 'account' is a Swift storage account and 'user'
 # is a user in that account
-swift_store_user = jdoe:jdoe
+swift_store_user = service:glance
 
 # Auth key for the user authenticating against the
 # Swift authentication service
@@ -203,7 +203,7 @@
 swift_store_container = glance
 
 # Do we create the container if it does not exist?
-swift_store_create_container_on_put = False
+swift_store_create_container_on_put = True
 
 # What size, in MB, should Glance start chunking image files
 # and do a large object manifest in Swift? By default, this is
@@ -311,16 +311,16 @@
 auth_host = 127.0.0.1
 auth_port = 35357
 auth_protocol = http
-admin_tenant_name = %SERVICE_TENANT_NAME%
-admin_user = %SERVICE_USER%
-admin_password = %SERVICE_PASSWORD%
+admin_tenant_name = service
+admin_user = glance
+admin_password = service123
 
 [paste_deploy]
 # Name of the paste configuration file that defines the available pipelines
-#config_file = glance-api-paste.ini
+config_file = /etc/glance/glance-api-paste.ini
 
 # Partial name of a pipeline in your paste configuration file with the
 # service name removed. For example, if your paste section name is
 # [pipeline:glance-api-keystone], you would configure the flavor below
 # as 'keystone'.
-#flavor=
+flavor=keystone
--- glance-registry.conf    2012-11-14 19:10:51.688606629 +0800
+++ /etc/glance/glance-registry.conf    2012-11-14 19:48:43.600719378 +0800
@@ -25,7 +25,7 @@
 # SQLAlchemy connection string for the reference implementation
 # registry server. Any valid SQLAlchemy connection string is fine.
 # See: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine
-sql_connection = sqlite:///glance.sqlite
+sql_connection = mysql://glance:glance@localhost/glance
 
 # Period in seconds after which SQLAlchemy should reestablish its connection
 # to the database.
@@ -71,16 +71,16 @@
 auth_host = 127.0.0.1
 auth_port = 35357
 auth_protocol = http
-admin_tenant_name = %SERVICE_TENANT_NAME%
-admin_user = %SERVICE_USER%
-admin_password = %SERVICE_PASSWORD%
+admin_tenant_name = service
+admin_user = glance
+admin_password = service123
 
 [paste_deploy]
 # Name of the paste configuration file that defines the available pipelines
-#config_file = glance-registry-paste.ini
+config_file = /etc/glance/glance-registry-paste.ini
 
 # Partial name of a pipeline in your paste configuration file with the
 # service name removed. For example, if your paste section name is
 # [pipeline:glance-registry-keystone], you would configure the flavor below
 # as 'keystone'.
-#flavor=
+flavor=keystone

注意这里的config_file文件的路径要写绝对路径,不然在用glance index命令时就只出了个标题行,就没其它内容了,也不返回。

补充:使用swift作为存储后端时还要修改swift_store_auth_address和swift_store_key两项,第一项要指明协议http不然采用默认的https协议的话会报:

Error uploading image: (AuthorizationFailure): Authorization Failed: Unable to communicate with identity service: [Errno 1] _ssl.c:490: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol. (HTTP 400)
第二项应修改为swift_store_user用户的密码,否则会报:
Error uploading image: (Unauthorized): Unable to communicate with identity service: {"error": {"message": "Invalid user / password", "code": 401, "title": "Not Authorized"}}. (HTTP 401)

同步数据库并启动相关服务

[root@stackcc glance]# glance-manage db_sync
[root@stackcc glance]# glance-manage db_version
15
[root@stackcc glance]# service glance-api start
[root@stackcc glance]# service glance-registry start
[root@stackcc glance]# service glance-api status
glance-api (pid  13218) is running...
[root@stackcc glance]# service glance-registry status
glance-registry (pid  13331) is running...

测试命令glance index发现有警告,可以通过pip install python-glanceclient安装新版的glanceclient并且会依赖安装python-keystoneclient,替换我刚安装的jsonschema为0.2版本,升级prettytable==0.6.1,如果机器上安装有E版的novaclient会冲突,可以用pip uninstall python-novaclient直接卸载再用pip install python-novaclient安装新版(这里我尝试不卸载老版直接安装没有反应)。最后如果要使用v2版api还需要调整Keystone中的endpoint。

北方工业大学 | 云计算研究中心 | 姜永

你可能感兴趣的:(OpenStack版本升级之Glance)