一、创建数据库
mysql -u root -p
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';
二、应用脚本登录创建glance用户
source admin-openrc.sh openstack user create --domain default --password-prompt glance openstack role add --project service --user glance admin openstack service create --name glance --description "OpenStack Image service" image
三、创建镜像服务API端点
openstack endpoint create --region RegionOne image public http://horizon:9292 openstack endpoint create --region RegionOne image internal http://horizon:9292 openstack endpoint create --region RegionOne image admin http://horizon:9292
四、镜像服务(glance)的源码安装开始
将tar包考入操作文件夹中,然后进行安装
cd glance-11.0.0/ vim requirements.txt 注释 #Routes!=2.0,!=2.1,>=1.12.3;python_version=='2.7' #Routes!=2.0,>=1.12.3;python_version!='2.7' pip install -r requirements.txt python setup.py install cd ../ cd python-glanceclient-1.2.0/ vim requirements.txt 注释 #Routes!=2.0,!=2.1,>=1.12.3;python_version=='2.7' #Routes!=2.0,>=1.12.3;python_version!='2.7' pip install -r requirements.txt python setup.py install cd ../
将配置文件考入etc下
cd glance-11.0.0/ cp -R etc /etc/glance chown -R laks:laks /etc/glance
编辑/etc/glance/glance-api.conf
复制备份以及去除注释
cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak cat /etc/glance/glance-api.conf.bak | grep -v '^#'| grep -v '^$'> /etc/glance/glance-api.conf
[DEFAULT] notification_driver = noop verbose = True [database] connection = mysql+pymysql://glance:GLANCE_DBPASS@horizon/glance [glance_store] default_store = file filesystem_store_datadir = /var/lib/glance/images/ [image_format] [keystone_authtoken] auth_uri = http://horizon:5000 auth_url = http://horizon:35357 auth_plugin = password project_domain_id = default user_domain_id = default project_name = service username = glance password = glance [matchmaker_redis] [matchmaker_ring] [oslo_concurrency] [oslo_messaging_amqp] [oslo_messaging_qpid] [oslo_messaging_rabbit] [oslo_policy] [paste_deploy] flavor = keystone [store_type_location_strategy] [task] [taskflow_executor]
编辑/etc/glance/glance-registry.conf
cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak cat /etc/glance/glance-registry.conf.bak | grep -v '^#'| grep -v '^$'> /etc/glance/glance-registry.conf
[DEFAULT] notification_driver = noop verbose = True [database] connection = mysql+pymysql://glance:GLANCE_DBPASS@horizon/glance [glance_store] [keystone_authtoken] auth_uri = http://horizon:5000 auth_url = http://horizon:35357 auth_plugin = password project_domain_id = default user_domain_id = default project_name = service username = glance password = glance [matchmaker_redis] [matchmaker_ring] [oslo_messaging_amqp] [oslo_messaging_qpid] [oslo_messaging_rabbit] [oslo_policy] [paste_deploy] flavor = keystone
添加用户
useradd glance mkdir -p /home/glance
同步数据库并且重启服务
su -s /bin/sh -c "glance-manage db_sync" glance glance-control api start glance-control registry start 若是服务已经起来 service glance-registry restart service glance-api restart
rm -f /var/lib/glance/glance.sqlite
五、验证服务
echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh source admin-openrc.sh wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
glance image-create --name "cirros" \ --file cirros-0.3.4-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --visibility public --progress
glance image-list
+--------------------------------------+--------+ | ID | Name | +--------------------------------------+--------+ | 4e53b72d-7771-4498-99cf-dce8035a92df | cirros | +--------------------------------------+--------+