创建一个云主机
Posted 人间忽晚,山河以秋
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了创建一个云主机相关的知识,希望对你有一定的参考价值。
创建云主机(续上一张)
创建云主机要先把镜像传上去
一、上传镜像
使用glance命令
可以先试用帮助命令找一下使用的参数
[root@controller ~]# glance help image-create
usage: glance image-create [--architecture <ARCHITECTURE>]
[--protected [True|False]] [--name <NAME>]
[--instance-uuid <INSTANCE_UUID>]
[--min-disk <MIN_DISK>] [--visibility <VISIBILITY>]
[--kernel-id <KERNEL_ID>]
[--tags <TAGS> [<TAGS> ...]]
[--os-version <OS_VERSION>]
[--disk-format <DISK_FORMAT>]
[--os-distro <OS_DISTRO>] [--id <ID>]
[--owner <OWNER>] [--ramdisk-id <RAMDISK_ID>]
[--min-ram <MIN_RAM>]
[--container-format <CONTAINER_FORMAT>]
[--property <key=value>] [--file <FILE>]
[--progress]
Create a new image.
Optional arguments:
--architecture <ARCHITECTURE>
Operating system architecture as specified in
http://docs.openstack.org/trunk/openstack-
compute/admin/content/adding-images.html
--protected [True|False]
If true, image will not be deletable.
--name <NAME> Descriptive name for the image
--instance-uuid <INSTANCE_UUID>
Metadata which can be used to record which instance
this image is associated with. (Informational only,
does not create an instance snapshot.)
--min-disk <MIN_DISK>
Amount of disk space (in GB) required to boot image.
--visibility <VISIBILITY>
Scope of image accessibility Valid values: public,
private
--kernel-id <KERNEL_ID>
ID of image stored in Glance that should be used as
the kernel when booting an AMI-style image.
--tags <TAGS> [<TAGS> ...]
List of strings related to the image
--os-version <OS_VERSION>
Operating system version as specified by the
distributor
--disk-format <DISK_FORMAT>
Format of the disk Valid values: ami, ari, aki, vhd,
vmdk, raw, qcow2, vdi, iso
--os-distro <OS_DISTRO>
Common name of operating system distribution as
specified in http://docs.openstack.org/trunk
/openstack-compute/admin/content/adding-images.html
--id <ID> An identifier for the image
--owner <OWNER> Owner of the image
--ramdisk-id <RAMDISK_ID>
ID of image stored in Glance that should be used as
the ramdisk when booting an AMI-style image.
--min-ram <MIN_RAM> Amount of ram (in MB) required to boot image.
--container-format <CONTAINER_FORMAT>
Format of the container Valid values: ami, ari, aki,
bare, ovf, ova, docker
--property <key=value>
Arbitrary property to associate with image. May be
used multiple times.
--file <FILE> Local file that contains disk image to be uploaded
during creation. Alternatively, the image data can be
passed to the client via stdin.
--progress Show upload progress bar.
Run `glance --os-image-api-version 1 help image-create` for v1 help
然后根据选择需要使用的参数,添加镜像
先看一下镜像
[root@controller ~]# cp /opt/iaas/images/* ./
[root@controller ~]# ll
total 8259588
-rw-r--r--. 1 root root 4 Dec 11 11:34 1.txt
-rw-------. 1 root root 1121 Dec 7 11:59 anaconda-ks.cfg
-rw-r--r--. 1 root root 283181056 Dec 11 21:15 CentOS_6.5_x86_64_XD.qcow2
-rw-r--r--. 1 root root 400752640 Dec 11 21:15 CentOS_7.2_x86_64_XD.qcow2
-rw-r--r--. 1 root root 4329570304 Jun 7 2019 CentOS-7-x86_64-DVD-1511.iso
-rw-r--r--. 1 root root 592800256 Dec 11 21:16 mysql_5.6_XD.qcow2
-rw-r--r--. 1 root root 2851502080 Nov 5 2017 XianDian-IaaS-v2.2.iso
我们上传centos7的镜像
[root@controller ~]# glance image-create --name centos7 --disk-format qcow2 --container-format bare --progress<CentOS_7.2_x86_64_XD.qcow2
[=============================>] 100%
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | ea197f4c679b8e1ce34c0aa70ae2a94a |
| container_format | bare |
| created_at | 2019-12-12T02:32:35Z |
| disk_format | qcow2 |
| id | 6babbb04-da4b-4197-a34f-7a39026bf1d8 |
| min_disk | 0 |
| min_ram | 0 |
| name | centos7 |
| owner | 5cb6243755824171b7e0873b18847545 |
| protected | False |
| size | 400752640 |
| status | active |
| tags | [] |
| updated_at | 2019-12-12T02:32:52Z |
| virtual_size | None |
| visibility | private |
+------------------+--------------------------------------+
[root@controller ~]#
上传完成后,在web页面会有一个显示
有了镜像就可以创建云主机了
根据下图顺序创建云主机
给云主机创建用户名
选择镜像
选一个规则
选择网络
然后启动实例
等待云主机创建完成后,绑定浮动ip即可
以上是关于创建一个云主机的主要内容,如果未能解决你的问题,请参考以下文章