OpenStack 运维 - 部署Glance组件 [T版]

Posted serendipity_cat

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenStack 运维 - 部署Glance组件 [T版]相关的知识,希望对你有一定的参考价值。

OpenStack 运维 - 部署Glance组件

一、创建数据库实例和数据库用户

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';

flush privileges;

exit

二、创建用户修改配置文件

#创建用户
openstack user create --domain default --password GLANCE_PASS glance	

#添加服务和用户权限glance为管理员
openstack role add --project service --user glance admin

#创建新的服务类型镜像
openstack service create --name glance --description "OpenStack Image" image

openstack service list

三、创建镜像服务API

使用三种API端点代表三种服务:admin、internal、public

openstack endpoint create --region RegionOne image admin http://ct:9292

openstack endpoint create --region RegionOne image internal http://ct:9292

openstack endpoint create --region RegionOne image public http://ct:9292

四、安装OpenStack-glance

yum -y install openstack-glance

五、修改glance配置文件

配置文件:glance-api.confglance-registry.conf

cp -a /etc/glance/glance-api.conf,.bak
grep -Ev '^$|#' /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf

openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@ct/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/

----

cat glance-api.conf
[DEFAULT]
[cinder]
[cors]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
[file]
[glance.store.http.store]
[glance.store.rbd.store]
[glance.store.sheepdog.store]
[glance.store.swift.store]
[glance.store.vmware_datastore.store]

[glance_store]
stores = file,http					#存储类型,file:文件,http:基于api调用的方式,把镜像放到其他存储上
default_store = file					#默认存储方式
filesystem_store_datadir = /var/lib/glance/images/	##指定镜像存放的本地目录

[image_format]
[keystone_authtoken]
www_authenticate_uri = http://ct:5000			##指定认证的keystone的URI
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service				#glance用户针对service项目拥有admin权限
username = glance
password = GLANCE_PASS

[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]

[paste_deploy]
flavor = keystone					#指定提供认证的服务器为keystone

[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]
cp -a /etc/glance/glance-registry.conf,.bak
grep -Ev '^$|#' /etc/glance/glance-registry.conf.bak > /etc/glance/glance-registry.conf

openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@ct/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/

六、初始化glance数据库

su -s /bin/sh -c "glance-manage db_sync" glance

① 开启服务

systemctl enable openstack-glance-api
systemctl start openstack-glance-api

② 查看端口

netstat -natp | grep 9292

③ 赋予glance服务的读写权限

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 运维 - 部署Glance组件 [T版]的主要内容,如果未能解决你的问题,请参考以下文章

OpenStack 的部署——Glance组件

openstack Glance 部署

传统公司部署OpenStack(t版)简易介绍——Glance组件部署

传统公司部署OpenStack(t版)简易介绍——Glance组件部署

OpenStack-Glance组件部署

OpenStack架构----glance组件