您好,登錄后才能下訂單哦!
IP地址 主機名 操作系統 192.168.56.11 linux-node1 CentOS7 192.168.56.12 linux-node2 CentOS7
其中,linux-node1當作控制節點
linux-node2當作計算節點
OpenStack鏡像服務是IaaS的核心服務。它接受磁盤鏡像或服務器鏡像API請求,和來自終端用戶或OpenStack計算組件的元數據定義。它也支持包括OpenStack對象存儲在內的多種類型倉庫上的磁盤鏡像或服務器鏡像存儲。 大量周期性進程運行于OpenStack鏡像服務上以支持緩存。同步復制(Replication)服務保證集群中的一致性和可用性。其它周期性進程包括auditors, updaters, 和 reapers。 OpenStack鏡像服務包括以下組件: glance-api 接收鏡像API的調用,諸如鏡像發現、恢復、存儲。 監聽9292端口 glance-registry 存儲、處理和恢復鏡像的元數據,元數據包括項諸如大小和類型 監聽9191端口 #glance-registry是私有內部服務,用于服務OpenStack Image服務。不要向用戶暴露該服務
[root@linux-node1 ~]# yum install -y openstack-glance
先決條件
創建用戶
配置數據庫連接
vim /etc/glance/glance-api.conf connection = mysql+pymysql://glance:glance@192.168.56.11/glance
配置數據庫連接
vim /etc/glance/glance-registry.conf connection = mysql+pymysql://glance:glance@192.168.56.11/glance
同步數據庫,創建glance的表結構
su -s /bin/sh -c "glance-manage db_sync" glance
同步完成后,確認一下創建是否成功
[root@linux-node1 ~]# mysql -h 192.168.56.11 -uglance -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 | +----------------------------------+
修改glance-api.conf
vim /etc/glance/glance-api.conf #在[keystone_authtoken]下添加 auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance #在[paste_deploy]下添加 flavor = keystone
修改glance-registry.conf
vim /etc/glance/glance-registry.conf 在[keystone_authtoken]下添加 auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance 在[paste_deploy]下添加 flavor = keystone
編輯glance-api.conf
在[glance_store]下修改 stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/p_w_picpaths
設置開機啟動 [root@linux-node1 ~]# systemctl enable openstack-glance-api.service \ > openstack-glance-registry.service 啟動glance [root@linux-node1 ~]# systemctl start openstack-glance-api.service \ > openstack-glance-registry.service
執行netstat -lntp查看端口監聽情況,若9292和9191都已監聽,則證明glance啟動成功。
在創建之前,要先執行環境變量腳本
[root@linux-node1 ~]# source admin-openstack.sh
再創建glance服務實體
[root@linux-node1 ~]# openstack service create --name glance --description "OpenStack Image" p_w_picpath +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image | | enabled | True | | id | 6b6de8cbe36d439bb9a4ef90a7aa6f0e | | name | glance | | type | p_w_picpath | +-------------+----------------------------------+
創建鏡像服務的API endpoint
[root@linux-node1 ~]# openstack endpoint create --region RegionOne p_w_picpath public http://192.168.56.11:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 560d86e5e9074b4b9a98564298e2e3bf | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 6b6de8cbe36d439bb9a4ef90a7aa6f0e | | 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 | 9f9bf0ef9e804099b2a11a94d8181e48 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 6b6de8cbe36d439bb9a4ef90a7aa6f0e | | 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 | f7008f53f5664a6f81b90841fee66c93 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 6b6de8cbe36d439bb9a4ef90a7aa6f0e | | service_name | glance | | service_type | p_w_picpath | | url | http://192.168.56.11:9292 | +--------------+----------------------------------+
驗證是否創建成功
[root@linux-node1 ~]# openstack p_w_picpath list [root@linux-node1 ~]# glance p_w_picpath-list +----+------+ | ID | Name | +----+------+ +----+------+ [root@linux-node1 ~]# 執行上面兩條命令,若返回結果與上面結果一致,則服務注冊成功。
使用QCOW2磁盤格式,bare容器格式上傳鏡像到鏡像服務并設置為public,這樣所有的項目都可以訪問它
[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-10-27T16:21:42Z | | disk_format | qcow2 | | file | /v2/p_w_picpaths/29d99654-ba91-4d04-8808-e1b8d16861fb/file | | id | 29d99654-ba91-4d04-8808-e1b8d16861fb | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | 53f72af1420a4d098d48f2c82d7e9ec7 | | protected | False | | schema | /v2/schemas/p_w_picpath | | size | 13287936 | | status | active | | tags | | | updated_at | 2016-10-27T16:21:43Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+
查看鏡像是否創建成功
[root@linux-node1 ~]# openstack p_w_picpath list +--------------------------------------+--------+--------+ | ID | Name | Status | +--------------------------------------+--------+--------+ | 29d99654-ba91-4d04-8808-e1b8d16861fb | cirros | active | +--------------------------------------+--------+--------+ [root@linux-node1 ~]# glance p_w_picpath-list +--------------------------------------+--------+ | ID | Name | +--------------------------------------+--------+ | 29d99654-ba91-4d04-8808-e1b8d16861fb | cirros | +--------------------------------------+--------+
鏡像上傳所在的目錄
[root@linux-node1 ~]# cd /var/lib/glance/p_w_picpaths/ [root@linux-node1 p_w_picpaths]# ls 29d99654-ba91-4d04-8808-e1b8d16861fb
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。