Cloud computing services openstack core components --glance- mirror (6)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image.png)
-
If you are installing the system more efficiency is very low
-
Long time, heavy workload
-
Also installing manual configuration, such as installing other software, such as IP set
-
Backup and recovery system is not flexible
-
First manually installed such a virtual machine
-
VM snapshot then performed, thus obtaining an image
-
When new employees need office environment, immediately start one or more of the image of the instance (virtual machine) on it
-
Provide REST API allows users to query and access image metadata and image itself
-
Support multiple stored image, comprising a common file system, Swift, Amazon S3, etc.
-
Create a new image for the implementation Instance Snapshot
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[1].png)
glance-api
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[2].png)
glance-registry
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[3].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[4].png)
Database
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[5].png)
Store backend
-
A directory on a local file system(这是默认配置)
-
GridFS
-
Ceph RBD
-
Amazon S3
-
Sheepdog
-
OpenStack Block Storage (Cinder)
-
OpenStack Object Storage (Swift)
-
VMware ESX
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[6].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[7].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[8].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[9].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[10].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[11].png)
[DEFAULT] [cors] [cors.subdomain] [database] connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance [glance_store] stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images/ [image_format] [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 = glance [matchmaker_redis] [oslo_concurrency] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_middleware] [oslo_policy] [paste_deploy] flavor = keystone [profiler] [store_type_location_strategy] [task] [taskflow_executor]
vim /etc/glance/glance-registry.conf
[DEFAULT] [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 = glance [matchmaker_redis] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_policy] [paste_deploy] flavor = keystone [profiler]
布建openstack的glance
1. mysql -u root -p
2. CREATE DATABASE glance;
3.
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \ IDENTIFIED BY '123';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \ IDENTIFIED BY '123';
3.source openrc
创建用户 设置角色 设置服务 创建三种服务端点
(internal内部 admin管理 public公共)
4. 退出数据库 创建 glance用户 domain项目
openstack user create --domain default --password=glance glance
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | bcaefe90e2ce41879fde9c81332a2229 |
| name | glance |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
5把glance的用户 设置在service的项目中 设置admin的权限管理员
openstack role add --project service --user glance admin
6.创建服务
openstack service create --name glance \ --description "OpenStack Image" image
问题解决
[root@node1 ~]# openstack endpoint create --region RegionOne \
> image internal http://node1:9292
Missing value auth-url required for auth plugin password
[root@node1 ~]# source openrc
7创建服务端点
openstack endpoint create --region RegionOne \
image public http://node1:9292
服务端点列表 显示两种方式
1 openstack endpoint list
2 openstack catalog list
删除不要的服务端点
openstack endpoint delete 加上ID 号
8 创建内部服务端点
openstack endpoint create --region RegionOne \ image internal http://node1:9292
9 创建管理端点
openstack endpoint create --region RegionOne \ image admin http://node1:9292
openstack endpoint list 有3个glance
10 yum install openstack-glance -y
11 cd /etc/glance/
ls
LL
修改这两个配置文件 注意属主 属组
cp glance-api.conf glance-api.conf.beifen 备份一根文件进行修改
cp glance-rgistry.conf glance-registry.conf.beifen
12 之前的全部删除掉
vim glance-api.conf glance—store 进行后台存储
[DEFAULT]
[cors]
[cors.subdomain]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@node1/glance
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[image_format]
[keystone_authtoken]
auth_uri = http://node1:5000
auth_url = http://node1:35357
memcached_servers = node1:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
[matchmaker_redis]
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_middleware]
[oslo_policy]
[paste_deploy] 认证模板
flavor = keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]
13 之前的全部删除掉
vim glance-rgistry.conf 元数据有关的工作交给rgistry
[DEFAULT]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@node1/glance
[keystone_authtoken]
auth_uri = http://node1:5000
auth_url = http://node1:35357
memcached_servers = node1:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
[matchmaker_redis]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]
14 导入表内容同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance
15 glance-api glance-registry 开机自启
# systemctl enable openstack-glance-api.service \ openstack-glance-registry.service # systemctl start openstack-glance-api.service \ openstack-glance-registry.service
查看状态
# systemctl status openstack-glance-api.service \ openstack-glance-registry.service # systemctl status openstack-glance-api.service \ openstack-glance-registry.service
创建镜像
16 wget http://download2.yunwei.edu/shell/openstack_app.tar.gz
17 ls
[root@node1 ~]# ls
1234.txt 2 3 5 7 9 apache-tomcat-9.0.20.zip openstack_app.tar.gz pjh.txt
1.txt 2.txt 4 6 8 anaconda-ks.cfg openrc openstack-ocata yum-repo.sh
18 tar zxf openstack_app.tar.gz
19 ls
[root@node1 openstack-ocata]# ls
cirros-0.3.3-x86_64-disk.img openstack-compute-yilai
20 openstack image create "cirros" \ --file cirros-0.3.3-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --public
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | 133eae9fb1c98f45894a4e60d8736619 |
| container_format | bare |
| created_at | 2019-08-03T01:22:51Z |
| disk_format | qcow2 |
| file | /v2/images/6a99c72d-e083-471d-a6f7-787cd05f8e56/file |
| id | 6a99c72d-e083-471d-a6f7-787cd05f8e56 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 77539b5d86c6419d88e99140ed0f84a1 |
| protected | False |
| schema | /v2/schemas/image |
| size | 13200896 |
| status | active |
| tags | |
| updated_at | 2019-08-03T01:22:52Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
21 openstack image list
glance image-list
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image.png)
-
如果要安装的系统多了效率就很低
-
时间长,工作量大
-
安装完还要进行手工配置,比如安装其他的软件,设置 IP 等
-
备份和恢复系统不灵活
-
先手工安装好这么一个虚机
-
然后对虚机执行 snapshot,这样就得到了一个 image
-
当有新员工入职需要办公环境时,立马启动一个或多个该 image 的 instance(虚机)就可以了
-
提供 REST API 让用户能够查询和获取 image 的元数据和 image 本身
-
支持多种方式存储 image,包括普通的文件系统、Swift、Amazon S3 等
-
对 Instance 执行 Snapshot 创建新的 image
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[1].png)
glance-api
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[2].png)
glance-registry
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[3].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[4].png)
Database
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[5].png)
Store backend
-
A directory on a local file system(这是默认配置)
-
GridFS
-
Ceph RBD
-
Amazon S3
-
Sheepdog
-
OpenStack Block Storage (Cinder)
-
OpenStack Object Storage (Swift)
-
VMware ESX
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[6].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[7].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[8].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[9].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[10].png)
![](http://learn.yunwei.edu/openstack-learn/glance_files/Image%20[11].png)
[DEFAULT] [cors] [cors.subdomain] [database] connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance [glance_store] stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images/ [image_format] [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 = glance [matchmaker_redis] [oslo_concurrency] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_middleware] [oslo_policy] [paste_deploy] flavor = keystone [profiler] [store_type_location_strategy] [task] [taskflow_executor]
vim /etc/glance/glance-registry.conf
[DEFAULT] [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 = glance [matchmaker_redis] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_policy] [paste_deploy] flavor = keystone [profiler]
布建openstack的glance
1. mysql -u root -p
2. CREATE DATABASE glance;
3.
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \ IDENTIFIED BY '123';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \ IDENTIFIED BY '123';
3.source openrc
创建用户 设置角色 设置服务 创建三种服务端点
(internal内部 admin管理 public公共)
4. 退出数据库 创建 glance用户 domain项目
openstack user create --domain default --password=glance glance
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | bcaefe90e2ce41879fde9c81332a2229 |
| name | glance |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
5把glance的用户 设置在service的项目中 设置admin的权限管理员
openstack role add --project service --user glance admin
6.创建服务
openstack service create --name glance \ --description "OpenStack Image" image
问题解决
[root@node1 ~]# openstack endpoint create --region RegionOne \
> image internal http://node1:9292
Missing value auth-url required for auth plugin password
[root@node1 ~]# source openrc
7创建服务端点
openstack endpoint create --region RegionOne \
image public http://node1:9292
服务端点列表 显示两种方式
1 openstack endpoint list
2 openstack catalog list
删除不要的服务端点
openstack endpoint delete 加上ID 号
8 创建内部服务端点
openstack endpoint create --region RegionOne \ image internal http://node1:9292
9 创建管理端点
openstack endpoint create --region RegionOne \ image admin http://node1:9292
openstack endpoint list 有3个glance
10 yum install openstack-glance -y
11 cd /etc/glance/
ls
LL
修改这两个配置文件 注意属主 属组
cp glance-api.conf glance-api.conf.beifen 备份一根文件进行修改
cp glance-rgistry.conf glance-registry.conf.beifen
12 之前的全部删除掉
vim glance-api.conf glance—store 进行后台存储
[DEFAULT]
[cors]
[cors.subdomain]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@node1/glance
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[image_format]
[keystone_authtoken]
auth_uri = http://node1:5000
auth_url = http://node1:35357
memcached_servers = node1:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
[matchmaker_redis]
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_middleware]
[oslo_policy]
[paste_deploy] 认证模板
flavor = keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]
13 之前的全部删除掉
vim glance-rgistry.conf 元数据有关的工作交给rgistry
[DEFAULT]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@node1/glance
[keystone_authtoken]
auth_uri = http://node1:5000
auth_url = http://node1:35357
memcached_servers = node1:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
[matchmaker_redis]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]
14 导入表内容同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance
15 glance-api glance-registry 开机自启
# systemctl enable openstack-glance-api.service \ openstack-glance-registry.service # systemctl start openstack-glance-api.service \ openstack-glance-registry.service
查看状态
# systemctl status openstack-glance-api.service \ openstack-glance-registry.service # systemctl status openstack-glance-api.service \ openstack-glance-registry.service
创建镜像
16 wget http://download2.yunwei.edu/shell/openstack_app.tar.gz
17 ls
[root@node1 ~]# ls
1234.txt 2 3 5 7 9 apache-tomcat-9.0.20.zip openstack_app.tar.gz pjh.txt
1.txt 2.txt 4 6 8 anaconda-ks.cfg openrc openstack-ocata yum-repo.sh
18 tar zxf openstack_app.tar.gz
19 ls
[root@node1 openstack-ocata]# ls
cirros-0.3.3-x86_64-disk.img openstack-compute-yilai
20 openstack image create "cirros" \ --file cirros-0.3.3-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --public
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | 133eae9fb1c98f45894a4e60d8736619 |
| container_format | bare |
| created_at | 2019-08-03T01:22:51Z |
| disk_format | qcow2 |
| file | /v2/images/6a99c72d-e083-471d-a6f7-787cd05f8e56/file |
| id | 6a99c72d-e083-471d-a6f7-787cd05f8e56 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 77539b5d86c6419d88e99140ed0f84a1 |
| protected | False |
| schema | /v2/schemas/image |
| size | 13200896 |
| status | active |
| tags | |
| updated_at | 2019-08-03T01:22:52Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
21 openstack image list
glance image-list