OpenStack部署应用第四篇:网络服务Neutron(转)

1、网络服务介绍

  OpenStack Networking(neutron),允许创建、插入接口设备,这些设备由其他的OpenStack服务管理。插件式的实现可以容纳不同的网络设备和软件,为OpenStack架构与部署提供了灵活性。
它包含下列组件:
neutron-server
  接收和路由API请求到合适的OpenStack网络插件,以达到预想的目的。
OpenStack网络插件和代理
  Plug and unplug ports, create networks or subnets, and provide IP addressing. These plug-ins and agents differ depending on the vendor and technologies used in the particular cloud. OpenStack Networking ships with plug-ins and agents for Cisco virtual and physical switches, NEC OpenFlow products, Open vSwitch, Linux bridging, and the VMware NSX product.
  常见的代理L3(3层),DHCP(动态主机IP地址),以及插件代理。
消息队列
  大多数的OpenStack Networking安装都会用到,用于在neutron-server和各种各样的代理进程间路由信息。也为某些特定的插件扮演数据库的角色,以存储网络状态
OpenStack网络主要和OpenStack计算交互,以提供网络连接到它的实例。

 

  网络服务提供网络,子网以及路由这些对象的抽象概念。每个抽象概念都有自己的功能,可以模拟对应的物理设备:网络包括子网,路由在不同的子网和网络间进行路由转发。

  对于任意一个给定的网络都必须包含至少一个外部网络。不想其他的网络那样,外部网络不仅仅是一个定义的虚拟网络。相反,它代表了一种OpenStack安装之外的能从物理的,外部的网络访问的视图。外部网络上的IP地址可供外部网络上的任意的物理设备所访问

  外部网络之外,任何 Networking 设置拥有一个或多个内部网络。这些软件定义的网络直接连接到虚拟机。仅仅在给定网络上的虚拟机,或那些在通过接口连接到相近路由的子网上的虚拟机,能直接访问连接到那个网络上的虚拟机。

  如果外部网络想要访问实例或者相反实例想要访问外部网络,那么网络之间的路由就是必要的了。每一个路由都配有一个网关用于连接到外部网络,以及一个或多个连接到内部网络的接口。就像一个物理路由一样,子网可以访问同一个路由上其他子网中的机器,并且机器也可以访问路由的网关访问外部网络。

  另外,你可以将外部网络的IP地址分配给内部网络的端口。不管什么时候一旦有连接连接到子网,那个连接被称作端口。你可以给实例的端口分配外部网络的IP地址。通过这种方式,外部网络上的实体可以访问实例.

  网络服务同样支持安全组。安全组允许管理员在安全组中定义防火墙规则。一个实例可以属于一个或多个安全组,网络为这个实例配置这些安全组中的规则,阻止或者开启端口,端口范围或者通信类型。

  每一个Networking使用的插件都有其自有的概念。虽然对操作VNI和OpenStack环境不是至关重要的,但理解这些概念能帮助你设置Networking。所有的Networking安装使用了一个核心插件和一个安全组插件(或仅是空操作安全组插件)。另外,防火墙即服务(FWaaS)和负载均衡即服务(LBaaS)插件是可用的。

2、环境准备

2.1 控制节点(node1)

1)创建数据库(第一篇中已经完成)

2)安装软件及配置服务

yum install -y openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables
[root@linux-node1 neutron]# grep -n '^[a-z]' neutron.conf
27:auth_strategy = keystone
30:core_plugin = ml2
33:service_plugins =
118:notify_nova_on_port_status_changes = true
122:notify_nova_on_port_data_changes = true
530:transport_url = rabbit://openstack:openstack@192.168.56.11
722:connection = mysql+pymysql://neutron:neutron@192.168.56.11/neutron
803:auth_uri = http://192.168.56.11:5000
804:auth_url = http://192.168.56.11:35357
805:memcached_servers = 192.168.56.11:11211
806:auth_type = password
807:project_domain_name = default
808:user_domain_name = default
809:project_name = service
810:username = neutron
811:password = neutron
1002:auth_url = http://192.168.56.11:35357
1003:auth_type = password
1004:project_domain_name = default
1005:user_domain_name = default
1006:region_name = RegionOne
1007:project_name = service
1008:username = nova
1009:password = nova
1122:lock_path = /var/lib/neutron/tmp


[root@linux-node1 ml2]# grep -n '^[a-z]' ml2_conf.ini 
109:type_drivers = flat,vlan,gre,vxlan,geneve
114:tenant_network_types = flat,vlan,gre,vxlan,geneve
118:mechanism_drivers = linuxbridge
123:extension_drivers = port_security
159:flat_networks = public
236:enable_ipset = true

[root@linux-node1 ml2]# grep -n '^[a-z]' linuxbridge_agent.ini
143:physical_interface_mappings = public:eth0
156:firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
161:enable_security_group = true
176:enable_vxlan = false

[root@linux-node1 ml2]# grep -n '^[a-z]' /etc/neutron/dhcp_agent.ini
16:interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
32:dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
41:enable_isolated_metadata = True

