设为首页 收藏本站
查看: 789|回复: 0

[经验分享] OpenStack 学习笔记(四):OpenStack glance服务搭建

[复制链接]

尚未签到

发表于 2018-6-1 09:15:01 | 显示全部楼层 |阅读模式
  ——先决条件

  

  1.)创建数据库
MariaDB [(none)]> CREATE DATABASE glance;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance';
Query OK, 0 rows affected (0.00 sec)  2.) create glance user
[root@openstack ~]# openstack user create --domain default --password glance glance
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | 505647f0f06e408e9d176da82a6684f1 |
| enabled   | True                             |
| id        | fa8739bf463a40e5a1945c700c16b8a8 |
| name      | glance                           |
+-----------+----------------------------------+  3.) Add the admin role to the glance user and service project
[root@openstack ~]# openstack role add --project service --user glance admin  4.) create image service
[root@openstack ~]# openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | e67a6d01628149b897be0a7795feb10a |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+  5.)Create the Image service API endpoints
[root@openstack ~]# openstack endpoint create --region RegionOne image public http://192.168.100.120:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 68c611cc0add4c178b7f1d58df0843af |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | e67a6d01628149b897be0a7795feb10a |
| service_name | glance                           |
| service_type | image                            |
| url          | http://192.168.100.120:9292      |
+--------------+----------------------------------+
[root@openstack ~]# openstack endpoint create --region RegionOne image internal http://192.168.100.120:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 716335ae9a8f46f9b9b175ae7e381aa9 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | e67a6d01628149b897be0a7795feb10a |
| service_name | glance                           |
| service_type | image                            |
| url          | http://192.168.100.120:9292      |
+--------------+----------------------------------+
[root@openstack ~]# openstack endpoint create --region RegionOne image admin http://192.168.100.120:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | b92d362f5d0d49d0a78cbc3ea3ed63f1 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | e67a6d01628149b897be0a7795feb10a |
| service_name | glance                           |
| service_type | image                            |
| url          | http://192.168.100.120:9292      |
+--------------+----------------------------------+  

  ——glance服务搭建配置

  

  6.)安装glance
[root@openstack ~]# yum -y install openstack-glance python-glanceclient python-crypto  
  7.)配置glance
[root@openstack ~]# cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
[root@openstack ~]# cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
[root@openstack ~]# vim /etc/glance/glance-api.conf
   1: [DEFAULT]
378: debug = true
405: log_file = /var/log/glance/glance-api.log
618: [database]
641: connection = mysql://glance:glance@localhost:3306/glance
741: stores = file,http
746: default_store = file
1025: filesystem_store_datadir = /var/lib/glance/images
1111: [keystone_authtoken]
1112: auth_uri = http://192.168.100.120:5000
1113: auth_url = http://192.168.100.120:35357
1114: memcached_servers = 192.168.100.120:11211
1115: auth_type = password
1116: project_domain_name = default
1117: user_domain_name = default
1118: project_name = service
1119: username = glance
1120: password = glance
1696: flavor = keystone
[root@openstack ~]# vim /etc/glance/glance-registry.conf
   1: [DEFAULT]
179: debug = true
206: log_file = /var/log/glance/glance-registry.log
359: [database]
382: connection = mysql://glance:glance@localhost:3306/glance
836: [keystone_authtoken]
837: auth_uri = http://192.168.100.120:5000
838: auth_url = http://192.168.100.120:35357
839: memcached_servers = 192.168.100.120:11211
840: auth_type = password
841: project_domain_name = default
842: user_domain_name = default
843: project_name = service
844: username = glance
845: password = glance
1402: flavor = keystone  
  8.) 同步数据库
[root@openstack ~]# glance-manage db_sync
[root@openstack ~]# mysql -uglance -pglance -e 'use glance; show tables;'
+----------------------------------+
| Tables_in_glance                 |
+----------------------------------+
| artifact_blob_locations          |
| artifact_blobs                   |
| artifact_dependencies            |
| artifact_properties              |
| artifact_tags                    |
| artifacts                        |
| image_locations                  |
| image_members                    |
| image_properties                 |
| image_tags                       |
| images                           |
| metadef_namespace_resource_types |
| metadef_namespaces               |
| metadef_objects                  |
| metadef_properties               |
| metadef_resource_types           |
| metadef_tags                     |
| migrate_version                  |
| task_info                        |
| tasks                            |
+----------------------------------+  
  9.) Start glance service
[root@openstack ~]# chown -R glance:glance /var/log/glance
[root@openstack ~]# systemctl enable openstack-glance-api.service openstack-glance-registry.service
[root@openstack ~]# systemctl start openstack-glance-api.service openstack-glance-registry.service
[root@openstack ~]# systemctl status openstack-glance-api.service openstack-glance-registry.service
[root@openstack ~]]# netstat -antup|egrep '9191|9292'|grep LISTEN
tcp        0      0 0.0.0.0:9292            0.0.0.0:*               LISTEN      5529/python2        
tcp        0      0 0.0.0.0:9191            0.0.0.0:*               LISTEN      5530/python2  
  

  10.)校验操作
  

  10.1)Download the source image
[root@openstack ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img -P /soft  
  10.2)Upload the image to the Image service
[root@openstack ~]# openstack image create "cirros-0.3.4-x86_64" \
--file /soft/cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 \
--container-format bare \
--public
+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6                     |
| container_format | bare                                                 |
| created_at       | 2016-05-26T06:03:52Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/138d731b-0372-4237-9187-62f7885ac147/file |
| id               | 138d731b-0372-4237-9187-62f7885ac147                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | cirros-0.3.4-x86_64                                  |
| owner            | e4f62edc6ed547109768b515be56044a                     |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 13287936                                             |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2016-05-26T06:03:52Z                                 |
| virtual_size     | None                                                 |
| visibility       | public                                               |
+------------------+------------------------------------------------------+
[root@openstack ~]# openstack image list
+--------------------------------------+---------------------+--------+
| ID                                   | Name                | Status |
+--------------------------------------+---------------------+--------+
| 138d731b-0372-4237-9187-62f7885ac147 | cirros-0.3.4-x86_64 | active |
+--------------------------------------+---------------------+--------+  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-496830-1-1.html 上篇帖子: OpenStack 学习笔记(三):OpenStack keystone服务搭建 下篇帖子: 从零构建OpenStack(1) 云计算相关概念及OpenStack介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表