使用nova boot命令创建openstack实例

使用命令:nova boot --flavor 1 --key_name mykey--image 9e5c2bee-0373-414c-b4af-b91b0246ad3b --security_group default cirrOS

其中:

flavor是虚拟机的配置,比如说内存大小,硬盘大小等,默认下1为最小,4为最大。

key_name是创建虚拟机使用的密钥,使用以下三条命令创建密钥:

ssh-keygen

cd.ssh

nova keypair-add --pub_key id_rsa.pub mykey

image是已上传镜像的ID,使用nova image-list查询。

security_group是安全组。

cirrOS是你所要创建的虚拟机名。

[email protected]:/home/stack$ pwd

/home/stack

[email protected]:/home/stack$ nova keypair-add oskey >oskey.priv

[email protected]:/home/stack$ chmod 600 oskey.priv

[email protected]:/home/stack$ nova flavor-list

+-----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

| ID | Name      | Memory_MB | Disk |Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |

+-----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

| 1  | m1.tiny   | 512       | 1    | 0        |      | 1     | 1.0         | True      |

| 2   | m1.small | 2048      | 20   | 0        |      | 1     | 1.0         | True      |

| 3  | m1.medium | 4096      | 40   | 0        |      | 2     | 1.0         | True      |

| 4  | m1.large  | 8192      | 80  | 0         |      | 4    | 1.0         | True      |

| 42 | m1.nano   | 64        | 0   | 0         |      | 1    | 1.0         | True      |

| 451 | m1.heat   | 512      | 0    | 0         |     | 1     | 1.0         | True      |

| 5  | m1.xlarge | 16384     | 160  | 0        |      | 8     | 1.0         | True      |

| 84 | m1.micro  | 128       | 0   | 0         |      | 1    | 1.0         | True      |

+-----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

[email protected]:/home/stack$ nova image-list

+--------------------------------------+---------------------------------+--------+--------+

| ID                                   | Name                            | Status | Server |

+--------------------------------------+---------------------------------+--------+--------+

| 845cae84-3031-47e0-9a76-0d2e1a9acc2d| Fedora-x86_64-20-20140618-sda   |ACTIVE |        |

| fb584b71-ee87-443c-adba-f5b61c10c039 |cirros-0.3.2-x86_64-uec         | ACTIVE|        |

| e54a9f62-f27d-4793-bcef-25cd80d06e62 |cirros-0.3.2-x86_64-uec-kernel  | ACTIVE|        |

| 0fb0e025-2df5-41d1-947f-60ba179d49d5 |cirros-0.3.2-x86_64-uec-ramdisk | ACTIVE |        |

+--------------------------------------+---------------------------------+--------+--------+

使用nova boot命令创建虚拟机

[email protected]:/home/stack$ nova boot --flavor 2 --key_nameoskey --image 845cae84-3031-47e0-9a76-0d2e1a9acc2d fedora

+--------------------------------------+----------------------------------------------------------------------+

| Property                             | Value                                                               |

+--------------------------------------+----------------------------------------------------------------------+

| OS-DCF:diskConfig                    | MANUAL                                                              |

| OS-EXT-AZ:availability_zone          | nova                                                                |

| OS-EXT-SRV-ATTR:host                 | -                                                                   |

| OS-EXT-SRV-ATTR:hypervisor_hostname  | -                                                                   |

| OS-EXT-SRV-ATTR:instance_name        | instance-00000002                                                    |

| OS-EXT-STS:power_state               | 0                                                                   |

| OS-EXT-STS:task_state                | scheduling                                                           |

| OS-EXT-STS:vm_state                  | building                                                            |

| OS-SRV-USG:launched_at               | -                                                                   |

| OS-SRV-USG:terminated_at             | -                                                                   |

| accessIPv4                           |                                                                     |

| accessIPv6                           |                                                                     |

| adminPass                            | Wbn9w6bTnEoG                                                        |

| config_drive                         |                                                                      |

| created                              |2014-11-27T02:11:02Z                                                |

| flavor                               | m1.small(2)                                                        |

| hostId                               |                                                                     |

| id                                   |9068bbb6-d640-4345-9a67-fad233f01961                                 |

| image                                |Fedora-x86_64-20-20140618-sda (845cae84-3031-47e0-9a76-0d2e1a9acc2d) |

| key_name                             | oskey                                                               |

| metadata                             | {}                                                                   |

| name                                 | fedora                                                              |

| os-extended-volumes:volumes_attached |[]                                                                   |

| progress                             | 0                                                                   |

| security_groups                      | default                                                             |

| status                               | BUILD                                                               |

| tenant_id                            |a32c49a8d4c04936bc436da5ff16379b                                     |

| updated                              | 2014-11-27T02:11:02Z                                                |

| user_id                              |7b313c95e7b044e2b3dc6f0b31672c2f                                     |

+--------------------------------------+----------------------------------------------------------------------+

虚拟机创建完毕,打印虚拟机列表

[email protected]:/home/stack$ nova list

+--------------------------------------+--------+--------+------------+-------------+--------------------+

| ID                                   | Name   | Status | Task State | Power State |Networks           |

+--------------------------------------+--------+--------+------------+-------------+--------------------+

| fda792f6-92b7-4c7f-adb9-a7e200ef0c7e |cirros | ACTIVE | -          |Running     | private=10.10.10.2 |

