OpenStack 鏡像服務Glance [三]
OpenStack鏡像服務Glance介紹
Linux運維開發群:545410476,群內有很多優秀的分類資料和大佬。
創建虛擬機我們需要有glance
的支持,因為glance
是提供鏡像服務 glance
有兩個比較重要的服務 Glance-api
接受雲系統鏡像的構建、刪除、讀取請求 Glance-Registry
雲系統的鏡像註冊服務
我們需要配置glance-api
glance-registry
配置文件 glance
不需要配置消息隊列
,但是glance需要配置keystone(認證中心)提示:默認情況下上傳鏡像存放在/var/lib/glance/images
下
安裝glance
創建數據庫和在keystone上創建glance用戶我們已經創建完成
安裝軟件包
[[email protected] ~]# yum install openstack-glance -y
修改數據庫地址
[[email protected] ~]# vim /etc/glance/glance-api.conf[database]…connection = mysql+pymysql://glance:[email protected]
修改完之後我們需要同步數據庫
[[email protected] ~]# su -s /bin/sh -c "glance-manage db_sync" glance#替我們去創建表結構,openstack有警告沒有關系,只要不是error就可以
同步完數據庫之後我們進行檢查
[[email protected] ~]# mysql -h 192.168.56.11 -u glance -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 |+----------------------------------+
我們要確保數據庫可以進行同步
設置keystone
在[keystone_authtoken]
進行設置
[[email protected] ~]# vim /etc/glance/glance-api.conf…[keystone_authtoken]auth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357memcached_servers = 192.168.56.11:11211auth_type = password #驗證類型為密碼project_domain_name = default #默認域user_domain_name = default #用戶默認域project_name = service #項目名稱username = glance #用戶password = glance #密碼
提示:必須復制在[keystone_authtoken]
模塊下,否則不生效
還需要設置[paste_deploy]
模塊
[paste_deploy]flavor = keystone#去掉註釋並修改為keystone
設置registry
,和api
的設置一樣
[[email protected] ~]# vim /etc/glance/glance-registry.conf…[keystone_authtoken]auth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357memcached_servers = 192.168.56.11:11211auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance …[paste_deploy]flavor = keystone
配置鏡像路徑
在glance-api
配置本地文件系統存儲和鏡像文件位置
[[email protected] ~]# vim /etc/glance/glance-api.conf…[glance_store]stores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/images#以上配置都是打開註釋就可以
檢查
glance-api配置文件配置小結:
[[email protected] ~]# grep ‘^[a-z]‘ /etc/glance/glance-api.conf connection = mysql+pymysql://glance:[email protected]/glancestores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/imagesauth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357memcached_servers = 192.168.56.11:11211auth_type = password project_domain_name = default user_domain_name = defaultproject_name = service username = glancepassword = glanceflavor = keystone
registry配置如下
[[email protected] ~]# grep ‘^[a-z]‘ /etc/glance/glance-registry.conf connection = mysql+pymysql://glance:[email protected]/glanceauth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357memcached_servers = 192.168.56.11:11211auth_type = password project_domain_name = defaultuser_domain_name = default project_name = service username = glance password = glance flavor = keystone提示:registry和api的配置跟我一樣現在我們就可以啟動了
設置開啟啟動並開啟服務
[[email protected] ~]# systemctl enable openstack-glance-api.service [[email protected] ~]# systemctl enable openstack-glance-registry.service [[email protected] ~]# systemctl start openstack-glance-api.service [[email protected] ~]# systemctl start openstack-glance-registry.service
提示:9292
是glance-api
的端口,9191
是glance-registry
的端口
在keystone上設置服務註冊
1.創建服務
[[email protected] ~]# source admin-openstack.sh [[email protected] ~]# openstack service create --name glance --description "OpenStack Image" image+-------------+----------------------------------+| Field | Value |+-------------+----------------------------------+| description | OpenStack Image || enabled | True || id | c9fd28645efe45faa2a9cf2f2cce623e || name | glance || type | image |+-------------+----------------------------------+
2.創建鏡像服務的API端點
[[email protected] ~]# openstack endpoint create --region RegionOne \> image public http://192.168.56.11:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | cabb8016fef74b438a341866ef10917f || interface | public || region | RegionOne || region_id | RegionOne || service_id | c9fd28645efe45faa2a9cf2f2cce623e || service_name | glance || service_type | image || url | http://192.168.56.11:9292 |+--------------+----------------------------------+[[email protected] ~]# openstack endpoint create --region RegionOne image internal http://192.168.56.11:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 0bafb4e5d90745d789a16c97fc3f5688 || interface | internal || region | RegionOne || region_id | RegionOne || service_id | c9fd28645efe45faa2a9cf2f2cce623e || service_name | glance || service_type | image || url | http://192.168.56.11:9292 |+--------------+----------------------------------+[[email protected] ~]# openstack endpoint create --region RegionOne image admin http://192.168.56.11:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 911d06d783094d62bf2cf97e4dd3fed6 || interface | admin || region | RegionOne || region_id | RegionOne || service_id | c9fd28645efe45faa2a9cf2f2cce623e || service_name | glance || service_type | image || url | http://192.168.56.11:9292 |+--------------+----------------------------------+
測試
我們可以使用openstack list
或者glance list
進行查看
[[email protected] ~]# openstack image list[[email protected] ~]# glance image-list+----+------+| ID | Name |+----+------++----+------+
提示:如果此處沒有出現空,那麽這時候就需要看日誌了。
最後我們可以上傳一個鏡像進行測試
[[email protected] ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
我們下載上面的鏡像進行測試
[[email protected] ~]# 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 | 2016-11-17T10:34:14Z || disk_format | qcow2 || file | /v2/images/fc67361d-ad30-40b2-9d96-941e50fc17f5/file || id | fc67361d-ad30-40b2-9d96-941e50fc17f5 || min_disk | 0 || min_ram | 0 || name | cirros || owner | 026a58f98402437fa95ef4a21fbd4d1a || protected | False || schema | /v2/schemas/image || size | 13287936 || status | active || tags | || updated_at | 2016-11-17T10:34:14Z || virtual_size | None || visibility | public |+------------------+------------------------------------------------------+
#提示:如果沒有環境變量還需要source
一下
檢查是否上傳成功
[[email protected] ~]# openstack image list+--------------------------------------+--------+--------+| ID | Name | Status |+--------------------------------------+--------+--------+| fc67361d-ad30-40b2-9d96-941e50fc17f5 | cirros | active |+--------------------------------------+--------+--------+[[email protected] ~]# glance image-list+--------------------------------------+--------+| ID | Name |+--------------------------------------+--------+| fc67361d-ad30-40b2-9d96-941e50fc17f5 | cirros |+--------------------------------------+--------+[[email protected] ~]# ls /var/lib/glance/images/fc67361d-ad30-40b2-9d96-941e50fc17f5鏡像存放在/var/lib/glance/images下
[M版本]
官方中文文檔:http://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/keystone-install.html
摘要
創建虛擬機我們需要有glance的支持,因為glance是提供鏡像服務,glance有兩個比較重要的服務 Glance-api接受雲系統鏡像的構建、刪除、讀取請求 Glance-Registry雲系統的鏡像註冊服務
本文出自 “一盞燭光” 博客,謝絕轉載!
OpenStack 鏡像服務Glance [三]