OpenStack安裝流程(juno版)- 啓動一個實例

所謂實例就是OpenStack在compute節點上建立的虛擬機。安全

使用OpenStack網絡(neutron)啓動一個實例

生成密鑰對

在啓動實例前,必須用ssh-keygen先生成一個公鑰/私鑰對,並把公鑰添加到OpenStack環境中。網絡

  1. 啓動demo租戶的證書:

$ source demo-openrc.shssh

  1. 生成密鑰對:

$ ssh-keygen
過程當中會要求輸入存放密鑰的文件名,本文采用默認的/root/.ssh/id_rsa文件名。隨後將在/root/.ssh/產生密鑰文件對:
<pre>Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
</pre>ide

  1. 把公鑰添加到OpenStack環境中:

$ nova keypair-add --pub-key ~/.ssh/id_rsa.pub demo-keyui

  1. 驗證是否添加成功:
    <pre>$ nova keypair-list
Name Fingerprint
demo-key 49:f9:6f:e7:f2:1c:ae:27:56:f6:cf:65:ca:f3:a2:13

+----------+-------------------------------------------------+</pre>3d

啓動實例

要啓動實例,至少要先指定方案(flavor),鏡像名字,網絡,安全組(security group),密鑰和實例名字。code

  1. 方案是用來指定虛擬資源分配的,包括處理器,內存和存儲。
    列出可用方案:
    <pre>$ 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
5 m1.xlarge 16384 160 0 8 1.0 True

+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+</pre>
本文實例使用的方案爲m1.tinyip

  1. 列出可用鏡像:
    <pre>$ nova image-list
ID Name Status Server
6db9f9c9-4011-4cf5-a12b-dc70423ec0c3 cirros-0.3.3-x86_64 ACTIVE

+--------------------------------------+---------------------+--------+--------+</pre>內存

  1. 列出可用的網絡:
    <pre>$ neutron net-list
id name subnets
e6f3606d-2bf6-4b01-8fb4-c10d299dbe75 ext-net 963754fb-73c4-4a1b-93ee-27d2c2beb97a
830379a4-cc69-4165-a18f-f9430d999d5f demo-net a6593d6d-1992-4207-ae61-7784f0aa5a3c 192.162.1.0/24

+--------------------------------------+----------+-----------------------------------------------------+</pre>
本文實例使用demo-net租戶網絡。需注意的是,在設定時必須使用網絡ID而不是名字。ci

  1. 列出可用安全組:
    <pre>$ nova secgroup-list
Id Name Description
86d1711a-3237-4c1a-ac2c-4d6ef99287c9 default default

+--------------------------------------+---------+-------------+</pre>
默認這個安全組會啓動防火牆阻止遠程訪問實例。若是須要遠程訪問,需設定遠程訪問的選項。

  1. 啓動實例
    $ nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=DEMO_NET_ID --security-group default --key-name demo-key demo-instance1
    其中DEMO_NET_ID用上述demo-net的ID替代。

    <pre>$ nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=830379a4-cc69-4165-a18f-f9430d999d5f \

--security-group default --key-name demo-key demo-instance1
Property Value
OS-DCF:diskConfig MANUAL
OS-EXT-AZ:availability_zone nova
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 PFuniZWVFTg9
config_drive
created 2015-12-02T07:19:18Z
flavor m1.tiny (1)
hostId
id a5f857ec-09d0-4148-a671-daf4a7afaea3
image cirros-0.3.3-x86_64 (6db9f9c9-4011-4cf5-a12b-dc70423ec0c3)
key_name demo-key
metadata {}
name demo-instance1
os-extended-volumes:volumes_attached []
progress 0
security_groups default
status BUILD
tenant_id d1f7caccc65840b68258997a759da07f
updated 2015-12-02T07:19:18Z
user_id 812116bcca5b4a01981669fcef09ee11

+--------------------------------------+------------------------------------------------------------+</pre>

  1. 查看實例的狀態:
    <pre>$ nova list
相關文章
相關標籤/搜索