一、glance介紹:

-
如果要安裝的系統多了效率就很低
-
時間長,工作量大
-
安裝完還要進行手工配置,比如安裝其他的軟件,設置 IP 等
-
備份和恢復系統不靈活
-
先手工安裝好這么一個虛機
-
然后對虛機執行 snapshot,這樣就得到了一個 image
-
當有新員工入職需要辦公環境時,立馬啟動一個或多個該 image 的 instance(虛機)就可以了
-
提供 REST API 讓用戶能夠查詢和獲取 image 的元數據和 image 本身
-
支持多種方式存儲 image,包括普通的文件系統、Swift、Amazon S3 等
-
對 Instance 執行 Snapshot 創建新的 image

glance-api

glance-registry


Database

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



二、glance創建鏡像:
一、建立glance數據庫並且給權限設置第三方登錄
mysql -uroot -p0330
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \ IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \ IDENTIFIED BY 'GLANCE_DBPASS';
二、部署glance
①宣告環境變量
source openrc或 . openrc
②創建glance用戶
openstack user create --domain default --password=glance glance
③將項目service中的用戶glance設置為admin角色
openstack role add --project service --user glance admin
④創建glance服務
openstack service create --name glance \ --description "OpenStack Image" image
⑤創建服務端點(RegionOne是一個域)
openstack endpoint create --region RegionOne \ image public http://controller:9292
openstack endpoint create --region RegionOne \ image internal http://controller:9292
openstack endpoint create --region RegionOne \ image admin http://controller:9292
三、安裝glance鏡像服務,並編輯配置文件
①安裝
yum install openstack-glance
②先復制再編輯配置文件(復制和無需更改)
cp /etc/glance/glance-api.conf
/etc/glance/glance-api.conf
.bak
cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak

[DEFAULT] [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]

[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]
③同步數據庫
su -s /bin/sh -c "glance-manage db_sync" glance
④重啟並設置開機自啟
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service
四、上傳鏡像
①上傳鏡像
cirros-0.3.3-x86_64-disk.img
source openrc
②查看鏡像列表(鏡像保存在/var/lib/glance/images)
opentack image list或glance image-list
【補充】
第三方進入數據庫
1.必須安裝mariadb客戶端
2.登錄的用戶必須可以第三方登錄
mysql -h ip -ukeystone -pkeystone
3.注釋多行
ctrl +v—— 全部選中——shift i ——#——esc兩次
取消多行注釋
ctrl +v——全部選中——dd
4、常用服務端口號:
8778 placement 6080 novncproxy 9292 glance-registry 8774 nova 9191 registry-api 11211 memcached
9696 neutron
6080 novncproxy
6633 openvswitch
6640 openvswitch
5000 keystone
35357 keystone (雖說時keystone的端口號,但是啟動與否與apache服務是否啟動有最直接關系)
5672(25672) rabbitmq
8776 cinder
5、報錯:
1)Missing value auth-url required for auth plugin password
因為沒聲明變量
2)Unable to establish connection to http://controller:35357
因為35357服務沒啟動,查看msgi配置文件和httpd服務情況