赞
踩
本篇主要记录一下 如何安装 OpenStack 的 Glance 镜像管理组件
和上一篇一样 选择的是 queens 版本
操作系统:Centos7
有一些前置条件 如 mariadb 、 NTP 同步 、MQ 等 需要提前安装好 详细在上一篇Keystone中
https://docs.openstack.org/glance/queens/install/install-rdo.html
mysql -u root -p
MariaDB [(none)]> CREATE DATABASE glance;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'root123'; #密码可以自定义
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'root123';
openstack user create --domain default --password-prompt glance
输入密码:#自定义密码 我的是root123
重复输入密码:
openstack role add --project service --user glance admin
#This command provides no output. 就是这一行输入完后 没有任何输出
openstack service create --name glance \
--description "OpenStack Glance Image" image
上一篇有提到 endpoint 分为3种类型, public、internal、admin ,所以glance 的endpoint 也是要去创建这3种类型
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 install openstack-glance #我安装的时候很慢 最后科学上网才安装成功
[database]
# ...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance #注意替换grance密码
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS
[paste_deploy]
# ...
flavor = keystone
[glance_store]
# ...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
和上面的两步一样
[database]
# ...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance #注意替换grance密码
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS
[paste_deploy]
# ...
flavor = keystone
su -s /bin/sh -c "glance-manage db_sync" glance
执行完成后 可以去数据库里查看到 对应的glance 的表
systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
systemctl start openstack-glance-api.service \
openstack-glance-registry.service
至此 glance 已经安装完毕,那我们来测试一下 它的 上传镜像 基础功能
专门openstack 用于 测试用的小型镜像 下载地址 https://download.cirros-cloud.net/0.5.2/
glance image-create --name "cirros-0.5.2-x86_64-disk.img" --file /root/cirros-0.5.2-x86_64-disk.img --container-format bare --disk-format qcow2 --progress
openstack image list
http://192.168.56.30:9292/v2/images?
注意需要带上 X-Auth-Token 去是keystone 拿
当我们添加一个镜像到glance时,你必须指定虚拟机的disk格式和container格式,关于disk格式请自行研究kvm等虚拟。
disk和container格式是每个部署的基本配置,常用的格式如下:
1.Disk Format
不同的虚拟化应用的厂针有不同的虚拟机镜像的disk格式:
raw
This is an unstructured disk image format
vhd
This is the VHD disk format, a common disk format used by virtual machine monitors from VMware, Xen, Microsoft, VirtualBox, and others
vhdx
This is the VHDX disk format, an enhanced version of the vhd format which supports larger disk sizes among other features.
vmdk
Another common disk format supported by many common virtual machine monitors
vdi
A disk format supported by VirtualBox virtual machine monitor and the QEMU emulator
iso
An archive format for the data contents of an optical disc (e.g. CDROM).
ploop
A disk format supported and used by Virtuozzo to run OS Containers
qcow2
A disk format supported by the QEMU emulator that can expand dynamically and supports Copy on Write
aki
This indicates what is stored in Glance is an Amazon kernel image
ari
This indicates what is stored in Glance is an Amazon ramdisk image
ami
This indicates what is stored in Glance is an Amazon machine image
容器container格式是指虚拟机映像是否包含一个文件格式,该文件格式还包含有关实际虚拟机的元数据。
需要注意的是:容器格式字符串在当前并不会被glance或其他OpenStack组件的使用,所以如果你不确定,简单的将容器格式指定bare是安全的。
你可以设置如下容器格式:
bare
This indicates there is no container or metadata envelope for the image
ovf
This is the OVF container format
aki
This indicates what is stored in Glance is an Amazon kernel image
ari
This indicates what is stored in Glance is an Amazon ramdisk image
ami
This indicates what is stored in Glance is an Amazon machine image
ova
This indicates what is stored in Glance is an OVA tar archive file
docker
This indicates what is stored in Glance is a Docker tar archive of the container filesystem
本篇主要记录一下 安装 OpenStack 的 Glance 镜像管理组件的全过程,最后再进行测试glance 的上传镜像功能,以及通过API的方式获取查询镜像
欢迎大家访问 个人博客 Johnny小屋
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。