1 先创建 port,设置好 IP 地址。
2 将该 port attach 到 instance。
3 在 instance 中手工配置静态 IP,如果设置dhcp。默认重启reboot就好。
4
5
6
7 [root@s16071-z2-controller01 ~]# source admin-openrc
8
9
10
11
12 [root@s16071-z2-controller01 ~]# nova list
13 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+
14 | ID | Name | Status | Task State | Power State | Networks |
15 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+
16 | 47289968-7943-487f-a910-59e1d1576a7f |mysql-01 | ACTIVE | - | Running | |
17 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+
找到对应的Name ,此次用的是mysql-01
18
19 [root@s16071-z2-controller01 ~]# neutron subnet-list
20 neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
21 +--------------------------------------+----------------+----------------------------------+--------------+-----------------------------------------------+
22 | id | name | tenant_id | cidr | allocation_pools |
23 +--------------------------------------+----------------+----------------------------------+--------------+-----------------------------------------------+
24 | 07518a92-ccd2-416b-a9be-1d85f386eab7 | vlan406-subnet | 2cc9c8a5b161407f9e7545998ef9dee8 | 10.96.6.0/24 | {"start": "10.96.6.10", "end": "10.96.6.200"} |
25 +--------------------------------------+----------------+----------------------------------+--------------+-----------------------------------------------+
找到对应的ID 07518a92-ccd2-416b-a9be-1d85f386eab7
26
27
28
29
30 绑定subnet_id,指定IP,和vlan
31 [root@s16071-z2-controller01 ~]# neutron port-create --fixed-ip subnet_id=07518a92-ccd2-416b-a9be-1d85f386eab7,ip_address=10.96.6.27 vlan406
32 查看port ID 72798877-8d7d-46fb-8560-df272cccddd67
33 [root@s16071-z2-controller01 ~]# neutron port-list
34 neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
35 +--------------------------------------+------+----------------------------------+-------------------+------------------------------------------------------------------------------------+
36 | id | name | tenant_id | mac_address | fixed_ips |
37 +--------------------------------------+------+----------------------------------+-------------------+------------------------------------------------------------------------------------+
38 | 72798877-8d7d-46fb-8560-df272cccdd67 | | 2cc9c8a5b161407f9e7545998ef9dee8 | fa:16:3e:48:b2:75 | {"subnet_id": "07518a92-ccd2-416b-a9be-1d85f386eab7", "ip_address": "10.96.6.27"} |
39 +--------------------------------------+------+----------------------------------+-------------------+------------------------------------------------------------------------------------+
40
绑定port-id到实例Name
41 [root@s16071-z2-controller01 ~]# nova interface-attach --port-id 72798877-8d7d-46fb-8560-df272cccdd67 mysql-01
42 [root@s16071-z2-controller01 ~]# nova list
43 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+
44 | ID | Name | Status | Task State | Power State | Networks |
45 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+
46 | 47289968-7943-487f-a910-59e1d1576a7f | mysql-01 | ACTIVE | - | Running | vlan406=10.96.6.27 |
47 +--------------------------------------+------------------------------+--------+------------+-------------+---------------------+
绑定成功后,重启实例mysql-01,配置完成