Steward_Xu

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
    1、neutron更改及mysql数据库更改网卡及ip:
    neutron port-update ae22c84b-22a9-4618-b046-1eb61379bcea  --allowed-address-pairs type=dict list=true ip_address=172.20.59.132  #更改openstack 网络端口ip地址更改后可在dashborad见面看见端口已经更改,但是网络仍然不通,是由于数据库中还是原有ip故而更改数据库;
    更改mysql数据库:
    use neutron 

    mysql> select * from ipallocations where port_id='ae22c84b-22a9-4618-b046-1eb61379bcea';
    +--------------------------------------+---------------+--------------------------------------+--------------------------------------+
    | port_id                              | ip_address    | subnet_id                            | network_id                           |
    +--------------------------------------+---------------+--------------------------------------+--------------------------------------+
    | ae22c84b-22a9-4618-b046-1eb61379bcea | 172.20.59.132 | 3b040206-4adc-487e-9b9b-177b93374fdb | af6ef793-5430-4fa9-a2ea-6751d721e00b |
    +--------------------------------------+---------------+--------------------------------------+--------------------------------------+
    1 row in set (0.00 sec)

    mysql>  update ipallocations set ip_address='172.20.59.132' where port_id='ae22c84b-22a9-4618-b046-1eb61379bcea';

   2、通过命令行更改;通过命令行更改必须关闭虚拟机
    详细步骤:
    bomc_cloud1:/root# neutron port-list

+--------------------------------------+--------+-------------------+--------------------------------------------------------------------------------------+
| id                                   | name   | mac_address       | fixed_ips                                                                            |
+--------------------------------------+--------+-------------------+--------------------------------------------------------------------------------------+
| 1cecaa46-8122-46e7-bd16-698e2fa43efe |        | fa:16:3e:c3:fd:69 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.131"} |
| 29b851cd-cdee-407d-a75a-d0bc7e3346d1 |        | fa:16:3e:dc:e8:af | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.134"} |
| 61e30821-972a-4a83-a3ab-e53802d457ef |        | fa:16:3e:53:ba:fc | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.133"} |
| 87462fba-ffce-4544-9bec-413c382baeda |        | fa:16:3e:5b:0b:9a | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.135"} |
| a7aaaac1-0473-4c72-822f-2370d7d164b4 | port-1 | fa:16:3e:14:c4:49 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.130"} |
| ae22c84b-22a9-4618-b046-1eb61379bcea |        | fa:16:3e:17:91:f1 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.132"} |
| f5ee728e-8017-454a-b347-0b299ad9494e |        | fa:16:3e:a3:6d:8e | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.136"} |
+--------------------------------------+--------+-------------------+--------------------------------------------------------------------------------------+
bomc_cloud1:/root# nova list 
+--------------------------------------+-------------+---------+------------+-------------+------------------------+
| ID                                   | Name        | Status  | Task State | Power State | Networks               |
+--------------------------------------+-------------+---------+------------+-------------+------------------------+
| e13f0be6-aaa6-439d-be1d-08c964f2a4ee | bomc_vm08   | ACTIVE  | -          | Running     | provider=172.20.59.134 |
| f902a752-6246-4722-94c6-4275f0f9f7ed | bomc_vm_003 | ACTIVE  | -          | Running     | provider=172.20.59.130 |
| 28374779-a46d-4705-b47c-d80daaa1a5a4 | bomc_vm_004 | SHUTOFF | -          | Shutdown    | provider=172.20.59.136 |
| 9b42be9d-7572-4a2b-8d6d-80d30fbca0d6 | bomc_vm_005 | ACTIVE  | -          | Running     | provider=172.20.59.135 |
| eb784193-1dfa-4b44-9dda-f8352fc7a573 | bomc_vm_006 | ACTIVE  | -          | Running     | provider=172.20.59.131 |
| 4fee78ae-1d96-4168-9795-6630d46dcbf6 | bomc_vm_007 | ACTIVE  | -          | Running     | provider=172.20.59.132 |
| 32dd588e-215a-4a9e-9f70-635f023bcfdb | bomc_vm_07  | ACTIVE  | -          | Running     | provider=172.20.59.133 |
+--------------------------------------+-------------+---------+------------+-------------+------------------------+

