所謂實例就是OpenStack在compute節點上建立的虛擬機。安全
在啓動實例前,必須用ssh-keygen
先生成一個公鑰/私鑰對,並把公鑰添加到OpenStack環境中。網絡
demo
租戶的證書:$ source demo-openrc.sh
ssh
$ ssh-keygen
過程當中會要求輸入存放密鑰的文件名,本文采用默認的/root/.ssh/id_rsa
文件名。隨後將在/root/.ssh/
產生密鑰文件對:
<pre>Your identification has been saved in /root/.ssh/id_rsa.
</pre>ide
Your public key has been saved in /root/.ssh/id_rsa.pub.
$ nova keypair-add --pub-key ~/.ssh/id_rsa.pub demo-key
ui
$ 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
$ 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.tiny
。ip
$ nova image-list
ID | Name | Status | Server |
---|---|---|---|
6db9f9c9-4011-4cf5-a12b-dc70423ec0c3 | cirros-0.3.3-x86_64 | ACTIVE |
+--------------------------------------+---------------------+--------+--------+</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
$ nova secgroup-list
Id | Name | Description |
---|---|---|
86d1711a-3237-4c1a-ac2c-4d6ef99287c9 | default | default |
+--------------------------------------+---------+-------------+</pre>
默認這個安全組會啓動防火牆阻止遠程訪問實例。若是須要遠程訪問,需設定遠程訪問的選項。
$ 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替代。<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>
$ nova list