yum install -y openstack-glance
/etc/glance/glance-api.conf
cat > /etc/glance/glance-api.conf << EOF [database] connection= mysql+pymysql://glance:glance@192.168.3.220/glance [keystone_authtoken] auth_uri = http://192.168.3.220:5000 auth_url = http://192.168.3.220:35357 memcached_servers = 192.168.3.220:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance [paste_deploy] flavor=keystone [glance_store] stores = file,http default_store=file filesystem_store_datadir=/var/lib/glance/images/ EOF
/etc/glance/glance-registry.conf
cat > /etc/glance/glance-registry.conf << EOF [database] connection= mysql+pymysql://glance:glance@192.168.3.220/glance [keystone_authtoken] auth_uri = http://192.168.3.220:5000 auth_url = http://192.168.3.220:35357 memcached_servers = 192.168.3.220:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance [paste_deploy] flavor=keystone EOF
初始化glance库
su -s /bin/sh -c "glance-manage db_sync" glance
查看表
mysql -uglance -pglance -e "use glance;show tables;"
启动并配置开机启动
systemctl restart openstack-glance-api openstack-glance-registry && systemctl enable openstack-glance-api openstack-glance-registry
keystone主机要加入服务和端点
openstack service create --name glance --description "OpenStack Image" image openstack endpoint create --region RegionOne image public http://192.168.3.220:9292 openstack endpoint create --region RegionOne image internal http://192.168.3.220:9292 openstack endpoint create --region RegionOne image admin http://192.168.3.220:9292
上传镜像(使用admin权限/上传镜像/列出镜像)
source /root/admin-openstack && openstack image create "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --public && openstack image list