您好,登錄后才能下訂單哦!
OpenStack 鏡像服務Glance [三]
openstack
時間:2016年11月28日
創建虛擬機我們需要有glance
的支持,因為glance
是提供鏡像服務 glance
有兩個比較重要的服務 Glance-api
接受云系統鏡像的構建、刪除、讀取請求 Glance-Registry
云系統的鏡像注冊服務
我們需要配置glance-api
的配置文件和glance-registry
配置文件
glance
不需要配置消息隊列
,但是glance需要配置keystone(認證中心)
提示:默認情況下上傳鏡像存放在/var/lib/glance/p_w_picpaths
下
安裝glance
創建數據庫和在keystone上穿件glance用戶我們已經創建完成
安裝軟件包
[root@linux-node1 ~]# yum install openstack-glance -y
修改數據庫地址
[root@linux-node1 ~]# vim /etc/glance/glance-api.conf[database]…connection = mysql+pymysql://glance:glance@192.168.56.11/glance…[root@linux-node1 ~]# vim /etc/glance/glance-registry.conf[database]…connection = mysql+pymysql://glance:glance@192.168.56.11/glance…#打開注釋,寫mysql地址,注意是在database默認下
修改完之后我們需要同步數據庫
[root@linux-node1 ~]# su -s /bin/sh -c "glance-manage db_sync" glance#替我們去創建表結構,openstack有警告沒有關系,只要不是error就可以
同步完數據庫之后我們進行檢查
[root@linux-node1 ~]# 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 || p_w_picpath_locations || p_w_picpath_members || p_w_picpath_properties || p_w_picpath_tags || p_w_picpaths || metadef_namespace_resource_types || metadef_namespaces || metadef_objects || metadef_properties || metadef_resource_types || metadef_tags || migrate_version || task_info || tasks |+----------------------------------+
我們要確保數據庫可以進行同步
在[keystone_authtoken]
進行設置
[root@linux-node1 ~]# 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
的設置一樣
[root@linux-node1 ~]# 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
配置本地文件系統存儲和鏡像文件位置
[root@linux-node1 ~]# vim /etc/glance/glance-api.conf…[glance_store]stores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/p_w_picpaths#以上配置都是打開注釋就可以
檢查
glance-api配置文件配置小結:
[root@linux-node1 ~]# grep '^[a-z]' /etc/glance/glance-api.conf connection = mysql+pymysql://glance:glance@192.168.56.11/glancestores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/p_w_picpathsauth_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配置如下
[root@linux-node1 ~]# grep '^[a-z]' /etc/glance/glance-registry.conf connection = mysql+pymysql://glance:glance@192.168.56.11/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的配置跟我一樣現在我們就可以啟動了
設置開啟啟動并開啟服務
[root@linux-node1 ~]# systemctl enable openstack-glance-api.service [root@linux-node1 ~]# systemctl enable openstack-glance-registry.service [root@linux-node1 ~]# systemctl start openstack-glance-api.service [root@linux-node1 ~]# systemctl start openstack-glance-registry.service
提示:9292
是glance-api
的端口,9191
是glance-registry
的端口
在keystone上設置服務注冊
1.創建服務
[root@linux-node1 ~]# source admin-openstack.sh [root@linux-node1 ~]# openstack service create --name glance --description "OpenStack Image" p_w_picpath+-------------+----------------------------------+| Field | Value |+-------------+----------------------------------+| description | OpenStack Image || enabled | True || id | c9fd28645efe45faa2a9cf2f2cce623e || name | glance || type | p_w_picpath |+-------------+----------------------------------+
2.創建鏡像服務的API端點
[root@linux-node1 ~]# openstack endpoint create --region RegionOne \> p_w_picpath 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 | p_w_picpath || url | http://192.168.56.11:9292 |+--------------+----------------------------------+[root@linux-node1 ~]# openstack endpoint create --region RegionOne p_w_picpath 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 | p_w_picpath || url | http://192.168.56.11:9292 |+--------------+----------------------------------+[root@linux-node1 ~]# openstack endpoint create --region RegionOne p_w_picpath 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 | p_w_picpath || url | http://192.168.56.11:9292 |+--------------+----------------------------------+
測試
我們可以使用openstack list
或者glance list
進行查看
[root@linux-node1 ~]# openstack p_w_picpath list[root@linux-node1 ~]# glance p_w_picpath-list+----+------+| ID | Name |+----+------++----+------+
提示:如果此處沒有出現空,那么這時候就需要看日志了。
最后我們可以上傳一個鏡像進行測試
[root@linux-node1 ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
我們下載上面的鏡像進行測試
[root@linux-node1 ~]# openstack p_w_picpath 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/p_w_picpaths/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/p_w_picpath || size | 13287936 || status | active || tags | || updated_at | 2016-11-17T10:34:14Z || virtual_size | None || visibility | public |+------------------+------------------------------------------------------+
#提示:如果沒有環境變量還需要source
一下
檢查是否上傳成功
[root@linux-node1 ~]# openstack p_w_picpath list+--------------------------------------+--------+--------+| ID | Name | Status |+--------------------------------------+--------+--------+| fc67361d-ad30-40b2-9d96-941e50fc17f5 | cirros | active |+--------------------------------------+--------+--------+[root@linux-node1 ~]# glance p_w_picpath-list+--------------------------------------+--------+| ID | Name |+--------------------------------------+--------+| fc67361d-ad30-40b2-9d96-941e50fc17f5 | cirros |+--------------------------------------+--------+[root@linux-node1 ~]# ls /var/lib/glance/p_w_picpaths/fc67361d-ad30-40b2-9d96-941e50fc17f5鏡像存放在/var/lib/glance/p_w_picpaths下
[M版本]
官方中文文檔:http://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/keystone-install.html
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。