glance镜像服务(控制节点)
- 创建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;
- 加载admin临时环境变量
source keystonerc_admin
- 在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 |
+---------------------+----------------------------------+
- 在keystone上给glance用户的service项目添加admin角色权限,命令不输出结果
[root@controller-01 ~]# openstack role add --project service --user glance admin
- 创建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 |
+-------------+----------------------------------+
- 创建镜像服务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安装配置服务
- 安装服务
yum install openstack-glance
- 编辑修改/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/
- 编辑修改/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
- 初始化同步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
验证
- 加载admin临时环境变量
source keystonerc_admin
- 下载镜像
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
- 上传镜像
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 |
+------------------+------------------------------------------------------+
- 查看上传的镜像
openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 8fe2a430-6e12-4de9-b9e6-202094bd6c2f | cirros | active |
+--------------------------------------+--------+--------+
glance镜像服务安装完成。