2.2删除网卡
bomc_cloud1:/root# nova interface-detach 28374779-a46d-4705-b47c-d80daaa1a5a4 f5ee728e-8017-454a-b347-0b299ad9494e
bomc_cloud1:/root# nova list 
+--------------------------------------+-------------+---------+------------+-------------+------------------------+
| ID                                   | Name        | Status  | Task State | Power State | Networks               |
+--------------------------------------+-------------+---------+------------+-------------+------------------------+
| e13f0be6-aaa6-439d-be1d-08c964f2a4ee | bomc_vm08   | ACTIVE  | -          | Running     | provider=172.20.59.134 |
| f902a752-6246-4722-94c6-4275f0f9f7ed | bomc_vm_003 | ACTIVE  | -          | Running     | provider=172.20.59.130 |
| 28374779-a46d-4705-b47c-d80daaa1a5a4 | bomc_vm_004 | SHUTOFF | -          | Shutdown    |                        |
| 9b42be9d-7572-4a2b-8d6d-80d30fbca0d6 | bomc_vm_005 | ACTIVE  | -          | Running     | provider=172.20.59.135 |
| eb784193-1dfa-4b44-9dda-f8352fc7a573 | bomc_vm_006 | ACTIVE  | -          | Running     | provider=172.20.59.131 |
| 4fee78ae-1d96-4168-9795-6630d46dcbf6 | bomc_vm_007 | ACTIVE  | -          | Running     | provider=172.20.59.132 |
| 32dd588e-215a-4a9e-9f70-635f023bcfdb | bomc_vm_07  | ACTIVE  | -          | Running     | provider=172.20.59.133 |
+--------------------------------------+-------------+---------+------------+-------------+------------------------+
bomc_cloud1:/root# neutron port-list
+--------------------------------------+--------+-------------------+--------------------------------------------------------------------------------------+
| id                                   | name   | mac_address       | fixed_ips                                                                            |
+--------------------------------------+--------+-------------------+--------------------------------------------------------------------------------------+
| 1cecaa46-8122-46e7-bd16-698e2fa43efe |        | fa:16:3e:c3:fd:69 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.131"} |
| 29b851cd-cdee-407d-a75a-d0bc7e3346d1 |        | fa:16:3e:dc:e8:af | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.134"} |
| 61e30821-972a-4a83-a3ab-e53802d457ef |        | fa:16:3e:53:ba:fc | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.133"} |
| 87462fba-ffce-4544-9bec-413c382baeda |        | fa:16:3e:5b:0b:9a | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.135"} |
| a7aaaac1-0473-4c72-822f-2370d7d164b4 | port-1 | fa:16:3e:14:c4:49 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.130"} |
| ae22c84b-22a9-4618-b046-1eb61379bcea |        | fa:16:3e:17:91:f1 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.132"} |
+--------------------------------------+--------+-------------------+--------------------------------------------------------------------------------------+

