接上一篇keystone, 这一篇介绍glance服务:
- 在开始操作之前,先用source环境变量,然后创建glance 用户,并设置密码为glance
[root@linux-node1 ~]#openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 31a0d9b7dd5f47b4b30ed4a77500a307 | | name | glance | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
- 添加admin角色到glance用户和service project
[root@linux-node1 ~]# openstack role add --project service --user glance admin
[root@linux-node1 ~]#
- 编辑/etc/glance/glance-registry.conf 如下所示
[database]
# ...
connection = mysql+pymysql://glance:glance@192.168.56.11/glance
[keystone_authtoken]
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
memcached_servers = 192.168.56.11:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor = keystone
- 编辑/etc/glance/glance-api.conf 如下所示:
[database]
connection = mysql+pymysql://glance:glance@192.168.56.11/glance
[keystone_authtoken]
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
memcached_servers = 192.168.56.11: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
- 同步glance数据库
[root@linux-node1 ~]# su -s /bin/sh -c "glance-manage db_sync" glance
- 验证数据库是否同步
[root@linux-node1 ~]# mysql -h 192.168.56.11 -uglance -pglance -e "use glance;show tables"
+----------------------------------+ | Tables_in_glance | +----------------------------------+ | alembic_version | | image_locations | | image_members | | image_properties | i |mage_tags| | metadef_namespaces | | metadef_objects | | metadef_properties | | metadef_resource_types | | metadef_tags | | images | | metadef_namespace_resource_types | | migrate_version | | task_info | | tasks | +----------------------------------+
- 启动memcached并设置开机启动
[root@linux-node1 ~]# systemctl enable memcached
[root@linux-node1 ~]# systemctl start memcached
- 启动glance服务并设置开机启动
systemctl enable openstack-glance-api.service \ openstack-glance-registry.service Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service. systemctl start openstack-glance-api.service \ openstack-glance-registry.service
- 创建glance实例
openstack service create --name glance \ --description "OpenStack Image" image +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image | | enabled | True | | id | 4c4dd5eb35324b568cd9722f174a632b | | name | glance | | type | image | +-------------+----------------------------------+
- 创建glance服务API 端点
openstack endpoint create --region RegionOne \ image public http://192.168.56.11:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 47e8d9659f70422487cf600405f518bf | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 4c4dd5eb35324b568cd9722f174a632b | | service_name | glance | | service_type | image | | url | http://192.168.56.11:9292 | +--------------+----------------------------------+openstack endpoint create --region RegionOne \ image internal http://192.168.56.11:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 859936e9632642d58517d9ac6a2c3176 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 4c4dd5eb35324b568cd9722f174a632b | | service_name | glance | | service_type | image | | url | http://192.168.56.11:9292 | +--------------+----------------------------------+openstack endpoint create --region RegionOne \ image admin http://192.168.56.11:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 223775040aaf460da4f275ebbcd01ae1 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 4c4dd5eb35324b568cd9722f174a632b | | service_name | glance | | service_type | image | | url | http://192.168.56.11:9292 | +--------------+----------------------------------+
- 验证创建,现在是两个服务的六个端点
[root@linux-node1 ~]# openstack endpoint list +----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+ | ID | Region | Service Name | Service Type | Enabled | Interface | URL | +----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+ | 16964c23761c428b909e9a8617d8146e | RegionOne | keystone | identity | True | internal | http://192.168.56.11:5000/v3/ | | 223775040aaf460da4f275ebbcd01ae1 | RegionOne | glance | image | True | admin | http://192.168.56.11:9292 | | 36fb4b5b955d471783a982ea455cf58d | RegionOne | keystone | identity | True | public | http://192.168.56.11:5000/v3/ | | 47e8d9659f70422487cf600405f518bf | RegionOne | glance | image | True | public | http://192.168.56.11:9292 | | 62766176a40f43bbbb40d4b986b4400e | RegionOne | keystone | identity | True | admin | http://192.168.56.11:35357/v3/ | | 859936e9632642d58517d9ac6a2c3176 | RegionOne | glance | image | True | internal | http://192.168.56.11:9292 | +----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+
- 这个时候,输入openstack image list,如果没有报错,即证明上面的操作是对的
[root@linux-node1 ~]# openstack image list
[root@linux-node1 ~]#
- 下面我们用一个小镜像来验证一下,首先先获取这个镜像
wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
- 创建并验证镜像
openstack image create "cirros" \ --file cirros-0.3.5-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --public +------------------+------------------------------------------------------+ | Field | Value | +------------------+------------------------------------------------------+ | checksum | f8ab98ff5e73ebab884d80c9dc9c7290 | | container_format | bare | | created_at | 2018-01-12T08:22:52Z | | disk_format | qcow2 | | file | /v2/images/24a1486b-d1b5-4564-b2cc-3397fdf295cf/file | | id | 24a1486b-d1b5-4564-b2cc-3397fdf295cf | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | fb6761ab3d3d43569d5fdfafcdfa5e28 | | protected | False | | schema | /v2/schemas/image | | size | 13267968 | | status | active | | tags | | | updated_at | 2018-01-12T08:22:52Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+ [root@linux-node1 ~]# openstack image list +--------------------------------------+--------+--------+ | ID | Name | Status | +--------------------------------------+--------+--------+ | 24a1486b-d1b5-4564-b2cc-3397fdf295cf | cirros | active | +--------------------------------------+--------+--------+
至此,glance部分创建完毕