作者:【吴业亮】云计算开发工程师
博客:http://blog.csdn.net/wylfengyujiancheng
1、创建glance数据库
# mysql -uroot -pChangeme_123 -e "CREATE DATABASE glance;
注意将Changeme_123替换为自己的密码
2、创建数据库用户并赋予权限
# mysql -uroot -pChangeme_123 -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'Changeme_123';"
# mysql -uroot -pChangeme_123 -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'Changeme_123';"
注意将Changeme_123替换为自己的密码
3、创建glance用户及赋予admin权限
# source /root/admin-openrc.sh
# openstack user create glance --password Changeme_123
# openstack role add --project service --user glance admin
注意将Changeme_123替换为自己的密码
4、创建image服务
# openstack service create --name glance --description "OpenStack Image service" image
5、创建glance的endpoint
# openstack endpoint create --region RegionOne image public http://${HOSTNAME}:9292
# openstack endpoint create --region RegionOne image internal http://${HOSTNAME}:9292
# openstack endpoint create --region RegionOne image admin http://${HOSTNAME}:9292
6、创建glance相关rpm包
# yum install openstack-glance python-glance python-glanceclient -y
7、修改glance配置文件/etc/glance/glance-api.conf
# openstack-config --set /etc/glance/glance-api.conf database connection mysql://glance:Changeme_123@${HOSTNAME}/glance
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://${HOSTNAME}:5000
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://${HOSTNAME}:35357
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_plugin password
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_id default
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_id default
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password Changeme_123
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
# openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
# 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/
# openstack-config --set /etc/glance/glance-api.conf DEFAULT notification_driver noop
# openstack-config --set /etc/glance/glance-api.conf DEFAULT verbose True
8、修改glance配置文件/etc/glance/glance-registry.conf
# openstack-config --set /etc/glance/glance-registry.conf database connection mysql://glance:Changeme_123@${HOSTNAME}/glance
# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://${HOSTNAME}:5000
# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://${HOSTNAME}:35357
# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_plugin password
# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_id default
# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_id 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 Changeme_123
# openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
# openstack-config --set /etc/glance/glance-registry.conf DEFAULT notification_driver noop
# openstack-config --set /etc/glance/glance-registry.conf DEFAULT verbose True
9、同步数据库
# su -s /bin/sh -c "glance-manage db_sync" glance
10、启动glance及设置开机启动
# systemctl enable openstack-glance-api.service openstack-glance-registry.service
# systemctl start openstack-glance-api.service openstack-glance-registry.service
11、将glance版本号写入环境变量中
# echo " " >> /root/admin-openrc.sh && \
# echo " " >> /root/demo-openrc.sh
# echo "export OS_IMAGE_API_VERSION=2" | tee -a /root/admin-openrc.sh /root/demo-openrc.sh
12、下载镜像
# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
13、上传镜像到glance
# source /root/admin-openrc.sh
# glance image-create --name "cirros-0.3.4-x86_64" --file cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 --container-format bare --visibility public --progress
14、查看镜像
# glance image-list