OpenStack install Glance(镜像服务)
2020-09-02虚拟化90root370°c
A+ A-一、Glance介绍
Glance项目提供虚拟机镜像的发现,注册,取得服务。
Glance-api:接受云系统镜像的创建、删除、读取请求
Glance-Registry:云系统的镜像注册服务
二、yum install glance(控制节点)
[[email protected] ~]# yum install -y openstack-glance python-glanceclient python-crypto
三、配置Glance
3.1 设置数据库链接地址
[[email protected] ~]# cd /etc/glance/[[email protected] glance]# vim glance-api.confconnection=mysql://glance:[email protected]/glance #设置数据库链接地址[[email protected] glance]# vim glance-registry.confconnection=mysql://glance:[email protected]/glance
3.2 同步数据库
[[email protected] glance]# glance-manage db_sync #可能会出现警告.请忽略[[email protected] glance]# mysql -h192.168.15.11 -uglance -pglance -e"use glance;show tables"+------------------+ | Tables_in_glance | +------------------+ | image_locations | | image_members | | image_properties | | image_tags | | images | | migrate_version | | task_info | | tasks | +------------------+
设置RabbitMQ只需要修改glance-api.conf文件即可
3.3 设置glance-api链接RabbitMQ地址
[[email protected] glance]# vim glance-api.confnotifier_strategy = rabbit rabbit_host=192.168.15.11 rabbit_port=5672 rabbit_use_ssl=falserabbit_userid=guest rabbit_password=guest #rabbitmq的密码.之前是admin后来改为guestrabbit_virtual_host=/ rabbit_notification_exchange=glance rabbit_notification_topic=notifications rabbit_durable_queues=False
3.4 创建注册用户glance
[[email protected] glance]# keystone user-create --name=glance --pass=glance+----------+----------------------------------+ | Property | Value | +----------+----------------------------------+ | email | | | enabled | True | | id | ccfa336746eb4db4b2bdb16158bafb61 | | name | glance | | username | glance | +----------+----------------------------------+ [[email protected] glance]# keystone user-role-add --user=glance --tenant=admin --role=admin
3.5 设置glance-api、glance-registry链接keystone认证服务器地址
[[email protected] glance]# vim glance-api.conf[keystone_authtoken] #keystone认证auth_host=192.168.15.11 auth_port=35357 auth_protocol=http admin_tenant_name=admin #租户admin_user=glance #用户admin_password=glance #密码flavor=keystone [[email protected] glance]# vim glance-registry.conf[keystone_authtoken] #keystone认证auth_host=192.168.15.11 auth_port=35357 auth_protocol=http admin_tenant_name=admin admin_user=glance admin_password=glance flavor=keystone
四、创建Glance service和endpoint
[[email protected] glance]# keystone service-create --name=glance --type=image+-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | description | | | enabled | True | | id | c0fe6a5ef1fb4bbeaf795ea7fef00748 | | name | glance | | type | image | +-------------+----------------------------------+ [[email protected] glance]# keystone endpoint-create \> --service-id=c0fe6a5ef1fb4bbeaf795ea7fef00748 \ > --publicurl=http://192.168.15.11:9292 \ > --internalurl=http://192.168.15.11:9292 \ > --adminurl=http://192.168.15.11:9292 +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | adminurl | http://192.168.15.11:9292 | | id | 135732ad0fd34da79cbca5b8fe93b15f | | internalurl | http://192.168.15.11:9292 | | publicurl | http://192.168.15.11:9292 | | region | regionOne | | service_id | c0fe6a5ef1fb4bbeaf795ea7fef00748 | +-------------+----------------------------------+ [[email protected] glance]# keystone service-list+----------------------------------+----------+----------+--------------------+ | id | name | type | description | +----------------------------------+----------+----------+--------------------+ | c0fe6a5ef1fb4bbeaf795ea7fef00748 | glance | image | | | e39a683d743340dea051005c3ae35046 | keystone | identity | Openstack Identity | +----------------------------------+----------+----------+--------------------+ [[email protected]_214 glance]# keystone endpoint-list+----------------------------------+-----------+--------------------------------+--------------------------------+---------------------------------+----------------------------------+ | id | region | publicurl | internalurl | adminurl | service_id | +----------------------------------+-----------+--------------------------------+--------------------------------+---------------------------------+----------------------------------+ | 135732ad0fd34da79cbca5b8fe93b15f | regionOne | http://192.168.15.11:9292 | http://192.168.15.11:9292 | http://192.168.15.11:9292 | c0fe6a5ef1fb4bbeaf795ea7fef00748 | | 7b923b2e790b43ee8b5be99d5c8262d6 | regionOne | http://192.168.15.11:5000/v2.0 | http://192.168.15.11:5000/v2.0 | http://192.168.15.11:35357/v2.0 | e39a683d743340dea051005c3ae35046 | +----------------------------------+-----------+--------------------------------+--------------------------------+---------------------------------+----------------------------------+
五、启动glance-api、glance-registrt
[[email protected] glance]# /etc/init.d/openstack-glance-api start[[email protected] glance]# /etc/init.d/openstack-glance-registry start### 启动失败请检测/var/log/glance/权限[[email protected] glance]# chkconfig --add openstack-glance-api[[email protected] glance]# chkconfig --add openstack-glance-registry[[email protected] glance]# chkconfig openstack-glance-api on[[email protected] glance]# chkconfig openstack-glance-registry on[[email protected] glance]# source /root/keystone-admin[[email protected] glance]# glance image-list #查看镜像+----+------+-------------+------------------+------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +----+------+-------------+------------------+------+--------+ +----+------+-------------+------------------+------+--------+
六、测试glance
[[email protected] glance]# cd /usr/local/src/[[email protected] src]# wget --no-check-certificate https://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img #下载镜像[[email protected] src]# glance image-create --name "cirros-0.3.4" --disk-format qcow2 --container-format bare --is-public True --file cirros-0.3.4-x86_64-disk.img #上传镜像+------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2016-11-05T19:03:36 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | e30af412-0e11-46bb-bb4f-54fe1fe5e342 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | cirros-0.3.4 | | owner | None | | protected | False | | size | 13287936 | | status | active | | updated_at | 2016-11-05T19:03:36 | | virtual_size | None | +------------------+--------------------------------------+ [[email protected] src]# glance image-list #查看镜像+--------------------------------------+--------------+-------------+------------------+----------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +--------------------------------------+--------------+-------------+------------------+----------+--------+ | e30af412-0e11-46bb-bb4f-54fe1fe5e342 | cirros-0.3.4 | qcow2 | bare | 13287936 | active | +--------------------------------------+--------------+-------------+------------------+----------+--------+ [[email protected] src]# ll /var/lib/glance/images/ #默认镜像存放目录-rw-r----- 1 glance glance 13287936 Nov 5 19:03: e30af412-0e11-46bb-bb4f-54fe1fe5e342