[root@linux-node1 ml2]# grep -n '^[a-z]' /etc/neutron/metadata_agent.ini 
22:nova_metadata_ip = 192.168.56.11
34:metadata_proxy_shared_secret = oldboy
# 网络服务初始化脚本需要一个超链接 /etc/neutron/plugin.ini``指向ML2插件配置文件/etc/neutron/plugins/ml2/ml2_conf.ini``。如果超链接不存在,使用下面的命令创建
ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini


# 同步数据库
su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \
--config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron

# 验证同步结果
mysql -h 192.168.56.11 -u neutron -pneutron -e "use neutron;show tables;"

# 启动服务
systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service
systemctl start neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service

 3)创建用户、API 端点等等

openstack service create --name neutron --description "OpenStack Networking" network

openstack endpoint create --region RegionOne network public http://192.168.56.11:9696
openstack endpoint create --region RegionOne network internal http://192.168.56.11:9696
openstack endpoint create --region RegionOne network admin http://192.168.56.11:9696

4)验证服务

[root@linux-node1 ~]# neutron agent-list          
+-----------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
| id                          | agent_type         | host                    | availability_zone | alive | admin_state_up | binary                    |
+-----------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
| 4a845146-20c8-4976-8440-8c5 | Metadata agent     | linux-node1.example.com |                   | :-)   | True           | neutron-metadata-agent    |
| 359e9f4b6                   |                    |                         |                   |       |                |                           |
| a0304ab9-4cf6-4dff-80ae-    | Linux bridge agent | linux-node1.example.com |                   | :-)   | True           | neutron-linuxbridge-agent |
| d517ec256f9b                |                    |                         |                   |       |                |                           |
| c753850b-aede-417e-         | DHCP agent         | linux-node1.example.com | nova              | :-)   | True           | neutron-dhcp-agent        |
| 8ea0-392a91248908           |                    |                         |                   |       |                |                           |
+-----------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+

 

2.2 计算节点(node2)

1)软件安装及配置

yum install -y openstack-neutron-linuxbridge ebtables ipset
[root@linux-node2 neutron]# grep -n '^[a-z]' /etc/neutron/neutron.conf 
27:auth_strategy = keystone
530:transport_url = rabbit://openstack:openstack@192.168.56.11
803:auth_uri = http://192.168.56.11:5000
804:auth_url = http://192.168.56.11:35357
805:memcached_servers = 192.168.56.11:11211
806:auth_type = password
807:project_domain_name = default
808:user_domain_name = default
809:project_name = service
810:username = neutron
811:password = neutron
1116:lock_path = /var/lib/neutron/tmp
[root@linux-node2 neutron]# grep -n '^[a-z]' /etc/neutron/plugins/ml2/linuxbridge_agent.ini   
143:physical_interface_mappings = public:eth0
156:firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
161:enable_security_group = true
176:enable_vxlan = false
systemctl restart openstack-nova-compute.service
systemctl enable neutron-linuxbridge-agent.service
systemctl start neutron-linuxbridge-agent.service

2)验证服务配置

[root@linux-node1 ~]# neutron agent-list 
+-----------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
| id                          | agent_type         | host                    | availability_zone | alive | admin_state_up | binary                    |
+-----------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
| 4a845146-20c8-4976-8440-8c5 | Metadata agent     | linux-node1.example.com |                   | :-)   | True           | neutron-metadata-agent    |
| 359e9f4b6                   |                    |                         |                   |       |                |                           |
| 56378775-792f-483c-         | Linux bridge agent | linux-node2.example.com |                   | :-)   | True           | neutron-linuxbridge-agent |
| ad04-bd662200d1fc           |                    |                         |                   |       |                |                           |
| a0304ab9-4cf6-4dff-80ae-    | Linux bridge agent | linux-node1.example.com |                   | :-)   | True           | neutron-linuxbridge-agent |
| d517ec256f9b                |                    |                         |                   |       |                |                           |
| c753850b-aede-417e-         | DHCP agent         | linux-node1.example.com | nova              | :-)   | True           | neutron-dhcp-agent        |
| 8ea0-392a91248908           |                    |                         |                   |       |                |                           |
+-----------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
[root@linux-node1 ~]# nova service-list
+----+------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary           | Host                    | Zone     | Status  | State | Updated_at                 | Disabled Reason |
+----+------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+
| 1  | nova-scheduler   | linux-node1.example.com | internal | enabled | up    | 2017-01-13T14:31:06.000000 | -               |
| 2  | nova-conductor   | linux-node1.example.com | internal | enabled | up    | 2017-01-13T14:31:09.000000 | -               |
| 3  | nova-consoleauth | linux-node1.example.com | internal | enabled | up    | 2017-01-13T14:31:12.000000 | -               |
| 6  | nova-compute     | linux-node2.example.com | nova     | enabled | up    | 2017-01-13T14:31:13.000000 | -               |
+----+------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+

 

posted @ 2017-01-13 21:37  每天进步一点点!!!  阅读(529)  评论(0编辑  收藏  举报