在控制節點上執行
controllerHost='controller'
MYSQL_PASSWD='m4r!adbOP'
GLANCE_PASSWD='glance1234!'
python
1.建立數據庫
mysql -uroot -p${MYSQL_PASSWD} << EOF
DROP DATABASE IF EXISTS glance;
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '${GLANCE_PASSWD}';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '${GLANCE_PASSWD}';
EOFmysql
2.建立認證用戶並受權
source ~/admin-openrc
openstack user create --domain default --password ${GLANCE_PASSWD} glance
openstack role add --project service --user glance adminsql
3.建立服務實體和端點
openstack service create --name glance --description "OpenStack Image" image
openstack endpoint create --region RegionOne image public http://${controllerHost}:9292
openstack endpoint create --region RegionOne image internal http://${controllerHost}:9292
openstack endpoint create --region RegionOne image admin http://${controllerHost}:9292數據庫
4.安裝glance組件
yum -y install openstack-glance python-glance python-glanceclientubuntu
5.配置glance服務訪問數據庫
openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:${GLANCE_PASSWD}@${controllerHost}/glance後端openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:${GLANCE_PASSWD}@${controllerHost}/glancecentos
6.配置glance服務訪問memcached
openstack-config --set /etc/glance/glance-api.conf cache backend oslo_cache.memcache_pool
openstack-config --set /etc/glance/glance-api.conf cache enabled True
openstack-config --set /etc/glance/glance-api.conf cache memcache_servers ${controllerHost}:11211apiopenstack-config --set /etc/glance/glance-registry.conf cache backend oslo_cache.memcache_pool
openstack-config --set /etc/glance/glance-registry.conf cache enabled True
openstack-config --set /etc/glance/glance-registry.conf cache memcache_servers ${controllerHost}:11211dom
7.配置glance服務訪問認證服務
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://${controllerHost}:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://${controllerHost}:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password ${GLANCE_PASSWD}memcachedopenstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://${controllerHost}:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://${controllerHost}:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password ${GLANCE_PASSWD}
8.配置glance服務禁用ceilometer消息機制
openstack-config --set /etc/glance/glance-api.conf DEFAULT notification_driver = noopopenstack-config --set /etc/glance/glance-registry.conf DEFAULT notification_driver = noop
9.配置glance服務的監聽IP
openstack-config --set /etc/glance/glance-api.conf DEFAULT bind_host 0.0.0.0openstack-config --set /etc/glance/glance-registry.conf DEFAULT bind_host 0.0.0.0
10.同步數據庫
su -s /bin/sh -c "glance-manage db_sync" glance
11.啓動glance服務
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service
systemctl status openstack-glance-api.service openstack-glance-registry.service
12.配置glance服務使用本地文件系統做爲後端存儲
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
13.重啓glance服務
systemctl restart openstack-glance-api.service openstack-glance-registry.service
systemctl status openstack-glance-api.service openstack-glance-registry.service
14.上傳鏡像
source ~/admin-openrc
yum -y install qemu-img
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
qemu-img convert -f qcow2 cirros-0.4.0-x86_64-disk.img -O raw cirros-0.4.0-x86_64-disk.img.raw
openstack image create cirros0.4 --disk-format raw --file cirros-0.4.0-x86_64-disk.img.raw --container-format bare --public --protected
openstack image list#wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1811.qcow2.xz #openstack image create centos7.6 --disk-format qcow2 --file CentOS-7-x86_64-GenericCloud-1811.qcow2 --container-format bare --protected --public #wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img #openstack image create ubuntu16.04 --disk-format qcow2 --file xenial-server-cloudimg-amd64-disk1.img --container-format bare --protected --public