# source demo-openrc.sh
# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
53:fd:b1:1e:28:c5:2e:d7:e8:ef:54:a8:0e:70:38:4a [email protected]
The key‘s randomart image is:
+--[ RSA 2048]----+
| |
| o |
| . + . |
| o o = + |
| E S + = * .|
| . . = = o o |
| . . o o |
| o o |
| ..o |
+-----------------+
# nova keypair-add --pub-key ~/.ssh/id_rsa.pub demo-key
# nova keypair-list
+----------+-------------------------------------------------+
| Name | Fingerprint |
+----------+-------------------------------------------------+
| demo-key | 53:fd:b1:1e:28:c5:2e:d7:e8:ef:54:a8:0e:70:38:4a |
+----------+-------------------------------------------------+
# 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 |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
# nova image-list
+--------------------------------------+--------------------------+--------+--------+
| ID | Name | Status | Server |
+--------------------------------------+--------------------------+--------+--------+
| 89e7fa04-dc3c-426f-9752-75f4c603bcc2 | cirros-0.3.0-x86_64-disk | ACTIVE | |
+--------------------------------------+--------------------------+--------+--------+
# neutron net-list
+--------------------------------------+----------+-----------------------------------------------------+
| id | name | subnets |
+--------------------------------------+----------+-----------------------------------------------------+
| 6484c200-a3ff-437c-8749-cf83147cb0d3 | demo-net | 2b4bf426-5e0b-44da-8772-1a306f127793 192.168.1.0/24 |
+--------------------------------------+----------+-----------------------------------------------------+
# nova secgroup-list
+--------------------------------------+---------+-------------+
| Id | Name | Description |
+--------------------------------------+---------+-------------+
| 65e1f270-1073-4254-945e-86d1db4f0a30 | default | default |
+--------------------------------------+---------+-------------+
# nova boot --flavor m1.tiny --image cirros-0.3.0-x86_64-disk --nic net-id=6484c200-a3ff-437c-8749-cf83147cb0d3 \
--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 | 4rXi2w2radYo |
| config_drive | |
| created | 2015-12-17T17:31:32Z |
| flavor | m1.tiny (1) |
| hostId | |
| id | ddec8d7b-e829-4760-a1bf-bf1dd2995dd2 |
| image | cirros-0.3.0-x86_64-disk (89e7fa04-dc3c-426f-9752-75f4c603bcc2) |
| key_name | demo-key |
| metadata | {} |
| name | demo-instance1 |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default |
| status | BUILD |
| tenant_id | 33c0fa01b2724184bc8def11443a3caa |
| updated | 2015-12-17T17:31:32Z |
| user_id | cbdb8af1c8e9444dbd9974ad3aca66fe |
+--------------------------------------+-----------------------------------------------------------------+
# nova list
+--------------------------------------+----------------+--------+------------+-------------+----------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+----------------+--------+------------+-------------+----------------------+
| ddec8d7b-e829-4760-a1bf-bf1dd2995dd2 | demo-instance1 | ERROR | - | NOSTATE | demo-net=192.168.1.2 |
+--------------------------------------+----------------+--------+------------+-------------+----------------------+
# nova show ddec8d7b-e829-4760-a1bf-bf1dd2995dd2
+--------------------------------------+------------------------------------------------------------------------------------------+
| Property | Value |
+--------------------------------------+------------------------------------------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | - |
| OS-EXT-STS:vm_state | error |
| OS-SRV-USG:launched_at | - |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2015-12-17T17:31:32Z |
| demo-net network | 192.168.1.2 |
| fault | {"message": "No valid host was found. ", "code": 500, "created": "2015-12-17T17:31:35Z"} |
| flavor | m1.tiny (1) |
| hostId | 7788431710acba448fac373e02d6a8ce8c71d41f1355210071b2699e |
| id | ddec8d7b-e829-4760-a1bf-bf1dd2995dd2 |
| image | cirros-0.3.0-x86_64-disk (89e7fa04-dc3c-426f-9752-75f4c603bcc2) |
| key_name | demo-key |
| metadata | {} |
| name | demo-instance1 |
| os-extended-volumes:volumes_attached | [] |
| security_groups | default |
| status | ERROR |
| tenant_id | 33c0fa01b2724184bc8def11443a3caa |
| updated | 2015-12-17T17:31:34Z |
| user_id | cbdb8af1c8e9444dbd9974ad3aca66fe |
+--------------------------------------+------------------------------------------------------------------------------------------+
发现报错“No valid host was found”没有可用的主机。
查看comput1的服务状态:
# systemctl status libvirtd.service openstack-nova-compute.service
libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled)
Active: active (running) since Wed 2015-12-16 23:18:19 CST; 1 day 2h ago
Docs: man:libvirtd(8)
http://libvirt.org
Main PID: 2710 (libvirtd)
CGroup: /system.slice/libvirtd.service
└─2710 /usr/sbin/libvirtd
Dec 16 23:20:05 compute1 libvirtd[2710]: End of file while reading data: Input/output error
Dec 16 23:20:06 compute1 libvirtd[2710]: End of file while reading data: Input/output error
Dec 16 23:20:08 compute1 libvirtd[2710]: End of file while reading data: Input/output error
Dec 16 23:21:59 compute1 libvirtd[2710]: End of file while reading data: Input/output error
Dec 16 23:22:01 compute1 libvirtd[2710]: End of file while reading data: Input/output error
Dec 16 23:22:02 compute1 libvirtd[2710]: End of file while reading data: Input/output error
Dec 16 23:22:04 compute1 libvirtd[2710]: End of file while reading data: Input/output error
Dec 16 23:22:05 compute1 libvirtd[2710]: End of file while reading data: Input/output error
Dec 17 22:22:58 compute1 libvirtd[2710]: End of file while reading data: Input/output error
Dec 18 01:43:27 compute1 systemd[1]: Started Virtualization daemon.
# nova delete ddec8d7b-e829-4760-a1bf-bf1dd2995dd2
# nova get-vnc-console demo-instance1 novnc
# ping -c 4 192.168.1.1