CentOS7安装OpenStack(Queens版)——(三)glance镜像服务

glance镜像服务(控制节点

  1. 创建glance数据库,用户密码设置为glance
mysql -uroot -p
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance';
FLUSH PRIVILEGES;
  1. 加载admin临时环境变量
source keystonerc_admin
  1. 在keystone上创建glance用户,密码自定义为glance
[root@controller-01 ~]# openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | d9dc186702da415db6b202327b73e08c |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
  1. 在keystone上给glance用户的service项目添加admin角色权限,命令不输出结果
[root@controller-01 ~]# openstack role add --project service --user glance admin
  1. 创建glance镜像服务实体
[root@controller-01 ~]# openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | c5fa51ca63b440bda5d277ee6dda23ec |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+
  1. 创建镜像服务API服务端点(endpoint)
[root@controller-01 ~]# openstack endpoint create --region RegionOne image public http://controller-01:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 580275b630f14f91903c90f0a46f260d |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c5fa51ca63b440bda5d277ee6dda23ec |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller-01:9292        |
+--------------+----------------------------------+

[root@controller-01 ~]# openstack endpoint create --region RegionOne image internal http://controller-01:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 0f8142d6abd048fd8c72f1861f713bde |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c5fa51ca63b440bda5d277ee6dda23ec |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller-01:9292        |
+--------------+----------------------------------+

[root@controller-01 ~]# openstack endpoint create --region RegionOne image admin http://controller-01:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | e40b8990bab5493a92469f2ffb7ad55e |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c5fa51ca63b440bda5d277ee6dda23ec |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller-01:9292        |
+--------------+----------------------------------+

glance安装配置服务

  1. 安装服务
yum install openstack-glance
  1. 编辑修改/etc/glance/glance-api.conf如下内容
[database]
connection = mysql+pymysql://glance:glance@controller-01/glance

[keystone_authtoken]
auth_uri = http://controller-01:5000
auth_url = http://controller-01:5000
memcached_servers = controller-01:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = glance

[paste_deploy]
flavor = keystone

[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
  1. 编辑修改/etc/glance/glance-registry.conf如下内容
[database]
connection = mysql+pymysql://glance:glance@controller-01/glance

[keystone_authtoken]
auth_uri = http://controller-01:5000
auth_url = http://controller-01:5000
memcached_servers = controller-01:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = glance

[paste_deploy]
flavor = keystone
  1. 初始化同步glance镜像数据库
su -s /bin/sh -c "glance-manage db_sync" glance
  1. 启动并开机自启服务
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service

验证

  1. 加载admin临时环境变量
source keystonerc_admin
  1. 下载镜像
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
  1. 上传镜像
openstack image create "cirros" --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --public
+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | 443b7623e27ecf03dc9e01ee93f67afe                     |
| container_format | bare                                                 |
| created_at       | 2022-11-27T16:36:22Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/8fe2a430-6e12-4de9-b9e6-202094bd6c2f/file |
| id               | 8fe2a430-6e12-4de9-b9e6-202094bd6c2f                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | cirros                                               |
| owner            | e39d64ee5972400db4a89b9ea3038de7                     |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 12716032                                             |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2022-11-27T16:36:22Z                                 |
| virtual_size     | None                                                 |
| visibility       | public                                               |
+------------------+------------------------------------------------------+
  1. 查看上传的镜像
openstack image list
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| 8fe2a430-6e12-4de9-b9e6-202094bd6c2f | cirros | active |
+--------------------------------------+--------+--------+

glance镜像服务安装完成。

参考文档

https://docs.openstack.org/queens/index.html

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据