分享

Quantum 网络创建使用指南(quantum Create Network Guide)

hochikong 发表于 2014-8-10 17:59:08 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 6852
问题导读:
1.网络节点的eth2应该怎样配置?
2.如何把内部网络和外部网络连接起来?
3.quantum和neutron的操作一样吗?


1. 创建网络
  1. quantum net-create network1
复制代码

2. 创建子网
  1. quantum subnet-create network1 192.168.12.0/24
  2. Created a new subnet:
  3. +------------------+----------------------------------------------------+
  4. | Field            | Value                                              |
  5. +------------------+----------------------------------------------------+
  6. | allocation_pools | {"start": "192.168.12.2", "end": "192.168.12.254"} |
  7. | cidr             | 192.168.12.0/24                                    |
  8. | dns_nameservers  |                                                    |
  9. | enable_dhcp      | True                                               |
  10. | gateway_ip       | 192.168.12.1                                       |
  11. | host_routes      |                                                    |
  12. | id               | 32fe8d37-5c35-453e-b7d4-a1c98ac7bf97               |
  13. | ip_version       | 4                                                  |
  14. | name             |                                                    |
  15. | network_id       | 54f37003-7f4e-47f4-a865-c928de1ae9e3               |
  16. | tenant_id        | 180deec2c933457cb149ef5cf38322f8                   |
  17. +------------------+----------------------------------------------------+
复制代码

3. 创建外部网络
3.1 创建外部网络目的:
作为floating ip 池

3.2 创建外部网络注意点:
创建外部网络子网的时候,注意network 节点上的br-ex网桥一定是要存在的
eth2接口的配置在ubuntu里可以参考如下的配置

  1. auto eth2
  2. iface eth2 inet manual
  3. up ifconfig $IFACE 0.0.0.0 up
  4. up ip link set $IFACE promisc on
  5. down ip link set $IFACE promisc off
  6. down ifconfig $IFACE down
