一、建立glance数据库并且给权限设置第三方登录
mysql -uroot -p0330
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 openrc或 . openrc
②创建glance用户
openstack user create --domain default --password=glance glance
③将项目service中的用户glance设置为admin角色
openstack role add --project service --user glance admin
④创建glance服务
openstack service create --name glance \ --description "OpenStack Image" image
⑤创建服务端点(RegionOne是一个域)
openstack endpoint create --region RegionOne \ image public http://controller:9292
openstack endpoint create --region RegionOne \ image internal http://controller:9292
openstack endpoint create --region RegionOne \ image admin http://controller:9292
三、安装glance镜像服务,并编辑配置文件
①安装
yum install openstack-glance
②先复制在编辑配置文件
cp /etc/glance/glance-api.conf
/etc/glance/glance-api.conf
.bak
cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
[DEFAULT] [cors] [cors.subdomain] [database] #数据库连接方式 connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance [glance_store] #镜像存储位置 stores = file,http #保存方式:文件,http类型 default_store = file #默认以文件进行存储 filesystem_store_datadir = /var/lib/glance/images/ #文件系统目录 [image_format] [keystone_authtoken] #keystone验证方式 auth_uri = http://controller:5000 #私有服务端点 auth_url = http://controller:35357 #管理服务端点 memcached_servers = controller:11211 #缓存镜像的方式memcache auth_type = password #认证类型:密码 project_domain_name = default #项目处在default域中 user_domain_name = default #user处在default域中 project_name = service #项目名称 username = glance #用户名称 password = glance #密码 [matchmaker_redis] [oslo_concurrency] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_middleware] [oslo_policy] [paste_deploy] flavor = keystone #flavor认证的模板方式 [profiler] [store_type_location_strategy] [task] [taskflow_executor]
[DEFAULT] [database] connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance [keystone_authtoken] auth_uri = http://controller:5000 auth_url = http://controller:35357 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance [matchmaker_redis] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_policy] [paste_deploy] flavor = keystone [profiler]
③同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance
④重启并设置开机自启
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service
四、上传镜像
①上传镜像
cirros-0.3.5-x86_64-disk.img
source openrc
openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public
②查看镜像列表(镜像保存在/var/lib/glance/images)
opentack image list或glance image-list
【补充】
第三方进入数据库
1.必须安装mariadb客户端
2.登录的用户必须可以第三方登录
mysql -h ip -ukeystone -pkeystone