OpenStack安装(三)--Glance

作者:CasonChan     分类:云技术     时间:2014-06-06     浏览:47     评论:0 来源:博客园

Glance组件提供了虚拟机镜像的发现,注册和获取服务,其提供restful API可以查询虚拟机镜像的metadata,并且可以获得镜像。通过Glance,虚拟机镜像可以被存储到多种存储上,比如简单的文件存储或者对象存储(比如OpenStack中swift项目)。

下面记录下Glance组件的整个安装过程:

1、下载Glance源码,并切换到havana分支:

(openstack)[root@casonchan openstack]# git clone git://git.openstack.org/openstack/glance glance
(openstack)[root@casonchan openstack]# cd glance/
(openstack)[root@casonchan glance]# git checkout -b stable/havana remotes/origin/stable/havana

2、安装相关依赖(包括会自动下载安装python-swiftclient、python-cinderclient组件):

(openstack)[root@casonchan glance]# pip install -r requirements.txt

这里遇到了一个错误:

1)No package 'libffi' found" error during pip install
      解决:yum install libffi libffi-devel

3、开始编译安装Glance组件:

(openstack)[root@casonchan glance]# python setup.py install

4、安装 python-glanceclient:

(openstack)[root@casonchan openstack]# git clone git://git.openstack.org/openstack/python-glanceclient  glanceclient
(openstack)[root@casonchan openstack]# cd glanceclient/
(openstack)[root@casonchan glanceclient]# pip install -r requirements.txt
(openstack)[root@casonchan glanceclient]# python setup.py install

5、创建glance配置文件目录和复制配置文件:

(openstack)[root@casonchan glance]# mkdir /etc/glance
(openstack)[root@casonchan glance]# mkdir /var/log/glance
(openstack)[root@casonchan glance]# mkdir /var/lib/glance

(openstack)[root@casonchan glance]# cp etc/* /etc/glance/
(openstack)[root@casonchan glance]# cd /etc/glance/
(openstack)[root@casonchan glance]# mv logging.cnf.sample logging.cnf
(openstack)[root@casonchan glance]# mv property-protections.conf.sample property-protections.conf
(openstack)[root@casonchan glance]# ll
total 56
-rw-r--r-- 1 root root 16210 Feb 24 15:18 glance-api.conf
-rw-r--r-- 1 root root  2603 Feb 24 15:18 glance-api-paste.ini
-rw-r--r-- 1 root root  6190 Feb 24 15:18 glance-cache.conf
-rw-r--r-- 1 root root  3151 Feb 24 15:18 glance-registry.conf
-rw-r--r-- 1 root root   866 Feb 24 15:18 glance-registry-paste.ini
-rw-r--r-- 1 root root  1750 Feb 24 15:18 glance-scrubber.conf
-rw-r--r-- 1 root root   982 Feb 24 15:18 logging.cnf
-rw-r--r-- 1 root root   101 Feb 24 15:18 policy.json
-rw-r--r-- 1 root root   943 Feb 24 15:18 property-protections.conf
-rw-r--r-- 1 root root  1259 Feb 24 15:18 schema-image.json
(openstack)[root@casonchan glance]# 

6、修改 /etc/glance/glance-api.conf 文件:

sed -i 's/#debug = False/debug = True/g' /etc/glance/glance-api.conf
sed -i 's/sql_connection = sqlite:\/\/\/glance.sqlite/sql_connection = mysql:\/\/root:123456@localhost\/glance/g' /etc/glance/glance-api.conf
sed -i 's/#admin_role = admin/admin_role = admin/g' /etc/glance/glance-api.conf
sed -i 's/#allow_anonymous_access = False/allow_anonymous_access = False/g' /etc/glance/glance-api.conf
sed -i 's/#enable_v1_api = True/enable_v1_api = True/g' /etc/glance/glance-api.conf
sed -i 's/#enable_v2_api = True/enable_v2_api = True/g' /etc/glance/glance-api.conf
sed -i 's/notifier_strategy = noop/notifier_strategy = rabbit/g' /etc/glance/glance-api.conf
sed -i 's/admin_tenant_name = %SERVICE_TENANT_NAME%/admin_tenant_name = tenant/g' /etc/glance/glance-api.conf
sed -i 's/admin_user = %SERVICE_USER%/admin_user = glance/g' /etc/glance/glance-api.conf
sed -i 's/admin_password = %SERVICE_PASSWORD%/admin_password = service/g' /etc/glance/glance-api.conf
sed -i 's/#config_file = glance-api-paste.ini/config_file = \/etc\/glance\/glance-api-paste.ini/g' /etc/glance/glance-api.conf
sed -i 's/#flavor=/flavor = keystone/g' /etc/glance/glance-api.conf

7、修改/etc/glance/glance-registry.conf文件:

 sed -i 's/debug = False/debug = True/g' /etc/glance/glance-registry.conf
 sed -i 's/sql_connection = sqlite:\/\/\/glance.sqlite/sql_connection = mysql:\/\/root:123456@localhost\/glance/g' /etc/glance/glance-registry.conf
 sed -i 's/#admin_role = admin/admin_role = admin/g' /etc/glance/glance-registry.conf
 sed -i 's/admin_tenant_name = %SERVICE_TENANT_NAME%/admin_tenant_name = tenant/g' /etc/glance/glance-registry.conf
 sed -i 's/admin_user = %SERVICE_USER%/admin_user = glance/g' /etc/glance/glance-registry.conf
 sed -i 's/admin_password = %SERVICE_PASSWORD%/admin_password = service/g' /etc/glance/glance-registry.conf
 sed -i 's/#config_file = glance-registry-paste.ini/config_file = \/etc\/glance\/glance-registry-paste.ini/g' /etc/glance/glance-registry.conf
 sed -i 's/#flavor=/flavor = keystone/g' /etc/glance/glance-registry.conf

8、初始化数据库:

(openstack)[root@casonchan glance]# mysql -h127.0.0.1 -uroot -p123456 -e 'create database `glance`'
(openstack)[root@casonchan glance]# glance-manage db_sync

初始化成功后,数据库表结构如下:

9、启动服务:

(openstack)[root@casonchan glance]# glance-api --config-file=/etc/glance/glance-api.conf &
(openstack)[root@casonchan glance]# glance-registry --config-file=/etc/glance/glance-registry.conf &

10、确认服务启动成功,其监听端口分别是9191和9292。

 

 

 

本文转载自:http://www.cnblogs.com/CasonChan/p/3563816.html

上一篇:Java从控制台接受输入字符

下一篇:继续寻找app开发的技术方案


0 评论

查看所有评论

给个评论吧