如何将浏览云镜像添加到OpenStack
时间:2020-02-23 14:41:11 来源:igfitidea点击:
在本教程中,我们将研究如何将VM镜像添加到OpenStack浏览镜像服务。
我假设我们已经有一个运行的OpenStack设置,并在控制器节点上运行浏览服务。
什么是OpenStack镜像服务?
OpenStack浏览使用户能够发现,注册和检索虚拟机镜像。
存储的默认位置这些镜像被存储为/var/lib/glance /镜像/它的后端是文件。
OpenStack Image Service还提供REST API,使我们可以查询虚拟机镜像元数据并检索实际镜像。
我们可以将虚拟机镜像存储在各种位置中的镜像服务,从简单的文件系统到OpenStack对象存储等对象存储系统。
获取浏览镜像?
获取与OpenStack配合使用的虚拟机镜像的最简单方法是下载其他人已经创建的。
大多数镜像都包含云-INIT包,以支持SSH密钥对和用户数据注入。
将介绍如何通过下载其他人所做的操作系统来为各种操作系统添加镜像。
当然,我们可以创建自己的镜像,但获得现成的镜像更快。
默认登录凭据
以下是从短时间内添加的镜像创建的实例的默认登录用户名。
Debian: debian Fedora: fedora Ubuntu: ubuntu RHEL: cloud-user CentOS: centos coreos: core Arch Linux: arch Gentoo: gentoo OpenSUSE: root Cirros: username: cirros Password: cubswin:)
例子:
1.添加Cirros云镜像浏览
wget http://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img openstack image create \ --container-format bare \ --disk-format qcow2 \ --file cirros-0.5.1-x86_64-disk.img \ Cirros-0.5.1-x86_64
2.将Fedora Cloud Image添加到OpenStack
wget http://fedora.mirror.liquidtelecom.com/fedora/linux/releases/32/Cloud/x86_64/images/Fedora-Cloud-Base-32-1.6.x86_64.qcow2 openstack image create \ --container-format bare \ --disk-format qcow2 \ --file Fedora-Cloud-Base-32-1.6.x86_64.qcow2 \ Fedora-32-x86_64
3.将CentOS云镜像添加到OpenStack
CentOS 8:
wget https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.2.2004-20170611.2.x86_64.qcow2 openstack image create \ --container-format bare \ --disk-format qcow2 \ --file CentOS-8-GenericCloud-8.2.2004-20170611.2.x86_64.qcow2 \ CentOS-8-x86_64
CentOS 7:
$wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 $openstack image create \ --container-format bare \ --disk-format qcow2 \ --file CentOS-7-x86_64-GenericCloud.qcow2 \ CentOS-7-x86_64
3.将Ubuntu云镜像添加到OpenStack
Ubuntu 20.04
wget http://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img openstack image create \ --container-format bare \ --disk-format qcow2 \ --file focal-server-cloudimg-amd64.img \ Ubuntu-20.04-x86_64
Ubuntu 18.04:
$wget http://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img $openstack image create \ --container-format bare \ --disk-format qcow2 \ --file bionic-server-cloudimg-amd64.img \ Ubuntu-18.04-x86_64
4.将Debian云镜像添加到OpenStack
Debian 10:
wget http://cdimage.debian.org/cdimage/openstack/current-10/debian-10-openstack-amd64.qcow2 openstack image create \ --container-format bare \ --disk-format qcow2 \ --file debian-10-openstack-amd64.qcow2 \ Debian-10-amd64
Debian 9:
$wget http://cdimage.debian.org/cdimage/openstack/current-9/debian-9-openstack-amd64.qcow2 $openstack image create \ --container-format bare \ --disk-format qcow2 \ --file debian-9-openstack-amd64.qcow2 \ Debian-9-amd64
5.将CoreS云镜像添加到OpenStack
$wget https://stable.release.core-os.net/amd64-usr/current/coreos_production_openstack_image.img.bz2 $bunzip2 coreos_production_openstack_image.img.bz2 $openstack image create \ --container-format bare \ --disk-format qcow2 \ --file coreos_production_openstack_image.img \ CoreOS-x86_64
6.将Arch Linux云镜像添加到OpenStack
$wget https://linuximages.de/openstack/arch/arch-openstack-LATEST-image-bootstrap.qcow2 $openstack image create \ --container-format bare \ --disk-format qcow2 \ --file arch-openstack-LATEST-image-bootstrap.qcow2 \ Arch-Linux-x86_64
7.将Gentoo云镜像添加到OpenStack
$wget https://linuximages.de/openstack/gentoo/gentoo-openstack-LATEST-image-bootstrap.qcow2 $openstack image create \ --container-format bare \ --disk-format qcow2 \ --file gentoo-openstack-LATEST-image-bootstrap.qcow2 \ Gentoo-Linux-x86_64
8.添加Windows Server 2012镜像
从https://cloudbase.it/windows-cloud-images/#download下载镜像
$gunzip -cd windows_server_2012_r2_standard_eval_kvm_20160321.qcow2.gz $openstack image create \ --container-format bare \ --disk-format qcow2 \ --file windows_server_2012_r2_standard_eval_kvm_20160321.qcow2 \ Windows-Server-2012-R2-Std
检查一目了如量的镜像列表。
$openstack image list +--------------------------------------+---------------------+--------+ | ID | Name | Status | +--------------------------------------+---------------------+--------+ | 0850ee38-1bdf-4379-9c69-0cf73e8b7c65 | Arch-Linux-x86_64 | active | | e98445b6-f14f-488c-a18a-1f66c6de15c7 | CentOS-7-x86_64 | active | | 7b4b616e-71f3-4419-9777-7aee66fad62c | Cirros-0.4.0-x86_64 | active | | 98bbd9e6-abbc-45fa-ac95-b91b7b18ba0a | Debian-9-amd64 | active | | 113b90b6-4e1e-4715-b9ab-456c191a82b3 | Fedora-30-x86_64 | active | | 06c17e8a-0d4c-428a-89b5-b0eb2489f403 | Ubuntu-16.04-x86_64 | active | +--------------------------------------+---------------------+--------+
设置镜像选项选项
现在让我们将所有镜像设置为公开可见并保护它们免受意外删除。
IMAGE_IDS=`openstack image list | egrep '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' -o` for i in ${IMAGE_IDS[@]}; do openstack image set --public $i openstack image set --protected $i done
通过进入Project> Compute>镜像来确认Horizo n Dashboard。
我们应该注意到保护的标志为所有镜像和可见性设置为Yes,也可以设置为public。