2.3创建添加网卡
bomc_cloud1:/root# neutron port-create --name port-1  --fixed-ip subnet_id=3b040206-4adc-487e-9b9b-177b93374fdb,ip_address=172.20.59.136  --security-group c719f256-f3b8-4cfd-a8f2-1d9844de1161 af6ef793-5430-4fa9-a2ea-6751d721e00b
Created a new port:
+-----------------------+--------------------------------------------------------------------------------------+
| Field                 | Value                                                                                |
+-----------------------+--------------------------------------------------------------------------------------+
| admin_state_up        | True                                                                                 |
| allowed_address_pairs |                                                                                      |
| binding:host_id       |                                                                                      |
| binding:profile       | {}                                                                                   |
| binding:vif_details   | {}                                                                                   |
| binding:vif_type      | unbound                                                                              |
| binding:vnic_type     | normal                                                                               |
| created_at            | 2018-06-05T06:50:16                                                                  |
| description           |                                                                                      |
| device_id             |                                                                                      |
| device_owner          |                                                                                      |
| extra_dhcp_opts       |                                                                                      |
| fixed_ips             | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.136"} |
| id                    | 6bd80a8e-bb26-4121-8d97-4d6c365a4a8d                                                 |
| mac_address           | fa:16:3e:67:e4:b4                                                                    |
| name                  | port-1                                                                               |
| network_id            | af6ef793-5430-4fa9-a2ea-6751d721e00b                                                 |
| port_security_enabled | True                                                                                 |
| security_groups       | c719f256-f3b8-4cfd-a8f2-1d9844de1161                                                 |
| status                | DOWN                                                                                 |
| tenant_id             | 3d89dd945e764bf19a3560bced6a4fbc                                                     |
| updated_at            | 2018-06-05T06:50:16                                                                  |
+-----------------------+--------------------------------------------------------------------------------------+
bomc_cloud1:/root# nova interface-attach --port-id ^Cf902a752-6246-4722-94c6-4275f0f9f7ed 
bomc_cloud1:/root# neutron port-list
+--------------------------------------+--------+-------------------+--------------------------------------------------------------------------------------+
| id                                   | name   | mac_address       | fixed_ips                                                                            |
+--------------------------------------+--------+-------------------+--------------------------------------------------------------------------------------+
| 1cecaa46-8122-46e7-bd16-698e2fa43efe |        | fa:16:3e:c3:fd:69 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.131"} |
| 29b851cd-cdee-407d-a75a-d0bc7e3346d1 |        | fa:16:3e:dc:e8:af | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.134"} |
| 61e30821-972a-4a83-a3ab-e53802d457ef |        | fa:16:3e:53:ba:fc | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.133"} |
| 6bd80a8e-bb26-4121-8d97-4d6c365a4a8d | port-1 | fa:16:3e:67:e4:b4 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.136"} |
| 757a743a-265f-43a4-82fd-23a84e30a637 |        | fa:16:3e:a4:7f:02 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.148"} |
| 87462fba-ffce-4544-9bec-413c382baeda |        | fa:16:3e:5b:0b:9a | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.135"} |
| a7aaaac1-0473-4c72-822f-2370d7d164b4 | port-1 | fa:16:3e:14:c4:49 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.130"} |
| ae22c84b-22a9-4618-b046-1eb61379bcea |        | fa:16:3e:17:91:f1 | {"subnet_id": "3b040206-4adc-487e-9b9b-177b93374fdb", "ip_address": "172.20.59.132"} |
+--------------------------------------+--------+-------------------+--------------------------------------------------------------------------------------+

2.4网卡与虚拟主机绑定
bomc_cloud1:/root# nova interface-attach --port-id 6bd80a8e-bb26-4121-8d97-4d6c365a4a8d 28374779-a46d-4705-b47c-d80daaa1a5a4
bomc_cloud1:/root# nova list
+--------------------------------------+-------------+---------+------------+-------------+------------------------+
| ID                                   | Name        | Status  | Task State | Power State | Networks               |
+--------------------------------------+-------------+---------+------------+-------------+------------------------+
| e13f0be6-aaa6-439d-be1d-08c964f2a4ee | bomc_vm08   | ACTIVE  | -          | Running     | provider=172.20.59.134 |
| f902a752-6246-4722-94c6-4275f0f9f7ed | bomc_vm_003 | ACTIVE  | -          | Running     | provider=172.20.59.130 |
| 28374779-a46d-4705-b47c-d80daaa1a5a4 | bomc_vm_004 | SHUTOFF | -          | Shutdown    | provider=172.20.59.136 |
| 9b42be9d-7572-4a2b-8d6d-80d30fbca0d6 | bomc_vm_005 | ACTIVE  | -          | Running     | provider=172.20.59.135 |
| eb784193-1dfa-4b44-9dda-f8352fc7a573 | bomc_vm_006 | ACTIVE  | -          | Running     | provider=172.20.59.131 |
| 4fee78ae-1d96-4168-9795-6630d46dcbf6 | bomc_vm_007 | ACTIVE  | -          | Running     | provider=172.20.59.132 |
| 32dd588e-215a-4a9e-9f70-635f023bcfdb | bomc_vm_07  | ACTIVE  | -          | Running     | provider=172.20.59.133 |
+--------------------------------------+-------------+---------+------------+-------------+------------------------+

备注:nova interface-attach 和nova interface-delach 添加删除网卡操作可用于为虚拟机添加多网卡!

 

posted on 2018-06-08 10:03  Steward_Xu  阅读(1114)  评论(0编辑  收藏  举报