OpenStack-Pike 搭建之Glance(三)

OpenStack-Pike 搭建之Glance(三)

Acha
2022-07-13 / 0 评论 / 138 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年07月21日,已超过617天没有更新,若内容或图片失效,请留言反馈。

Glance

概述

The OpenStack Image service includes the following components:

glance-api

Accepts Image API calls for image discovery, retrieval, and storage.

glance-registry

Stores, processes, and retrieves metadata about images. Metadata includes items such as size and type.

Database

Stores image metadata and you can choose your database depending on your preference. Most deployments use MySQL or SQLite.

Storage repository for image files

Various repository types are supported including normal file systems (or any filesystem mounted on the glance-api controller node), Object Storage, RADOS block devices, VMware datastore, and HTTP. Note that some repositories will only support read-only usage.

Metadata definition service

A common API for vendors, admins, services, and users to meaningfully define their own custom metadata. This metadata can be used on different types of resources like images, artifacts, volumes, flavors, and aggregates. A definition includes the new property’s key, description, constraints, and the resource types which it can be associated with.


前置条件

创建 数据库并授权

1、使用 root用户登录数据库

 mysql -u root -p000000

2、创建 glance 数据库

CREATE DATABASE glance;

3、授权 glance用户 对 glance数据库 所有权限

GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
  IDENTIFIED BY '000000';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
  IDENTIFIED BY '000000';

创建 服务凭证 和 API端点

1、加载 admin用户信息

. admin-openrc

2、创建 服务凭证

  • 创建 glance 用户
openstack user create --domain default --password 000000 glance
  • 将 service项目 中的 glance用户 设置为 admin角色
openstack role add --project service --user glance admin
  • 创建 glance服务
openstack service create --name glance \
  --description "OpenStack Image" image

3、创建 glance 服务 API端点

openstack endpoint create --region RegionOne \
  image public http://controller:9292

openstack endpoint create --region RegionOne \
  image internal http://controller:9292

openstack endpoint create --region RegionOne \
  image admin http://controller:9292

安装 和 配置组件

1、安装软件包

yum install -y openstack-glance

2、配置 glance-api.conf

# sed -i.bak '/^#/d;/^$/d' /etc/glance/glance-api.conf

# vim /etc/glance/glance-api.conf

[database]
# 配置数据库访问
connection = mysql+pymysql://glance:000000@controller/glance

[keystone_authtoken]
# 配置身份服务访问
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = 000000

[paste_deploy]
# 配置身份服务访问
flavor = keystone

[glance_store]
# 配置本地文件系统存储和镜像文件的位置
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

3、配置 glance-registry.conf

# sed -i.bak '/^#/d;/^$/d' /etc/glance/glance-registry.conf

# vim /etc/glance/glance-registry.conf

[database]
# 配置数据库访问
connection = mysql+pymysql://glance:000000@controller/glance

[keystone_authtoken]
# 配置身份服务访问
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = 000000

[paste_deploy]
# 配置身份服务访问
flavor = keystone

4、同步 glance 数据库

su -s /bin/sh -c "glance-manage db_sync" glance

完成安装

启动镜像服务并设置开机自启

systemctl enable openstack-glance-api.service \
  openstack-glance-registry.service
systemctl start openstack-glance-api.service \
  openstack-glance-registry.service

验证

1、获取 admin 凭证

. admin-openrc

2、下载 测试镜像

wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img

3、上传 测试镜像

openstack image create "cirros" \
  --file cirros-0.3.5-x86_64-disk.img \
  --disk-format qcow2 --container-format bare \
  --public

4、查询 镜像列表

openstack image list

0

评论

博主关闭了当前页面的评论