mysql -u root -p123456
create database glance;
grant all privileges on glance.* to 'glance'@'%' identified by 'glance_dbpass';
grant all privileges on glance.* to 'glance'@'localhost' identified by 'glance_dbpass';pass';
flush privileges;
exit;
创建用户前,需要首先执行管理员环境变量脚本(此处已经在~/.bashrc 中定义过了)
openstack user create --domain default --password glance_pass glance
openstack role add --project service --user glance admin
openstack service create --name glance --description "OpenStack Image" image
OpenStack使用三种API端点代表三种服务:admin、internal、public
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
yum -y install openstack-glance
glance有两个配置文件:
/etc/glance/glance-api.conf
/etc/glance/glance-registry.conf
cp -a /etc/glance/glance-api.conf{,.bak}
grep -Ev '^$|#' /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf
cp -a /etc/glance/glance-registry.conf{,.bak}
openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:glance_dbpass@controller/glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken www_authenticate_uri http://controller:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://controller:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password glance_pass
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
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 database connection mysql+pymysql://glance:glance_dbpass@controller/glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers ct:11211
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password glance_pass
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
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-registry.conf database connection mysql+pymysql://glance:glance_dbpass@controller/glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken www_authenticate_uri http://controller:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name 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 glance_pass
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
不管有多少个controler,只需要初始化一次即可
su -s /bin/sh -c "glance-manage db_sync" glance
此处开启之后会生成存放镜像的目录/var/lib/glance/image
systemctl enable openstack-glance-api.service
systemctl start openstack-glance-api.service
netstat -natp | grep 9292
-h:值对符号连接/软链接的文件修改
chown -hR glance:glance /var/lib/glance/
openstack image create --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros
openstack image list
glance image-list
因为OpenStack上创建虚拟机需要镜像支持,所以先行进行部署;
部署思路:
1、创建数据库、授权;
2、创建openstack用户、授权、管理;
3、修改配置文件(glance-api.conf、glance-registry.conf);
4、初始化数据库、上传实例镜像