1.安装前准备
1.1 创建数据库及用户
mysql -u root -p MariaDB [(none)]> CREATE DATABASE glance; MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS'; #GLANCE_DBPASS需要替换成自己想设置的
1.2 在identity service中创建glance 用户
1.导入环境变量
. admin-openrc
2.创建glance用户
openstack user create --domain default --password-prompt glance
3.设置glance用户规则
openstack role add --project service --user glance admin
4.创建glance服务条目
openstack service create --name glance --description "OpenStack Image" image
1.3 创建image服务的API访问点
root@ubuntu-ControllerNode:/home/ubuntu# openstack endpoint create --region RegionOne image public http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 31e174133c664cf9ac3a99840b2e2b82 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | a22a4f6bc9784177982de2a896b1ee94 | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+ root@ubuntu-ControllerNode:/home/ubuntu# openstack endpoint create --region RegionOne image internal http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 58fea80947b24771b030e0c7be32a2c8 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | a22a4f6bc9784177982de2a896b1ee94 | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+ root@ubuntu-ControllerNode:/home/ubuntu# openstack endpoint create --region RegionOne image admin http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | ba6b07ff9598421b824523597bdea95f | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | a22a4f6bc9784177982de2a896b1ee94 | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+
2.安装与配置
2.1.安装glance
apt install glance
2.2.配置/etc/glance/glance-api.conf
需要修改如下几个位置,GLANCE_DBPASS
和GLANCE_PASS
需要替换成自己设置的:
[database] # ... connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
[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 = GLANCE_PASS [paste_deploy] # ... flavor = keystone
[glance_store] # ... stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images/
2.3.配置 /etc/glance/glance-registry.conf
修改如下内容,GLANCE_DBPASS
和GLANCE_PASS
需要替换成自己设置的:
[database] # ... connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glancea
[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 = GLANCE_PASS [paste_deploy] # ... flavor = keystone
2.4.迁移Image service的数据库
su -s /bin/sh -c "glance-manage db_sync" glance
2.5 重启Image services
service glance-registry restart service glance-api restart
3.检测安装成果
1.导入环境变量
. admin-openrc
2.下载一个网上现场的镜像用来测试
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
3.将镜像传给Image service,使用 QCOW2 的硬盘格式,不创建容器,设置权限为public
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 | 2019-01-09T09:52:52Z | | disk_format | qcow2 | | file | /v2/images/8adf48c6-2713-4b56-a1c1-7f6164b8a4e1/file | | id | 8adf48c6-2713-4b56-a1c1-7f6164b8a4e1 | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | 37bb7182137c419995a57ccea6e2eff8 | | properties | os_hash_algo='sha512', os_hash_value='6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e2161b5b5186106570c17a9e58b64dd39390617cd5a350f78', os_hidden='False' | | protected | False | | schema | /v2/schemas/image | | size | 12716032 | | status | active | | tags | | | updated_at | 2019-01-09T09:52:53Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
4.查看镜像是否上传成功
root@ubuntu-ControllerNode:/home/ubuntu# openstack image list +--------------------------------------+--------+--------+ | ID | Name | Status | +--------------------------------------+--------+--------+ | 8adf48c6-2713-4b56-a1c1-7f6164b8a4e1 | cirros | active | +--------------------------------------+--------+--------+