| 9068bbb6-d640-4345-9a67-fad233f01961 |fedora | ACTIVE | -          |Running     | private=10.10.10.3 |

+--------------------------------------+--------+--------+------------+-------------+--------------------+

添加防火墙规则

[email protected]:/home/stack$ nova secgroup-add-rule defaulttcp 22 22 0.0.0.0/0

+-------------+-----------+---------+-----------+--------------+

| IP Protocol | From Port | To Port | IPRange  | Source Group |

+-------------+-----------+---------+-----------+--------------+

| tcp         | 22        | 22      | 0.0.0.0/0 |              |

+-------------+-----------+---------+-----------+--------------+

[email protected]:/home/stack$ nova secgroup-add-rule defaulticmp -1 -1 0.0.0.0/0

+-------------+-----------+---------+-----------+--------------+

| IP Protocol | From Port | To Port | IPRange  | Source Group |

+-------------+-----------+---------+-----------+--------------+

| icmp        | -1        | -1      | 0.0.0.0/0 |              |

+-------------+-----------+---------+-----------+--------------+

时间: 2024-11-05 03:09:10

使用nova boot命令创建openstack实例的相关文章

Openstack Nova(六)----Instance 创建(CLI RESTful请求)

在上一章中, 通过跟踪nova boot命令, 已经完成了Instance创建参数的解析及身份认证的过程.这一章中继续完成CLI部分的代码跟踪,看看RESTful的请求是如何发出去的. 如果阅读过上一章的内容,就可知道nova boot所对应的最终的执行函数是do_boot.这段代码不长,内容也很简单,具体看注释. do_boot def do_boot(cs, args): """Boot a new server.""" #从args中把参数

在Openstack控制节点上使用nova命令创建虚拟机(详细图文过程)

首先,我们需要了解到使用nova命令行创建一个虚拟机,需要如下的信息:glanceID.flavorID.net-id.security-groupsID.availability-zone(指定的母机}.keypairname1.查看glance使用命令:glance image-list 列出节点上所有的image,选择需要的镜像, 我们这里选择:93449941-fba1-436e-a4f2-74a5c1250ad1 2.查看flavor使用命令:nova flavor-list 来列出节

OpenStack之九: 创建一个实例

官网地址 https://docs.openstack.org/install-guide/launch-instance-networks-provider.html #:导入变量 [[email protected] ~]# source scripts/admin-stein.sh #:创建一个网络 [[email protected] ~]# openstack network create --share --internal --provider-physical-network e

创建 OpenStack云主机 [六]

创建 OpenStack云主机 [六] openstack 时间:2016年11月28日 创建虚拟网络 创建m1.nano规格的主机(相等于定义虚拟机的硬件配置)生成一个密钥对(openstack的原理是不使用密码连接,而是使用密钥对进行连接) 增加安全组规则(用iptables做的安全组) 启动一个实例(使用命令启动,启动虚拟机有三种方式:1.命令CLI 2.api 3.Dashboard)其实Dashboard也是通过api进行连接块设备存储编排共享文件系统 虚拟网络分为提供者网络和私有网络

nova boot from volume代码分析

OpenStack Liberty版本,这里简单记录下nova boot from volume的代码调用过程. nova boot from volume命令行 nova client novaclient/v2/shell.py   # novaclient端发起请求 def do_boot(cs, args):     """Boot a new server."""     boot_args, boot_kwargs = _boot(c

nova boot代码流程分析(三):nova与neutron的交互(2)

继续<nova boot代码流程分析(三):nova与neutron的交互(1)>的分析. #/nova/virt/libvirt/driver.py:LibvirtDriver # NOTE(ilyaalekseyev): Implementation like in multinics # for xenapi(tr3buchet) def spawn(self, context, instance, image_meta, injected_files, admin_password,

nova boot代码流程分析(一):Claim机制

nova boot创建VM的流程大致为: 1. novaclient发送HTTP请求到nova-api(这里内部细节包括keystone对用户的验证及用户从keystone获取token和endpoints等信息,具体参考<keystone WSGI流程>). 2. nova-api通过rpc调用到nova-conductor. 3. nova-conductor调用rpc进入nova-scheduler进行compute节点的选择,nova-scheduler将compute节点选择的信息的

nova boot代码流程分析(五):VM启动从neutron-dhcp-agent获取IP与MAC

1.   network和subnet创建代码流程 [[email protected] ~(keystone_user1)]# neutron net-create demo-net [[email protected] ~(keystone_user1)]# neutron subnet-create  demo-net 1.1.1.0/24 --name demo-subnet --gateway 1.1.1.1 --enable_dhcp true 这里,我们主要分析上面两个命令的代码流

CentOS7_86_64创建Oracle实例且设置开机自启以及允许远程连接

一.前言 先说明下,这里系统是CentOS7_86_64,Oracle版本是Oracle10g R2,假设系统和数据库都已安装完毕.前面有一篇文章详细说明了CentOS7下安装Oracle10g的流程,需要的同学可以去看一下.传送门:CentOS7_86_64安装Oracle10g R2血泪史. 二.检查/设置系统防火墙 说明:这里主要是为了设置oracle允许远程连接,如果没有这个需求,可以先不用管. 1.客户端检测网络通过性 此步骤不执行也可以,如果没条件检测的话.这里只是说明下网络是否正常