镜像服务
镜像服务(glance)是用户能够发现,注册和检索虚拟机的镜像,它提供了一个REST API,使您能够查询虚拟机映像元数据并检索实际映像。可以将通过Image服务提供的虚拟机映像存储在各种位置,从简单文件系统到对象存储系统(如OpenStack对象存储)。镜像默认放在/var/lib/glance/images/。
下面说一下glance服务的安装及配置
1.创建数据库
[iyunv@controller ~]# mysql -uroot -p123456
mysql> CREATE DATABASE glance;
mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'GLANCE_DBPASS';
mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'GLANCE_DBPASS';
2.获取admin权限
[iyunv@controller ~]# . admin-openrc
3.创建glance用户
[iyunv@controller ~]# openstack user create --domain default --password-prompt glance
User Password:123456
Repeat User Password:123456
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 09d8b7bbfe9748ffadff25bffc1b46cd |
| name | glance |
| password_expires_at | None |
+---------------------+----------------------------------+
将admin角色添加到glance用户和服务项目中
1
[iyunv@controller ~]# openstack role add --project service --user glance admin
创建glance服务实例
# openstack service create --name glance \
--description "OpenStack Image" image
[iyunv@controller ~]# openstack service create --name glance \
> --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | d6319246d7e3486d86b54634f07c1cb8 |
| name | glance |
| type | image |
+-------------+----------------------------------+
4.创建image服务API端点
# openstack endpoint create --region RegionOne \
image public http://controller:9292
[iyunv@controller ~]# openstack endpoint create --region RegionOne \
> image public http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 621b1c8dabc9472591690d4dadbd4dff |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | d6319246d7e3486d86b54634f07c1cb8 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
# openstack endpoint create --region RegionOne \
image internal http://controller:9292
[iyunv@controller ~]# openstack endpoint create --region RegionOne \
> image internal http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | f2d4366f844d415e9745c6d7d817d859 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | d6319246d7e3486d86b54634f07c1cb8 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
# openstack endpoint create --region RegionOne \
image admin http://controller:9292
[iyunv@controller ~]# openstack endpoint create --region RegionOne \
> image admin http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 48114b387628482f9ae11d0cdb29dce2 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | d6319246d7e3486d86b54634f07c1cb8 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
5.安装服务
[iyunv@controller ~]# yum install openstack-glance -y
6.配置服务
修改/etc/glance/glance-api.conf
[iyunv@controller ~]# cd /etc/glance/
[iyunv@controller glance]# cp glance-api.conf glance-api.conf.bak
[iyunv@controller glance]# egrep -v "^#|^$" glance-api.conf.bak > glance-api.conf
[iyunv@controller glance]# vim glance-api.conf
[database]
...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
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
[glance_store]
...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
修改/etc/glance/glance-registry.conf
[iyunv@controller ~]# cd /etc/glance/
[iyunv@controller glance]# cp glance-registry.conf glance-registry.conf.bak
[iyunv@controller glance]# egrep -v "^#|^$" glance-registry.conf.bak glance-registry.conf
[database]
...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
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
7.填充数据库
[iyunv@controller glance]# su -s /bin/sh -c "glance-manage db_sync" glance
8.启动服务
[iyunv@controller glance]# systemctl enable openstack-glance-api.service openstack-glance-registry.service
[iyunv@controller glance]# systemctl start openstack-glance-api.service openstack-glance-registry.service
9.验证
下载镜像
[iyunv@controller glance]# wget http://download.cirros-cloud.net ... 3.4-x86_64-disk.img
导入镜像
# openstack image create "cirros" \
--file cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--public
[iyunv@controller glance]# openstack image create "cirros" \
> --file cirros-0.3.4-x86_64-disk.img \
> --disk-format qcow2 --container-format bare \
> --public
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2017-01-11T03:10:51Z |
| disk_format | qcow2 |
| file | /v2/images/2faf5e8a-890d-4c68-a391-a2911342a3af/file |
| id | 2faf5e8a-890d-4c68-a391-a2911342a3af |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 3cf031774a844e4c8422cadb9d67785e |
| protected | False |
| schema | /v2/schemas/image |
| size | 13287936 |
| status | active |
| tags | |
| updated_at | 2017-01-11T03:10:52Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
[iyunv@controller glance]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 2faf5e8a-890d-4c68-a391-a2911342a3af | cirros | active |
+--------------------------------------+--------+--------+
安装成功
[iyunv@controller ~]# ls /var/lib/glance/images/
2faf5e8a-890d-4c68-a391-a2911342a3af
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com