21/100保存草稿发布文章 博文管理我的博客退出加粗 斜体 标题 删除线 无序 有序 待办 引用 代码块 BashCC++C#CLikeCSSGoHandlebarsJavaJavaScriptKotlinMarkupObjective-CPerlPHPShellPythonRubySQLSwiftVB.NetYAML图片 上传图片实验版,新增正版图库功能 视频 表格 超链接 摘要 导入 导出 保存 填写标题才可自动保存 撤销 重做 目录 帮助
Openstack的镜像服务——Glance
1、 Glance概述
https://docs.openstack.org/glance/rocky/install/install-rdo.html#install-and-configure-components
2、 Glance的安装
2.1 、安装Glance组件
[root@linux-node1~]# yum install -y openstack-glance
2.2、 配置Glance
编辑/etc/glance/glance-api.conf文件,完成以下设置
[database]...connection =mysql+pymysql://glance:GLANCE_DBPASS@Controller/glance
注意:替换GLANCE_DBPASS用在数据库中创建Glance时的密码
1901 connection = mysql+pymysql://glance:glance@192.168.56.104/glance
同时可以编辑/etc/glance/glance-registry.conf
[database]...connection =mysql+pymysql://Glance:GLANCE_DBPASS@Controller/Glance
注意:替换GLANCE_DBPASS用在数据库中创建Glance时的密码
1146 connection = mysql+pymysql://glance:glance@192.168.56.104/glance
然后同步数据库
[root@linux-node1Glance]# su -s /bin/sh -c "glance-manage db_sync" glance
会有一些警告信息,可以忽略。
[root@linux-node1
Glance]# mysql -h 192.168.56.104 -uglance -pglance -e "use glance;show
tables;"
证明数据库配置正确!!
编辑/etc/glance/glance-api.conf文件
[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_PASS
注意修改相关内容
auth_uri =http://192.168.56.11:5000
auth_url =http://192.168.56.11:35357
memcached_servers= 192.168.56.11:11211
auth_type =password
project_domain_name= default
user_domain_name =default
project_name =service
username = glance
password = glance
[Glance_store]
...
1941 stores =
file,http
1973 default_store= file
2292
filesystem_store_datadir = /var/lib/Glance/images/
[paste_deploy]
...
4268 flavor = keystone
配置/etc/Glance/Glance-registry.conf
1204
[keystone_authtoken]
auth_uri = http://192.168.56.11:5000
auth_url =
http://192.168.56.11:35357
memcached_servers
= 192.168.56.11:11211
auth_type =
password
project_domain_name
= default
user_domain_name =
default
project_name =
service
username = Glance
password = Glance
[paste_deploy]
...
2160 flavor =
keystone
配置完成后我们可以查看一下在这里完成了哪些配置?
[root@linux-node1
Glance]# grep '^[a-Z]' /etc/Glance/Glance-api.conf
connection =
mysql+pymysql://Glance:Glance@192.168.56.11/Glance
stores = file,http
default_store =
file
filesystem_store_datadir
= /var/lib/Glance/images
auth_uri =
http://192.168.56.11:5000
auth_url =
http://192.168.56.11:35357
memcached_servers
= 192.168.56.11:11211
auth_type =
password
project_domain_name
= default
user_domain_name =
default
project_name =
service
username = Glance
password = Glance
flavor = keystone
[root@linux-node1
Glance]# grep '^[a-Z]' /etc/Glance/Glance-registry.conf
connection =
mysql+pymysql://Glance:Glance@192.168.56.11/Glance
auth_uri =
http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
memcached_servers
= 192.168.56.11:11211
auth_type =
password
project_domain_name
= default
user_domain_name =
default
project_name =
service
username = Glance
password = Glance
flavor = keystone
2.3 、启动Glance服务
[root@linux-node1
Glance]# systemctl enable openstack-glance-api.service openstack-glance-registry.service
[root@linux-node1
Glance]# systemctl start openstack-glance-api.service openstack-glance-registry.service
以下内容为10.16日新增
[root@controller Glance]# ps -e|grep Glance
3959 ? 00:00:02 Glance-api
3960 ? 00:00:01 Glance-registry
3977 ? 00:00:00 Glance-registry
3978 ? 00:00:00 Glance-registry
3979 ? 00:00:00 Glance-registry
3980 ? 00:00:00 Glance-registry
3981 ? 00:00:00 Glance-api
3982 ? 00:00:00 Glance-api
3985 ? 00:00:00 Glance-api
3986 ? 00:00:00 Glance-api
发现端口9191和9292已经被监听,服务启动。
[root@linux-node1~]# ps aux | grep Glance
日志目录在 /var/log/Glance
[root@linux-node1~]# cd /var/log/Glance
[root@linux-node1Glance]# ll
总用量 28
-rw-r--r-- 1
Glance Glance 22415 7月 23 04:14 api.log
-rw-r--r-- 1
Glance Glance 258 7月 23
04:14 registry.log
[root@linux-node1Glance]#
3、 Glance服务注册与镜像上传
3.1、 创建Glance的服务实体
[root@linux-node1~]# source admin-openrc.sh
[root@linux-node1~]# openstack service create --name glance --description "OpenStack Image"image
查看一下刚才创建的Glance服务
[root@linux-node1~]# openstack service list
显示结果
3.2、 创建Image service API endpoints
[root@linux-node1~]# openstack endpoint create --region RegionOne image public
http://192.168.56.104:9292
[root@linux-node1
~]# openstack endpoint create --region RegionOne image internal
http://192.168.56.104:9292
[root@linux-node1
~]# openstack endpoint create --region RegionOne image admin
http://192.168.56.104:9292
[root@linux-node1
~]# openstack endpoint list
查看一下我们新创建的endpoint
查看一下Glance的镜像
[root@linux-node1
~]# Glance image-list
还未上传镜像,所以这里是空的,注意此处要是报错的话,那就说明Glance的安装是有问题的。
3.3 镜像上传
(1)下载一个镜像文件wget
http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
(2)上传镜像文件
openstack image create
“cirros” \
–file cirros-0.3.4-x86_64-disk.img \
–disk-format qcow2 --container-format bare \
–public
[root@linux-node1~]# openstack image list
[root@linux-node1
images]# pwd
/var/lib/Glance/images
[root@linux-node1
images]# ll
总用量 12980
-rw-r----- 1
Glance Glance 13287936 7月 26 23:54 a1ed0cae-705e-4bd7-a143-a4dcea6a66dc
[root@linux-node1
images]# Glance image-list
Glance服务安装配置完毕