一、實驗目的:
1、理解glance鏡像服務在OpenStack框架中的作用
2、掌握glance服務安裝的基本方法
3、掌握glance的配置基本方法
二、實驗步驟:
1、在controller節點上為glance服務創建數據庫,並創建訪問數據庫用戶glance並授權,參考命令
登錄mysql
#mysql -u root -p (用數據庫連接客戶端以 root 用戶連接到數據庫服務器)
#CREATE DATABASE glance;(創建 glance 數據庫)
授權
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY '密碼'; (對``glance``數據庫授予恰當的權限)
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY '密碼';(對``glance``數據庫授予恰當的權限)
2、在controller上為glance訪問創建用戶、角色和服務訪問點。
運行環境變量:
#. admin-openrc
創建glance用戶信息:
#openstack user create --domain default --password-prompt glance
添加 admin 角色到 glance 用戶和 service 項目上
#openstack role add --project service --user glance admin
創建``glance``服務實體:
#openstack service create --name glance --description "OpenStack Image" image
#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
3、在controller上安裝glance服務,參考命令
# yum install openstack-glance
4、編輯配置文件
#vi /etc/glance/glance-api.conf 配置
[database]
[keystone_authtoken]
[paste_deploy]
[glance_store]
#vi /etc/glance/glance-registry.conf
[database]
[keystone_authtoken]
[paste_deploy]
5、同步數據庫,並啟動服務,參考命令
同步數據庫:
#su -s /bin/sh -c "glance-manage db_sync" glance
啟動glance:
#systemctl enable openstack-glance-api.service openstack-glance-registry.service
# systemctl start openstack-glance-api.service openstack-glance-registry.service
6、從網絡中下載一個較小的鏡像,並上傳到服務器上
從網上下載一個鏡像到本地
上傳一個qcow2格式的鏡像:
openstack image create "cirros" \ #創建的鏡像名稱 --file cirros-0.3.4-x86_64---disk-format qcow2 --container-format bare \ --public
檢查上傳結果: