当前位置: 首页 > 工具软件 > Glance > 使用案例 >

OpenStack Glance部署(4)

颜黎昕
2023-12-01

目录

一、创建数据库

二、安装配置组件

三、启动Glance服务

一、创建数据库

1、创建数据库:控制节点部署

①、授予数据库访问权限

②、刷新数据库

[root@controller ~]# mysql -u root -p

MariaDB [(none)]> create database glance;

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY '123456';

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY '123456';

MariaDB [(none)]> flush privileges;

MariaDB [(none)]> quit

2、获取管理员的权限访问OpenStack cli

[root@controller ~]# . admin-openrc.sh 

3、创建服务凭据:

①、创建用户glance

密码:"123456"

②、将角色添加到用户项目

[root@controller ~]# openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 4c093cb98dbb431d869cfd5e9fead2b0 |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

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

4、创建服务实体:glance

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

5、创建镜像服务API端点

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

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

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

二、安装配置组件

1、安装软件包

2、修改配置文件/etc/glance/glance-api.conf

3、填充镜像服务数据库

[root@controller ~]# yum install openstack-glance -y
[root@controller ~]# vim /etc/glance/glance-api.conf 

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


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


 #配置标识服务访问
[keystone_authtoken]
www_authenticate_uri  = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = 123456


 #配置标识服务访问
[paste_deploy]
flavor = keystone


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

三、启动Glance服务

1、启动glance服务,并设置开机自启动

目录

一、创建数据库

二、安装配置组件

三、启动Glance服务


四、验证是否完成安装

1、获取管理员对OpenStack cli的访问权限

[root@controller ~]# . admin-openrc.sh 

2、下载源镜像

[root@controller ~]# wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
--2022-07-21 17:34:58--  http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
Resolving download.cirros-cloud.net (download.cirros-cloud.net)... 64.90.42.85, 2607:f298:6:a036::bd6:a72a
Connecting to download.cirros-cloud.net (download.cirros-cloud.net)|64.90.42.85|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github.com/cirros-dev/cirros/releases/download/0.4.0/cirros-0.4.0-x86_64-disk.img [following]
--2022-07-21 17:35:00--  https://github.com/cirros-dev/cirros/releases/download/0.4.0/cirros-0.4.0-x86_64-disk.img
Resolving github.com (github.com)... 20.205.243.166

... ...

100%[=================================================================================================================================>] 12,716,032  1.70MB/s   in 9.6s   

2022-07-21 17:35:15 (1.27 MB/s) - ‘cirros-0.4.0-x86_64-disk.img’ saved [12716032/12716032]

3、将cirros以QCOW2文件类型上传到glance服务

[root@controller ~]# glance image-create --name "cirros" \
--file cirros-0.4.0-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--visibility public
+------------------+----------------------------------------------------------------------------------+
| Property         | Value                                                                            |
+------------------+----------------------------------------------------------------------------------+
| checksum         | 443b7623e27ecf03dc9e01ee93f67afe                                                 |
| container_format | bare                                                                             |
| created_at       | 2022-07-21T02:36:55Z                                                             |
| disk_format      | qcow2                                                                            |
| id               | e82bb244-644a-4d9c-8739-053f55328634                                             |
| min_disk         | 0                                                                                |
| min_ram          | 0                                                                                |
| name             | cirros                                                                           |
| os_hash_algo     | sha512                                                                           |
| os_hash_value    | 6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e |
|                  | 2161b5b5186106570c17a9e58b64dd39390617cd5a350f78                                 |
| os_hidden        | False                                                                            |
| owner            | 495f2e77e0ba4614a4812bcd5fd86bb8                                                 |
| protected        | False                                                                            |
| size             | 12716032                                                                         |
| status           | active                                                                           |
| tags             | []                                                                               |
| updated_at       | 2022-07-21T02:36:56Z                                                             |
| virtual_size     | Not available                                                                    |
| visibility       | public                                                                           |
+------------------+----------------------------------------------------------------------------------+

4、确认镜像上传状态

[root@controller ~]# glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| e82bb244-644a-4d9c-8739-053f55328634 | cirros |
+--------------------------------------+--------+

 类似资料: