本节开始安装Glance服务,Glance用于管理虚拟镜像,仅在CT01进行操作
1、新建数据库
CREATE DATABASE glance CHARACTER SET utf8; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance'; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance';
2、新建OS用户及endpoint
. admin-openrc openstack user create --domain default --password-prompt glance openstack role add --project serviceproject --user glance admin openstack service create --name glance --description "OpenStack Image" image openstack endpoint create --region Region01 image public http://CT01:9292 openstack endpoint create --region Region01 image internal http://CT01:9292 openstack endpoint create --region Region01 image admin http://CT01:9292
3、安装glance
apt install glance
4、修改配置文件
4.1、/etc/glance/glance-api.conf
[database] connection = mysql+pymysql://glance:glance@CT01/glance [keystone_authtoken] #注释掉其他内容 auth_uri = http://CT01:5000 auth_url = http://CT01:35357 memcached_servers = CT01:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = serviceproject username = glance password = glance [paste_deploy] flavor = keystone [glance_store] stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images/
4.2、/etc/glance/glance-registry.conf
[database] connection = mysql+pymysql://glance:glance@CT01/glance [keystone_authtoken] #注释掉其他内容 auth_uri = http://CT01:5000 auth_url = http://CT01:35357 memcached_servers = CT01:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = serviceproject username = glance password = glance [paste_deploy] flavor = keystone
5、填充数据库,并重启服务
sudo su -s /bin/sh -c "glance-manage db_sync" glance service glance-registry restart service glance-api restart
6、下载系统镜像,并上传
. admin-openrc wget -O cirros-0.3.5-x86_64-disk.img http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public openstack image list