OpenStack安装流程(juno版)- 添加镜像服务(glance)

OpenStack镜像服务(glance)可以让用户查询,存取虚拟机。

安装和配置

glance安装在controller节点上。

创建配置glance所需的数据库,服务证书和API端点

  1. 创建glance数据库:
    用root身份进入数据库:
    $ mysql -u root -p

    创建glance数据库:
    <pre>CREATE DATABASE glance;</pre>

    把glance数据库的访问权限赋予名为glance,来自任何主机地址的用户,并设定访问密码为GLANCE_DBPASS(替换为合适的密码):
    <pre>GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';

GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';</pre>

退出数据库。

  1. 启动admin证书:
    $ source admin-openrc.sh
  2. 创建glance的服务证书:

    创建glance用户:
    <pre>$ keystone user-create --name glance --pass GLANCE_PASS

PropertyValue
email
enabledTrue
id9d458c5ef8854904ae279f25bbbc5b8b
nameglance
usernameglance

+----------+----------------------------------+</pre>
用合适的密码替换GLANCE_PASS。

admin角色赋予给glance用户:
$ keystone user-role-add --user glance --tenant service --role admin
这条命令不产生输出显示。

创建glance服务实体:
<pre>$ keystone service-create --name glance --type image \

--description "OpenStack Image Service"
PropertyValue
descriptionOpenStack Image Service
enabledTrue
id8247ab1fa1be4b75aef86889ad66698d
nameglance
typeimage

+-------------+----------------------------------+</pre>

  1. 创建镜像服务的API端点:
    <pre>$ keystone endpoint-create \

--service-id $(keystone service-list | awk '/ image / {print $2}') \
--publicurl http://controller:9292 \
--internalurl http://controller:9292 \
--adminurl http://controller:9292 \

--region regionOne
PropertyValue
adminurl http://controller:9292
idac47c90ff5c842eda22e59d408bc5bbf
internalurl http://controller:9292
publicurl http://controller:9292
regionregionOne
service_id8247ab1fa1be4b75aef86889ad66698d

+-------------+----------------------------------+</pre>

安装和配置镜像服务的组件

  1. 安装所需包:
    # apt-get install glance python-glanceclient
  2. 编辑# vi /etc/glance/glance-api.conf文件:

    [database]部分,设定数据库的访问选项:
    <pre>[database]

...
connection = mysql://glance:GLANCE_DBPASS@controller/glance</pre>
GLANCE_DBPASS为创建glance数据库时设立的密码。

[keystone_authtoken][paste_deploy]部分,设定认证服务的选项:
<pre>[keystone_authtoken]
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = GLANCE_PASS
</pre>

<pre>[paste_deploy]
...
flavor = keystone
</pre>
GLANCE_PASS为创建glance用户时使用的密码。在[keystone_authtoken]部分,注释掉 auth_host,auth_port,和auth_protocol的选项,因为identity_uri选项是直接代替它们的。

[glance_store]部分,设定本地文件系统存储方式(local file system store)和镜像文件的存储位置:
<pre>[glance_store]
...
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
</pre>

[DEFAULT]部分,将notification driver设定为noop来关闭通知,因为通知服务将由Telemetry服务来提供:
<pre>[DEFAULT]
...
notification_driver = noop
</pre>
继续在[DEFAULT]部分,开启“详细输出日志”选项:
<pre>[DEFAULT]
...
verbose = True
</pre>

  1. 编辑# vi /etc/glance/glance-registry.conf 文件:

    [database]部分,设定数据库的访问选项:
    <pre>[database]

...
connection = mysql://glance:GLANCE_DBPASS@controller/glance</pre>
GLANCE_DBPASS为创建glance数据库时设立的密码。

[keystone_authtoken][paste_deploy]部分,设定认证服务的选项:
<pre>[keystone_authtoken]
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = GLANCE_PASS
</pre>

<pre>[paste_deploy]
...
flavor = keystone
</pre>
GLANCE_PASS为创建glance用户时使用的密码。在[keystone_authtoken]部分,注释掉 auth_host,auth_port,和auth_protocol的选项,因为identity_uri选项是直接代替它们的。

[DEFAULT]部分,将notification driver设定为noop来关闭通知,因为通知服务将由Telemetry服务来提供:
<pre>[DEFAULT]
...
notification_driver = noop
</pre>
继续在[DEFAULT]部分,开启“详细输出日志”选项:
<pre>[DEFAULT]
...
verbose = True
</pre>

  1. 同步数据库:
    # glance-manage db_sync

完成安装

  1. 重启镜像服务:

# service glance-registry restart
# service glance-api restart

  1. 删除Ubuntu默认产生的SQLite数据库:

# rm -f /var/lib/glance/glance.sqlite

验证操作

这节采用CirrOS,一种非常小的Linux镜像,来进行验证。

  1. 下载镜像:
    镜像的下载地址为:http://download.cirros-cloud....
    $ wget http://download.cirros-cloud....
  2. 启动admin证书:
    $ source admin-openrc.sh
  3. 上传镜像文件到镜像服务上:
    <pre>$ glance image-create --name "cirros-0.3.3-x86_64" --file /home/controller/Downloads/cirros-0.3.3-x86_64-disk.img \

--disk-format qcow2 --container-format bare --is-public True --progress

[=============================>] 100%
PropertyValue
checksum133eae9fb1c98f45894a4e60d8736619
container_formatbare
created_at2015-11-25T03:04:22
deletedFalse
deleted_atNone
disk_formatqcow2
id6db9f9c9-4011-4cf5-a12b-dc70423ec0c3
is_publicTrue
min_disk0
min_ram0
namecirros-0.3.3-x86_64
owner4f7806287c9a437e9cd912504ff71727
protectedFalse
size13200896
statusactive
updated_at2015-11-25T03:04:22
virtual_sizeNone

+------------------+--------------------------------------+</pre>

  1. 确认上传的镜像文件:
    <pre>$ glance image-list
IDNameDisk FormatContainer FormatSizeStatus
6db9f9c9-4011-4cf5-a12b-dc70423ec0c3cirros-0.3.3-x86_64qcow2bare13200896active

+--------------------------------------+---------------------+-------------+------------------+----------+--------+</pre>

至此完成glance的安装,本节安装较为简单一般不会出现问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值