复制代码
这个子网能工作的前提条件必须满足,不然即使分配了floating ip也是无法工作的。

  • *这个子网一定一个是物理上和你network节点连接的,这里是用的eth2接口*allocation-pool中的ip都是可用的*不需要dhcp*network节点上openvswitch网桥br-ex必须存在*br-ex上添加eth2接口,命令为ovs-vsctl add-port br-ex eth2
    下面是建好的ovs网桥
    1. bridge name bridge id  STP enabled interfaces
    2. br-ex  0000.180373d2869d no  eth2
    3. br-int  0000.823fbdfff741 no  qr-520f18b3-85
    4.       tap7415fb87-d7
    5.       tape9e5dc79-c8
    6.       tapfec2a3b4-4c
    7. br-tun  0000.5ef67744584e no
    8. virbr0  8000.000000000000 yes
    复制代码
    3.3 创建外部网络
    1. # quantum net-create ext_net --router:external=True
    2. Created a new network:
    3. +---------------------------+--------------------------------------+
    4. | Field                     | Value                                |
    5. +---------------------------+--------------------------------------+
    6. | admin_state_up            | True                                 |
    7. | id                        | 45217501-16c6-49a9-946d-6d44ef2b0256 |
    8. | name                      | ext_net                              |
    9. | provider:network_type     | gre                                  |
    10. | provider:physical_network |                                      |
    11. | provider:segmentation_id  | 2                                    |
    12. | router:external           | True                                 |
    13. | shared                    | False                                |
    14. | status                    | ACTIVE                               |
    15. | subnets                   |                                      |
    16. | tenant_id                 | 180deec2c933457cb149ef5cf38322f8     |
    17. +---------------------------+--------------------------------------+
    复制代码

    3.3. 创建外部网络子网这里我们创建一个10.1.3.0/24的子网,假设你的的eth2接口是接在10.1.3.0/24网段的, 分配地址从140到160,就是在参数中指定--allocation-pool start=10.1.3.10,end=10.1.3.70, 这里的dhcp是需要关闭的
    1. # quantum subnet-create --allocation-pool start=10.1.3.10,end=10.1.3.70 --gateway 10.1.3.1 ext_net 10.1.3.0/24 --enable_dhcp=False
    2. Created a new subnet:
    3. +------------------+--------------------------------------------+
    4. | Field            | Value                                      |
    5. +------------------+--------------------------------------------+
    6. | allocation_pools | {"start": "10.1.3.10", "end": "10.1.3.70"} |
    7. | cidr             | 10.1.3.0/24                                |
    8. | dns_nameservers  |                                            |
    9. | enable_dhcp      | False                                      |
    10. | gateway_ip       | 10.1.3.1                                   |
    11. | host_routes      |                                            |
    12. | id               | e51a2803-64cf-4d8d-9637-9ae38ad4d76c       |
    13. | ip_version       | 4                                          |
    14. | name             |                                            |
    15. | network_id       | 45217501-16c6-49a9-946d-6d44ef2b0256       |
    16. | tenant_id        | 180deec2c933457cb149ef5cf38322f8           |
    17. +------------------+--------------------------------------------+
    复制代码

    3.4 查看创建好的网络
    1. # quantum net-list
    2. +--------------------------------------+----------+------------------------------------------------------+
    3. | id                                   | name     | subnets                                              |
    4. +--------------------------------------+----------+------------------------------------------------------+
    5. | 45217501-16c6-49a9-946d-6d44ef2b0256 | ext_net  | e51a2803-64cf-4d8d-9637-9ae38ad4d76c 10.1.3.0/24     |
    6. | 54f37003-7f4e-47f4-a865-c928de1ae9e3 | network1 | 32fe8d37-5c35-453e-b7d4-a1c98ac7bf97 192.168.12.0/24 |
    7. +--------------------------------------+----------+------------------------------------------------------+
    复制代码

    4. 创建路由4.1 创建路由
    1. # quantum router-create default-router
    2. Created a new router:
    3. +-----------------------+--------------------------------------+
    4. | Field                 | Value                                |
    5. +-----------------------+--------------------------------------+
    6. | admin_state_up        | True                                 |
    7. | external_gateway_info |                                      |
    8. | id                    | 93a70ed7-ac17-41d3-9d92-4d8bfb0ee56a |
    9. | name                  | default-router                       |
    10. | status                | ACTIVE                               |
    11. | tenant_id             | 180deec2c933457cb149ef5cf38322f8     |
    12. +-----------------------+--------------------------------------+
    复制代码

    4.2 将路由添加到一个l3 agent上查看有哪些l3 agent
    1. # quantum agent-list
    2. +--------------------------------------+--------------------+----------+-------+----------------+
    3. | id                                   | agent_type         | host     | alive | admin_state_up |
    4. +--------------------------------------+--------------------+----------+-------+----------------+
    5. | 20fe37a3-9146-4744-9f4a-67db973b70e2 | Open vSwitch agent | network2 | :-)   | True           |
    6. | 40dabe35-dfc1-4723-9ab7-5b4dfb51108b | L3 agent           | network2 | :-)   | True           |
    7. | 6452b796-e7f6-4057-96df-4d320a0ceb84 | DHCP agent         | network1 | :-)   | True           |
    8. | 6dcd47a8-f56e-46db-aec1-5c2c18f0c321 | Open vSwitch agent | network1 | :-)   | True           |
    9. | 715ce6bc-7cb5-4e0b-9de9-3b6a8750cf59 | Open vSwitch agent | compute1 | :-)   | True           |
    10. | a39da87a-16ea-4924-8aff-d9e468e68f13 | DHCP agent         | network2 | :-)   | True           |
    11. | ccf26580-ba40-4148-9a73-c0cf67713a73 | L3 agent           | network1 | :-)   | True           |
    12. +--------------------------------------+--------------------+----------+-------+----------------+
    复制代码

    4.3 将路由添加到network1的l3 agent上命令如下:
    1. quantum l3-agent-router-add $l3_agent_ID router_id
    复制代码
    1. # quantum l3-agent-router-add  ccf26580-ba40-4148-9a73-c0cf67713a73 93a70ed7-ac17-41d3-9d92-4d8bfb0ee56a
    2. Added router 93a70ed7-ac17-41d3-9d92-4d8bfb0ee56a to L3 agent
    复制代码

    4.4 设置路由网关命令如下quantum router-gateway-set $router_id $ext_net_id:
    1. # quantum router-gateway-set 93a70ed7-ac17-41d3-9d92-4d8bfb0ee56a  45217501-16c6-49a9-946d-6d44ef2b0256
    2. Set gateway for router 93a70ed7-ac17-41d3-9d92-4d8bfb0ee56a
    复制代码
    查看路由:
    1. # quantum router-list
    2. +--------------------------------------+----------------+--------------------------------------------------------+
    3. | id                                   | name           | external_gateway_info                                  |
    4. +--------------------------------------+----------------+--------------------------------------------------------+
    5. | 93a70ed7-ac17-41d3-9d92-4d8bfb0ee56a | default-router | {"network_id": "45217501-16c6-49a9-946d-6d44ef2b0256"} |
    6. +--------------------------------------+----------------+--------------------------------------------------------+
    复制代码

    4.5 将路由添加到子网或者说将子网添加到路由,主要目的就是让某个子网的路由设置成我们的router,这个router 的网关已经被设置为外部网络,这样我们的子网就可以上网了 命令如下quantum router-interface-add $router_id $subnet_id:
    1. # quantum router-interface-add 93a70ed7-ac17-41d3-9d92-4d8bfb0ee56a  32fe8d37-5c35-453e-b7d4-a1c98ac7bf97
    2. Added interface to router 93a70ed7-ac17-41d3-9d92-4d8bfb0ee56a
    复制代码
    network节点上应该会出现一个qrouter的namespace,如果启用了namespace的话(默认启动)
    1. # ip netns
    2. qrouter-93a70ed7-ac17-41d3-9d92-4d8bfb0ee56a
    复制代码

    4.6 创建一个floating ip
    1. # quantum floatingip-create ext_net
    2. Created a new floatingip:
    3. +---------------------+--------------------------------------+
    4. | Field               | Value                                |
    5. +---------------------+--------------------------------------+
    6. | fixed_ip_address    |                                      |
    7. | floating_ip_address | 10.1.3.11                            |
    8. | floating_network_id | 45217501-16c6-49a9-946d-6d44ef2b0256 |
    9. | id                  | 9461b279-c5c7-4db0-a332-a3466c616861 |
    10. | port_id             |                                      |
    11. | router_id           |                                      |
    12. | tenant_id           | 180deec2c933457cb149ef5cf38322f8     |
    13. +---------------------+--------------------------------------+
    复制代码
    至此,网络相关资源全部创建完成
    下面我们来验证网络是否工作正常
    5. 启动虚拟机,分配floating ip创建port
    1. # quantum port-create --fixed-ip subnet_id=32fe8d37-5c35-453e-b7d4-a1c98ac7bf97 54f37003-7f4e-47f4-a865-c928de1ae9e3
    2. Created a new port:
    3. +----------------------+-------------------------------------------------------------------------------------+
    4. | Field                | Value                                                                               |
    5. +----------------------+-------------------------------------------------------------------------------------+
    6. | admin_state_up       | True                                                                                |
    7. | binding:capabilities | {"port_filter": false}                                                              |
    8. | binding:vif_type     | ovs                                                                                 |
    9. | device_id            |                                                                                     |
    10. | device_owner         |                                                                                     |
    11. | fixed_ips            | {"subnet_id": "32fe8d37-5c35-453e-b7d4-a1c98ac7bf97", "ip_address": "192.168.12.2"} |
    12. | id                   | 69802c75-20a9-4533-9b26-8975a39f9a5d                                                |
    13. | mac_address          | fa:16:3e:af:35:30                                                                   |
    14. | name                 |                                                                                     |
    15. | network_id           | 54f37003-7f4e-47f4-a865-c928de1ae9e3                                                |
    16. | status               | DOWN                                                                                |
    17. | tenant_id            | 180deec2c933457cb149ef5cf38322f8                                                    |
    18. +----------------------+-------------------------------------------------------------------------------------+
    复制代码
    创建 volume
    1. # cinder create --image-id 6b01928b-056f-4d2e-bb33-988a4853d7f9 --display-name dcai-precise 10
    2. +---------------------+--------------------------------------+
    3. |       Property      |                Value                 |
    4. +---------------------+--------------------------------------+
    5. |     attachments     |                  []                  |
    6. |  availability_zone  |                 nova                 |
    7. |       bootable      |                false                 |
    8. |      created_at     |      2013-05-17T08:32:55.108870      |
    9. | display_description |                 None                 |
    10. |     display_name    |             dcai-precise             |
    11. |          id         | 949077a3-67d9-478c-82b1-a57ad6780e97 |
    12. |       image_id      | 6b01928b-056f-4d2e-bb33-988a4853d7f9 |
    13. |       metadata      |                  {}                  |
    14. |         size        |                  10                  |
    15. |     snapshot_id     |                 None                 |
    16. |     source_volid    |                 None                 |
    17. |        status       |               creating               |
    18. |     volume_type     |                 None                 |
    19. +---------------------+--------------------------------------+
    复制代码

    启动虚拟机
    1. # nova boot --flavor 1 --image 6b01928b-056f-4d2e-bb33-988a4853d7f9 --block_device_mapping vda=949077a3-67d9-478c-82b1-a57ad6780e97:::0 --nic port-id=69802c75-20a9-4533-9b26-8975a39f9a5d dcai-m1
    2. +-------------------------------------+--------------------------------------+
    3. | Property                            | Value                                |
    4. +-------------------------------------+--------------------------------------+
    5. | OS-EXT-STS:task_state               | scheduling                           |
    6. | image                               | precise                              |
    7. | OS-EXT-STS:vm_state                 | building                             |
    8. | OS-EXT-SRV-ATTR:instance_name       | instance-0000007b                    |
    9. | flavor                              | m1.tiny                              |
    10. | id                                  | 9e6c3ed0-7e7a-4fdf-ae66-9b9eb99163b7 |
    11. | security_groups                     | [{u'name': u'default'}]              |
    12. | user_id                             | d61a9823e00f417b90b842dd8b5f7a94     |
    13. | OS-DCF:diskConfig                   | MANUAL                               |
    14. | accessIPv4                          |                                      |
    15. | accessIPv6                          |                                      |
    16. | progress                            | 0                                    |
    17. | OS-EXT-STS:power_state              | 0                                    |
    18. | OS-EXT-AZ:availability_zone         | None                                 |
    19. | config_drive                        |                                      |
    20. | status                              | BUILD                                |
    21. | updated                             | 2013-05-17T08:35:01Z                 |
    22. | hostId                              |                                      |
    23. | OS-EXT-SRV-ATTR:host                | None                                 |
    24. | key_name                            | None                                 |
    25. | OS-EXT-SRV-ATTR:hypervisor_hostname | None                                 |
    26. | name                                | dcai-m1                              |
    27. | adminPass                           | XH2o4LJda7CE                         |
    28. | tenant_id                           | 180deec2c933457cb149ef5cf38322f8     |
    29. | created                             | 2013-05-17T08:35:01Z                 |
    30. | metadata                            | {}                                   |
    31. +-------------------------------------+--------------------------------------+
    复制代码
    进入虚拟机,查看一切是否正常

    #########################################################本文转自:http://dnscai.com/blog/2013/05/18/quantum-create-network-guide/




欢迎加入about云群9037177932227315139327136 ,云计算爱好者群,亦可关注about云腾讯认证空间||关注本站微信

没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条