<手动安装Openstack Mikita>之(三) Glance安装

来源:互联网 发布:全民枪战刷龙软件 编辑:程序博客网 时间:2024/05/21 19:21

手动安装Openstack Mikita的第三部分: 镜像服务Glance安装. 这部分内容主要是对OpenStack Installation Guide for Red Hat Enterprise Linux and CentOS在Glance这部分内容的实践总结.

The Image service (glance) enables users to discover, register, and retrieve virtual machine images. It offers a REST API that enables you to query virtual machine image metadata and retrieve an actual image. You can store virtual machine images made available through the Image service in a variety of locations, from simple file systems to object-storage systems like OpenStack Object Storage.

为了简化操作, 我们将Glance服务安装在controller节点. 默认的镜像目录为 /var/lib/glance/images/ . 以下操作均在controller节点进行.

一. 安装前准备

1. 为Glance创建数据库

[root@controller ~]# mysql -u root -pCREATE DATABASE glance;GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \  IDENTIFIED BY 'GLANCE_DBPASS';GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \  IDENTIFIED BY 'GLANCE_DBPASS';

其中, GLANCE_DBPASS是Glance访问数据库时使用的密码.

2. 创建Service和API Endpoint

(1) 获取admin-only CLI指令的权限

[root@controller ~]# . admin-openrc

(2) 创建glance用户

[root@controller ~]# openstack user create --domain default --password-prompt glanceUser Password:Repeat User Password:+-----------+----------------------------------+| Field     | Value                            |+-----------+----------------------------------+| domain_id | 23445595d52c44be995b0b393870b5ef || enabled   | True                             || id        | dee5c1d866804d2a83d6f5f62c329dc4 || name      | glance                           |+-----------+----------------------------------+

这里glance用户的密码为: zzr.

(3) 把glance用户增加到admin角色和service租户

[root@controller ~]# openstack role add --project service --user glance admin

(4) 创建image服务

[root@controller ~]# openstack service create --name glance \  --description "OpenStack Image" image+-------------+----------------------------------+| Field       | Value                            |+-------------+----------------------------------+| description | OpenStack Image                  || enabled     | True                             || id          | 9df122e5374742cb9bfd1bec48622f30 || name        | glance                           || type        | image                            |+-------------+----------------------------------+

(5) 创建image服务的Endpoints

  • public endpoint
[root@controller ~]# openstack endpoint create --region RegionOne \  image public http://controller:9292+--------------+----------------------------------+| Field        | Value                            |+--------------+----------------------------------+| enabled      | True                             || id           | 7ddc527f399f4592943c0ac687e313ed || interface    | public                           || region       | RegionOne                        || region_id    | RegionOne                        || service_id   | 9df122e5374742cb9bfd1bec48622f30 || service_name | glance                           || service_type | image                            || url          | http://controller:9292           |+--------------+----------------------------------+
  • internal endpoint
[root@controller ~]# openstack endpoint create --region RegionOne \  image internal http://controller:9292+--------------+----------------------------------+| Field        | Value                            |+--------------+----------------------------------+| enabled      | True                             || id           | 70f89821d1054a64ba044ac35554a082 || interface    | internal                         || region       | RegionOne                        || region_id    | RegionOne                        || service_id   | 9df122e5374742cb9bfd1bec48622f30 || service_name | glance                           || service_type | image                            || url          | http://controller:9292           |+--------------+----------------------------------+
  • admin endpoint
[root@controller ~]# openstack endpoint create --region RegionOne \  image admin http://controller:9292+--------------+----------------------------------+| Field        | Value                            |+--------------+----------------------------------+| enabled      | True                             || id           | 98f67ed0b6ab454a915d5c585b66b22d || interface    | admin                            || region       | RegionOne                        || region_id    | RegionOne                        || service_id   | 9df122e5374742cb9bfd1bec48622f30 || service_name | glance                           || service_type | image                            || url          | http://controller:9292           |+--------------+----------------------------------+

二. 安装glance组件

1. 安装glance

[root@controller ~]# yum install openstack-glance -y

2. 配置glance

编辑文件 /etc/glance/glance-api.conf :

[database]...connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance[keystone_authtoken]...auth_uri = http://controller:5000auth_url = http://controller:35357memcached_servers = controller:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = glancepassword = zzr[paste_deploy]...flavor = keystone[glance_store]...stores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/images/

其中, zzr为上一步骤中为glance用户设置的密码.

编辑文件 /etc/glance/glance-registry.conf .

[database]...connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance[keystone_authtoken]...auth_uri = http://controller:5000auth_url = http://controller:35357memcached_servers = controller:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = glancepassword = zzr[paste_deploy]...flavor = keystone

[keystone_authtoken]的内容, 除了以上增加的内容外, 其它的全部删除.

(3) 同步glance配置成数据库

以glance用户的身份执行指令 glance-manage db_sync , 同步glance的配置到数据库:

[root@controller ~]# su -s /bin/sh -c "glance-manage db_sync" glance

(4) 开启Image服务

[root@controller ~]# # systemctl enable openstack-glance-api.service \  openstack-glance-registry.service[root@controller ~]# # systemctl start openstack-glance-api.service \  openstack-glance-registry.service

3. 验证

(1) 获取admin-only CLI指令的权限

[root@controller ~]# . admin-openrc

(2) 获取镜像

[root@controller ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

(3) 上传镜像到Image service

使用QCOW2硬盘格式. public可视, 从而所有project可以看到它.

[root@controller ~]# openstack image create "cirros" \  --file cirros-0.3.4-x86_64-disk.img \  --disk-format qcow2 --container-format bare \  --public+------------------+------------------------------------------------------+| Field            | Value                                                |+------------------+------------------------------------------------------+| checksum         | ee1eca47dc88f4879d8a229cc70a07c6                     || container_format | bare                                                 || created_at       | 2016-08-01T11:26:58Z                                 || disk_format      | qcow2                                                || file             | /v2/images/57d1498f-cbd2-4314-9114-6f74c11d5952/file || id               | 57d1498f-cbd2-4314-9114-6f74c11d5952                 || min_disk         | 0                                                    || min_ram          | 0                                                    || name             | cirros                                               || owner            | f8207344afbc4983837fccd7ad29c3d7                     || protected        | False                                                || schema           | /v2/schemas/image                                    || size             | 13287936                                             || status           | active                                               || tags             |                                                      || updated_at       | 2016-08-01T11:26:59Z                                 || virtual_size     | None                                                 || visibility       | public                                               |+------------------+------------------------------------------------------+

(4) 查看现有镜像

[root@controller ~]# openstack image list+--------------------------------------+--------+--------+| ID                                   | Name   | Status |+--------------------------------------+--------+--------+| 38047887-61a7-41ea-9b49-27987d5e8bb9 | cirros | active |+--------------------------------------+--------+--------+

参考文献

  1. OpenStack Installation Guide for Red Hat Enterprise Linux and CentOS
  2. OpenStack Mitaka 安裝 for CentOS — Kyle.Bai
  3. OpenStack Liberty
0 0