zoukankan      html  css  js  c++  java
  • 【openstack N版】——网络服务neutron(flat扁平网络)

    一.openstack网络服务neutron

    1.1neutron介绍

      neutron是openstack重要组件之一,在以前是时候没有neutron项目,早期的时候是没有neutron,早期所使用的网络的nova-network,经过版本改变才有neutron。

      OpenStack的网络(Neutron),可以创建和附加其他的OpenStack服务,网络管理接口设备。插件可以被实现,以适应不同的网络设备和软件,提供灵活性,以开栈架构和部署。
    OpenStack的网络(Neutron)管理虚拟网络基础架构(VNI),并在您的OpenStack的环境中的物理网络基础架构(PNI)的接入层方面的所有网络方面。开栈网络允许租户创建高级的虚拟网络拓扑可包括服务,例如防火墙,负载均衡器,和虚拟专用网(VPN)。

    1.1.1Openstack Networking
    • 网络:在实际的物理环境下,我们使用交换机或者集线器把多个计算机连接起来形成了网络。在neutron的世界里,网络也是将多个不同的云主机连起来。
    • 子网:在十几的物理环境下,在一个网络中,我们可以讲网络划分成多位逻辑子网。在neutron世界里,子网也是隶属于网络下的。
    • 端口:是十几的物理环境下,每个子网或者每个网络,都有很多的端口,比如交换机端口来供计算机连接。在neutron的世界里,端口也是隶属于自往下,云主机的网卡会对应到一个端口上。
    • 路由器:在实际的网络罗环境下,不同网络或者不同逻辑子网之间如果需要进行通信,需要通过路由器进行路由。在neutron的世界里实际路由也是这个作用,用来连接不同的网络或者子网。

    1.2neutron环境准备(控制节点)

    1.2.1安装neutron包
    1 #安装neutron,openstack的网络服务 
    2 [root@linux-node1 ~]# yum install -y \
    3 openstack-neutron \
    4 openstack-neutron-ml2 \
    5 openstack-neutron-linuxbridge \
    6 ebtables
    1.2.2创建库及用户
    1 #创建neutron库
    2 MariaDB [(none)]> create database neutron;
    3 Query OK, 1 row affected (0.01 sec)
    4 #创建neutron用户并授权
    5 MariaDB [(none)]> grant all privileges on neutron.* to 'neutron'@'%' identified by 'neutron';
    6 Query OK, 0 rows affected (0.00 sec)
    7 MariaDB [(none)]> grant all privileges on neutron.* to 'neutron'@'localhost' identified by 'neutron'; 
    8 Query OK, 0 rows affected (0.00 sec)
    1.2.3编辑neutron控制节点配置文件
     1 #编辑配置文件
     2 [root@linux-node1 ~]# vim /etc/neutron/neutron.conf
     3 #neutron连接数据库配置
     4 connection = mysql+pymysql://neutron:neutron@192.168.56.11/neutron
     5 #开启keystone认证,打开注释
     6 auth_strategy = keystone
     7 #使用ml2插件
     8 core_plugin = ml2
     9 #禁用其它插件
    10 service_plugins =
    11 #配置neutron连接keystone
    12 auth_uri = http://192.168.56.11:5000
    13 auth_url = http://192.168.56.11:35357
    14 memcached_servers = 192.168.56.11:11211
    15 auth_type = password
    16 project_domain_name = default
    17 user_domain_name = default
    18 project_name = service
    19 username = neutron
    20 password = neutron
    21 #neutron连接消息队列
    22 transport_url = rabbit://openstack:openstack@192.168.56.11
    23 #配置网络服务来通知计算节点的网络拓扑变化
    24 notify_nova_on_port_status_changes = true
    25 notify_nova_on_port_data_changes = true
    26 #配置[nova]部分
    27 auth_url = http://192.168.56.11:35357
    28 auth_type = password
    29 project_domain_name = default
    30 user_domain_name = default
    31 region_name = RegionOne
    32 project_name = service
    33 username = nova
    34 password = nova
    35 #锁文件路径
    36 lock_path = /var/lib/neutron/tmp
    1.2.4配置网络选项

    您可以部署网络服务使用选项1和选项2两种架构中的一种来部署网络服务。

    选项1:采用尽可能简单的架构进行部署,只支持实例连接到公有网络(外部网络)。没有私有网络(个人网络),路由器以及浮动IP地址。只有``admin``或者其他特权用户才可以管理公有网络

    选项2:在选项1的基础上多了layer-3服务,支持实例连接到私有网络。``demo``或者其他没有特权的用户可以管理自己的私有网络,包含连接公网和私网的路由器。另外,浮动IP地址可以让实例使用私有网络连接到外部网络,例如互联网

    典型的私有网络一般使用覆盖网络。覆盖网络,例如VXLAN包含了额外的数据头,这些数据头增加了开销,减少了有效内容和用户数据的可用空间。在不了解虚拟网络架构的情况下,实例尝试用以太网 最大传输单元 (MTU) 1500字节发送数据包。网络服务会自动给实例提供正确的MTU的值通过DHCP的方式。但是,一些云镜像并没有使用DHCP或者忽视了DHCP MTU选项,要求使用元数据或者脚本来进行配置

    网络选项1:提供者网络(flat扁平网络模式)

    网络选项2:自服务网络(vxlan浮动IP模式)

    • 配置 Modular Layer 2 (ML2) 插件

    ML2插件使用Linuxbridge机制来为实例创建layer-2虚拟网络基础设施

     1 #编辑ml2配置文件
     2 [root@linux-node1 ~]# vim /etc/neutron/plugins/ml2/ml2_conf.ini
     3 #在ml2下添加内容
     4 [ml2]
     5 #启用flat和VLAN网络
     6 type_drivers = flat,vlan,gre,vxlan,geneve
     7 #禁用私有网络
     8 tenant_network_types = flat,vlan,gre,vxlan,geneve
     9 #启用linuxbridge
    10 mechanism_drivers = linuxbridge
    11 #启用端口安全扩展
    12 extension_drivers = port_security
    13 #在ml2_type_flat配置 
    14 [ml2_type_flat]
    15 #配置公共虚拟网络名字
    16 flat_networks = public
    17 #在securitygroup配置
    18 [securitygroup]
    19 #启用ipset 
    20 enable_ipset = true
    • 配置Linuxbridge代理
     1 #编辑linuxbridge配置文件
     2 [root@linux-node1 ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
     3 #在linux_bridge下配置 
     4 [linux_bridge]
     5 #映射虚拟网络接口和物理接口
     6 physical_interface_mappings = public:eth0
     7 #在vxlan下配置
     8 [vxlan]
     9 #禁止vxlan覆盖网络
    10 enable_vxlan = false
    11 #在securitygroup下配置
    12 [securitygroup]
    13 #启用安全组
    14 enable_security_group = true
    15 #配置linux桥接防火墙驱动
    16 firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
    • 配置DHCP代理
    1 #编辑dhcp配置文件
    2 [root@linux-node1 ~]# vim /etc/neutron/dhcp_agent.ini
    3 #配置linuxbridge接口驱动 
    4 interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
    5 #DHCP驱动
    6 dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
    7 #启用隔离元数据 
    8 enable_isolated_metadata = True
    • 配置元数据代理
    1 #修改metadata配置文件
    2 [root@linux-node1 ~]# vim /etc/neutron/metadata_agent.ini
    3 #元数据主机IP
    4 nova_metadata_ip = 192.168.56.11
    5 #配置共享密码
    6 metadata_proxy_shared_secret = metadata
    • 在nova配置文件里配置nuetron
     1 #修改nova配置文件
     2 [root@linux-node1 ~]# vim /etc/nova/nova.conf
     3 #在neutron标签下配置
     4 [neutron]
     5 url = http://192.168.56.11:9696
     6 auth_url = http://192.168.56.11:35357
     7 auth_type = password
     8 project_domain_name = default
     9 user_domain_name = default
    10 region_name = RegionOne
    11 project_name = service
    12 username = neutron
    13 password = neutron
    14 service_metadata_proxy = True
    15 #上文配置的共享密码 
    16 metadata_proxy_shared_secret = metadata

    注:网络服务初始化脚本需要一个超链接 /etc/neutron/plugin.ini``指向ML2插件配置文件/etc/neutron/plugins/ml2

    1 [root@linux-node1 ~]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini

    1.2.5将数据导入数据库

    1 [root@linux-node1 ~]# su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \
    2 --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron

    1.2.6创建端点及实体服务

     1 #创建neutron实体服务
     2 [root@linux-node1 ~]# openstack service create --name neutron \
     3 --description "OpenStack Networking" network
     4 #创建neutron端点
     5 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \
     6 network public http://192.168.56.11:9696
     7 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \
     8 network internal http://192.168.56.11:9696
     9 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \
    10 network admin http://192.168.56.11:9696

    1.2.7启动neutron服务

     1 #重启nova-api服务
     2 [root@linux-node1 ~]# systemctl restart openstack-nova-api.service
     3 #允许开机自启
     4 [root@linux-node1 ~]# systemctl enable neutron-server.service \
     5 neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
     6 neutron-metadata-agent.service
     7 #启动neutron及其插件服务
     8 [root@linux-node1 ~]# systemctl start neutron-server.service \
     9 neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
    10 neutron-metadata-agent.service

    1.2.8检查服务

    1 [root@linux-node1 ~]# neutron agent-list
    +--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
    | id                                   | agent_type         | host                    | availability_zone | alive | admin_state_up | binary                    |
    +--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
    | 09179e20-de5a-46c8-8653-892d8c4e6ffb | Linux bridge agent | linux-node1.example.com |                   | :-)   | True           | neutron-linuxbridge-agent |
    | 62658264-8d5e-42ba-ac9c-95dc52e102ec | DHCP agent         | linux-node1.example.com | nova              | :-)   | True           | neutron-dhcp-agent        |
    | c63619f7-0ed9-4833-88f4-4ae0422a9214 | Metadata agent     | linux-node1.example.com |                   | :-)   | True           | neutron-metadata-agent    |
    +--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
    看到标红的三个笑脸,则证明neutron控制节点的服务启动正常

    二.neutron计算节点配置

    2.1计算节点neutron环境准备

    2.1.1安装neutron包
    1 [root@linux-node2 ~]# yum install openstack-neutron-linuxbridge ebtables ipset -y
    2.1.2修改neutron配置文件
     1 #编辑计算节点neutron配置文件
     2 [root@linux-node2 ~]# vim /etc/neutron/neutron.conf
     3 #连接消息队列配置
     4 transport_url = rabbit://openstack:openstack@192.168.56.11
     5 #开启keystone认证,打开注释
     6 auth_strategy = keystone
     7 #在keystone_authtoken标签下添加连接keystone配置
     8 [keystone_authtoken]
     9 auth_uri = http://192.168.56.11:5000
    10 auth_url = http://192.168.56.11:35357
    11 memcached_servers = 192.168.56.11:11211
    12 auth_type = password
    13 project_domain_name = default
    14 user_domain_name = default
    15 project_name = service
    16 username = neutron
    17 password = neutron
    18 #锁路径
    19 lock_path = /var/lib/neutron/tmp
    2.1.3配置网络选项

    注:如果控制节点选的是,网络选项1,则此处也选择网络选项1.

    网络选项1:提供者网络

    网络选项2:自服务网络

    • 配置 Modular Layer 2 (ML2) 插件
    1 #因为计算节点此文件和控制节点相同只需要拷贝即可
    2 [root@linux-node1 ~]# scp /etc/neutron/plugins/ml2/linuxbridge_agent.ini 192.168.56.12:/etc/neutron/plugins/ml2/
    • 在nova配置文件中配置neutron
     1 #修改nova配置文件
     2 [root@linux-node2 ~]# vim /etc/nova/nova.conf
     3 #在neutron标签下添加内容
     4 [neutron]
     5 url = http://192.168.56.11:9696
     6 auth_url = http://192.168.56.11:35357
     7 auth_type = password
     8 project_domain_name = default
     9 user_domain_name = default
    10 region_name = RegionOne
    11 project_name = service
    12 username = neutron
    13 password = neutron
    2.1.4启动neutron服务
    1 #重启nova服务
    2 [root@linux-node2 ~]# systemctl restart openstack-nova-compute.service
    3 #允许neutron开机自启
    4 [root@linux-node2 ~]# systemctl enable neutron-linuxbridge-agent.service
    5 #启动neutron服务
    6 [root@linux-node2 ~]# systemctl start neutron-linuxbridge-agent.service
    2.1.5检查服务
    1 #检查网络服务
    2 [root@linux-node1 ~]# neutron agent-list
    +--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
    | id                                   | agent_type         | host                    | availability_zone | alive | admin_state_up | binary                    |
    +--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
    | 09179e20-de5a-46c8-8653-892d8c4e6ffb | Linux bridge agent | linux-node1.example.com |                   | :-)   | True           | neutron-linuxbridge-agent |
    | 62658264-8d5e-42ba-ac9c-95dc52e102ec | DHCP agent         | linux-node1.example.com | nova              | :-)   | True           | neutron-dhcp-agent        |
    | 9600eb37-fce4-476f-bc31-fe7031309f04 | Linux bridge agent | linux-node2.example.com |                   | :-)   | True           | neutron-linuxbridge-agent |
    | c63619f7-0ed9-4833-88f4-4ae0422a9214 | Metadata agent     | linux-node1.example.com |                   | :-)   | True           | neutron-metadata-agent    |
    +--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
    3 #检查计算服务 4 [root@linux-node1 ~]# nova service-list
    +----+------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+
    | Id | Binary           | Host                    | Zone     | Status  | State | Updated_at                 | Disabled Reason |
    +----+------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+
    | 1  | nova-consoleauth | linux-node1.example.com | internal | enabled | up    | 2017-02-27T06:33:10.000000 | -               |
    | 2  | nova-conductor   | linux-node1.example.com | internal | enabled | up    | 2017-02-27T06:33:17.000000 | -               |
    | 3  | nova-scheduler   | linux-node1.example.com | internal | enabled | up    | 2017-02-27T06:33:10.000000 | -               |
    | 6  | nova-compute     | linux-node2.example.com | nova     | enabled | up    | 2017-02-27T06:33:16.000000 | -               |
    +----+------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+

    【开源是一种精神,分享是一种美德】

      — By GoodCook

      — 笔者QQ:253097001

      — 欢迎大家随时来交流

      —原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。

  • 相关阅读:
    卿学姐与魔法(优先队列)
    H国的身份证号码(搜索)
    钓鱼(贪心,优先队列)
    Communication System(动态规划)
    最长连续01字符串
    魔法跳舞链 (最小生成树)
    括号匹配(线段树)
    bzoj 1042: [HAOI2008]硬币购物
    bzoj 1057: [ZJOI2007]棋盘制作
    bzoj 1452: [JSOI2009]Count
  • 原文地址:https://www.cnblogs.com/goodcook/p/6473991.html
Copyright © 2011-2022 走看看