萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 作業系統 >  >> Linux 教學

OpenStack 安裝篇——控制節點部署 Glance 映像服務

前置條件

  1. 建立 glance 資料庫並授權:
    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';
    FLUSH PRIVILEGES;
  2. 載入 admin 憑證:source admin-openrc.sh
  3. 建立 glance 服務用戶、角色與端點:
    keystone user-create --name glance --pass GLANCE_PASS
    keystone user-role-add --user glance --tenant service --role admin
    keystone service-create --name glance --type image --description "OpenStack Image Service"
    keystone endpoint-create --service-id $(keystone service-list | awk '/ image / {print $2}') --publicurl https://controller:9292 --internalurl https://controller:9292 --adminurl https://controller:9292 --region regionOne

安裝與配置 Glance 套件

yum install openstack-glance python-glanceclient

編輯 /etc/glance/glance-api.conf

[database]
connection = mysql://glance:GLANCE_DBPASS@controller/glance

[keystone_authtoken]
auth_uri = https://controller:5000/v2.0
identity_uri = https://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = GLANCE_PASS

[paste_deploy]
flavor = keystone

[DEFAULT]
verbose = True

編輯 /etc/glance/glance-registry.conf

database、keystone_authtoken、paste_deploy 區段同上;DEFAULT 同樣啟用 verbose = True。

初始化資料庫與啟動服務

su -s /bin/sh -c "glance-manage db_sync" glance
systemctl enable openstack-glance-api openstack-glance-registry --now

驗證操作:上傳 CirrOS 測試映像

mkdir /tmp/images && cd /tmp/images
wget https://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img
source admin-openrc.sh
glance image-create --name "cirros-0.3.3-x86_64" --file cirros-0.3.3-x86_64-disk.img --disk-format qcow2 --container-format bare --is-public True --progress
glance image-list
rm -r /tmp/images

若 glance image-list 顯示狀態 active,即代表映像服務部署成功。

copyright © 萬盛學電腦網 all rights reserved