当前使用 vlan 网络架构
默认状态下创建 VM 利用 DHCP 进行 IP 地址分配
由于某些原因需要指定某些 VM 的 IP 地址, 那么可以参考下面方法执行操作
先获得 TENANT, NETWORK 信息, 然后创建对应的 PORT, PORT 可以指定使用某个 IP 地址, 之后在创建 VM 时候指定对应的 PORT就可以
获得 tenant id
[root@sh-zabbix-129023 ~(keystone_DEV)]# keystone tenant-list | grep DEV | 00f77483830d48e5aafba5880f5c437d | DEV | True |
获得 network 信息
[root@sh-zabbix-129023 ~(keystone_DEV)]# neutron net-list | grep DEV | 9106aee4-2dc0-4a6d-a789-10c53e2b88c1 | SH_DEV_NET | a42781d8-07fd-4744-8409-0b1b40750a71 10.198.192.0/18 |
创建新的 port
[root@sh-zabbix-129023 ~(keystone_DEV)]# neutron port-create --tenant-id 00f77483830d48e5aafba5880f5c437d --fixed-ip subnet_id=a42781d8-07fd-4744-8409-0b1b40750a71,ip_address=10.198.193.94 9106aee4-2dc0-4a6d-a789-10c53e2b88c1 Created a new port: +---------------------+--------------------------------------------------------------------------------------+ | Field | Value | +---------------------+--------------------------------------------------------------------------------------+ | admin_state_up | True | | binding:host_id | | | binding:profile | {} | | binding:vif_details | {} | | binding:vif_type | unbound | | binding:vnic_type | normal | | device_id | | | device_owner | | | fixed_ips | {"subnet_id": "a42781d8-07fd-4744-8409-0b1b40750a71", "ip_address": "10.198.193.94"} | | id | c71cf80c-d26c-4337-bad1-e7ac419613b1 | | mac_address | fa:16:3e:f2:eb:ef | | name | | | network_id | 9106aee4-2dc0-4a6d-a789-10c53e2b88c1 | | status | DOWN | | tenant_id | 00f77483830d48e5aafba5880f5c437d | +---------------------+--------------------------------------------------------------------------------------+
创建vm 时指定对应的port 方法
[root@sh-zabbix-129023 ~(keystone_DEV)]# nova boot --flavor b2c_allinone --image Centos7_Generic_1503 --security_group default --nic port-id=c71cf80c-d26c-4337-bad1-e7ac419613b1 violalu-sh-qa-web-e5jhn.sh.vclound.com +--------------------------------------+-------------------------------------------------------------+ | 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-00001cb5 | | 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 | iTvPvkXhp84v | | config_drive | | | created | 2015-08-17T07:52:19Z | | flavor | b2c_allinone (3) | | hostId | | | id | 8cf12579-85ee-41f4-ab9f-55a608c5640b | | image | Centos7_Generic_1503 (8de228c7-3913-4fff-8e70-dd3ec05446a7) | | key_name | - | | metadata | {} | | name | violalu-sh-qa-web-e5jhn.sh.vclound.com | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | security_groups | default | | status | BUILD | | tenant_id | 00f77483830d48e5aafba5880f5c437d | | updated | 2015-08-17T07:52:19Z | | user_id | 62b3813eb92e415b85816722e9479636 | +--------------------------------------+-------------------------------------------------------------+
查询实例详细信息
[root@sh-zabbix-129023 ~(keystone_DEV)]# nova show 8cf12579-85ee-41f4-ab9f-55a608c5640b +--------------------------------------+-------------------------------------------------------------+ | Property | Value | +--------------------------------------+-------------------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | nova | | OS-EXT-SRV-ATTR:host | sh-compute-129070.sh.vclound.com | | OS-EXT-SRV-ATTR:hypervisor_hostname | sh-compute-129070.sh.vclound.com | | OS-EXT-SRV-ATTR:instance_name | instance-00001cb5 | | OS-EXT-STS:power_state | 0 | | OS-EXT-STS:task_state | spawning | | OS-EXT-STS:vm_state | building | | OS-SRV-USG:launched_at | - | | OS-SRV-USG:terminated_at | - | | SH_DEV_NET network | 10.198.193.94 | | accessIPv4 | | | accessIPv6 | | | config_drive | | | created | 2015-08-17T07:52:19Z | | flavor | b2c_allinone (3) | | hostId | 2f4f8c8676263bdf2c6a575d27d4156768c495f51f895cea35ba7792 | | id | 8cf12579-85ee-41f4-ab9f-55a608c5640b | | image | Centos7_Generic_1503 (8de228c7-3913-4fff-8e70-dd3ec05446a7) | | key_name | - | | metadata | {} | | name | violalu-sh-qa-web-e5jhn.sh.vclound.com | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | security_groups | default | | status | BUILD | | tenant_id | 00f77483830d48e5aafba5880f5c437d | | updated | 2015-08-17T07:52:16Z | | user_id | 62b3813eb92e415b85816722e9479636 | +--------------------------------------+-------------------------------------------------------------+
测试网络
[root@sh-zabbix-129023 ~(keystone_DEV)]# ping 10.198.193.94 PING 10.198.193.94 (10.198.193.94) 56(84) bytes of data. 64 bytes from 10.198.193.94: icmp_seq=1 ttl=61 time=0.841 ms --- 10.198.193.94 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.841/0.841/0.841/0.000 ms [root@sh-zabbix-129023 ~(keystone_DEV)]# ssh 10.198.193.94 The authenticity of host '10.198.193.94 (10.198.193.94)' can't be established. ECDSA key fingerprint is c5:8c:19:d9:85:31:63:7c:04:b3:dd:20:aa:66:81:7b. Are you sure you want to continue connecting (yes/no)?