openstackNetworking(neutron)服务篇

一、安装并配置控制节点

1.先决条件

在你配置OpenStack网络(neutron)服务,你必须创建一个数据库,服务凭证和API端点。

1)创建数据库

mysql -uroot -p123123

      create database neutron;

      grant all privileges on neutron.* to'neutron'@'localhost' identified  by'123123';

      grant all privileges on neutron.* to'neutron'@'%' identified by '123123';

      exit;

2)获得 admin 凭证来获取只有管理员能执行命令的访问权限

     sourceadmin-openrc

3)创建服务证书
  a.创建neutron用户

      openstack user create --domain default--password-prompt neutron ##设置密码

  b.添加admin角色到neutron用户

      openstack role add --project service--user neutron admin

  c.创建neutron服务实体

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

4)创建网络服务API端点

      openstack endpoint create --regionRegionOne network public http://controller:9696

      openstack endpoint create --regionRegionOne network internel http://controller:9696

      openstack endpoint create --regionRegionOne network admin http://controller:9696

2.配置网络选项(这配置私有网络)

 1)安装组件

      yum install openstack-neutronopenstack-neutron-ml2 openstack-neutron-linuxbridge ebtables

 2)配置服务组件
  a.编辑/etc/neutron/neutron.conf文件并完成如下动作

      vi /etc/neutron/neutron.conf

      [database]

      connection = mysql+pymysql://neutron:123123@controller/neutron  ##配置数据库访问

      [DEFAULT]

      core_plugin = ml2

      service_plugins = router

      allow_overlapping_ips = True ##启用Modular Layer 2 (ML2)插件,路由服务和重叠的IP地址

      auth_strategy = keystone  ##配置认证服务访问

      notify_nova_on_port_status_changes = True

      notify_nova_on_port_data_changes = True  ##配置网络服务来通知计算节点的网络拓扑变化

      rpc_backend = rabbit  ##配置RabbitMQ消息队列的连接

      [oslo_messaging_rabbit]

      rabbit_host = controller

      rabbit_userid = openstack

      rabbit_password = 123123  ##配置RabbitMQ消息队列的连接

      [keystone_authtoken]   ##配置认证服务

      auth_uri = http://controller:5000

      auth_url = http://controller:35357

      memcached_servers = controller:11211

      auth_type = password

      project_domain_name = default

      user_domain_name = default

      project_name = service

      username = neutron

      password = 123123  ##配置认证服务,在 [keystone_authtoken] 中注释或者删除其他选项。

      [nova]  ##配置网络以能够反映计算网络拓扑变化:

auth_url =http://controller:35357

      auth_plugin = password

      project_domain_name = default

      user_domain_name = default

      region_name = RegionOne

      project_name = service

      username = nova

      password = 123123  ##配置网络以能够反映计算网络拓扑变化

      [oslo_concurrency]

      lock_path = /var/lib/neutron/tmp  ##配置锁路径

3)配置Modular Layer 2(ML2)插件

ML2插件使用Linux桥接机制为实例创建layer-2 (桥接/交换)虚拟网络基础设施。

a.编辑/etc/neutron/plugins/ml2/ml2_conf.ini文件并完成下面的操作

      vi /etc/neutron/plugins/ml2/ml2_conf.ini

      [ml2]

      type_drivers = flat,vlan,vxlan  ##启用flat,VLAN和VXLAN网络

      tenant_network_types = vxlan  ##启用VXLAN项目(私有)网络

      mechanism_drivers =linuxbridge,l2population  ##启用Linuxbridge和ayer-2机制

##在你配置ML2插件后,删除可能导致数据库不一致的``type_drivers``项的值,Linux桥接代理只支持VXLAN网络。

      extension_drivers = port_security  ##启用端口安全扩展驱动

      [ml2_type_flat]

      flat_networks = provider  ##配置公共flat提供网络

      [ml2_type_vxlan]

      vni_ranges = 1:1000  ##私有网络配置VXLAN网络识别的网络范围

      [securitygroup]

      enable_ipset = True  ##启用 ipset 增加安全组的方便性

 4)配置Linux桥接代理
a.编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini文件并完成下面的操作:

      vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini

      [linux_bridge]

      physical_interface_mappings = public:eth2  ##映射公共虚拟网络到公共物理网络接口,将eth2替换为物理公共网络接口。

      [vxlan]

      enable_vxlan = True

      local_ip = 10.0.0.31

      12_population = True  ##启用VXLAN覆盖网络,配置处理覆盖网络和启用layer-2 的物理网络接口的IP地址

      [securitygroup]

      enable_security_group = True

      firewall_driver =neutron.agent.linux.iptables_firewall.IptablesFirewallDriver  ##启用安全组并配置 Linux 桥接iptables 防火墙驱动

5)配置layer-3代理
a.编辑 /etc/neutron/l3_agent.ini 文件并完成下面操作:

      vi /etc/neutron/l3_agent.ini

      [DEFAULT]

      interface_driver =neutron.agent.linux.interface.BridgeInterfaceDriver

      external_network_bridge =

##配置Linux桥接网络驱动和外部网络桥接,external_network_bridge选项故意缺少值,这样就可以在一个代理上启用多个外部网络。

6)配置DHCP代理
a.编辑/etc/neutron/dhcp_agent.ini文件并完成下面的操作

配置Linux桥接网卡驱动,Dnsmasq DHCP驱动并启用隔离元数据,这样在公共网络上的实例就可以通过网络访问元数据

      [DEFAULT]

      interface_driver =neutron.agent.linux.interface.BridgeInterfaceDriver

      dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq

      enable_isolated_metadata = True

3.配置元数据代理

 1)编辑/etc/neutron/metadata_agent.ini文件并完成下面的操作

      vi /etc/neutron/metadata_agent.ini

      [DEFAULT]

      nova_metadata_ip = controller

      metadata_proxy_shared_secret = 123123  ##配置元数据代理共享密码

4.配置计算使用网络

1)编辑/etc/nova/nova.conf文件并完成下面操作

      vi /etc/nova/nova.conf

      [neutron]

      url = http://controller:9696

      auth_url = http://controller:35357

      auth_type = password

      project_domain_name = default

      user_domain_name = default

      region_name = RegionOne

      project_name = service

      username = neutron

      password = 123123 

      service_metadata_proxy = True

      metadata_proxy_shared_secret = 123123  ##配置访问参数,启用元数据代理并设置密码

5.完成安装

 1)网络服务初始化脚本需要一个超链接 /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

 2)同步数据库

     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

##数据库的同步发生在 Networking之后,因为脚本需要完成服务器和插件的配置文件。

3)重启计算API服务

 systemctl restart openstack-nova-api.service

4)启动Networking服务并配置他们开机启动
a.对所有网络选项:

systemctl enableneutron-server.service neutron-linuxbridge-agent.serviceneutron-dhcp-agent.service neutron-metadata-agent.service

systemctl startneutron-server.service neutron-linuxbridge-agent.serviceneutron-dhcp-agent.service neutron-metadata-agent.service

 b.对网络选项2,同样也启用并启动layer-3服务

   systemctl enable neutron-13-agent.service

    systemctlstart neutron-13-agent.service   

二、安装和配置计算节点

1.安装组件

      yum install openstack-neutronopenstack-neutron-linuxbridge ebtables ipset

2.配置通用组件

Networking通用组件的配置包括认证机制、消息队列和插件

1)编辑/etc/neutron/neutron.conf文件并完成如下动作:

在[database]部分,注释所有connection项,因为计算节点不直接访问数据库

      [DEFAULT]

      rpc_backend = rabbit  ##配置RabbitMQ消息队列访问

      auth_strategy = keystone  ##配置认证服务访问

      [oslo_messaging_rabbit]

      rabbit_host = controller

      rabbit_userid = openstack

      rabbit_password = 123123  ##配置RabbitMQ消息队列访问

     

      [keystone_authtoken]

      auth_uri = http://controller:5000

      auth_url = http://controller:35357

      memcached_servers = controller:11211

      auth_type = password

      project_domain_name = default

      user_domain_name = default

      project_name = service

      username = neutron

      password = 123123  ##配置认证服务访问,在 [keystone_authtoken] 中注释或者删除其他选项。

      [oslo_concurrency]

      lock_path = /var/lib/neutron/tmp  ##配锁路径

3.配置网络选项

1)配置Linux桥接代理
a.编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini文件并完成下面的操作:

      vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini

      [linux_bridge]

      physical_interface_mappings = public:eth2

##映射公共虚拟网络到公共物理网络接口,将eth2替换为物理公共网络接口

      [vxlan]

      enable_vxlan = True

      local_ip = 10.0.0.31

      12_population = True  ##启用VXLAN覆盖网络,配置处理覆盖网络和启用layer-2的物理网络接口的IP地址

      [securitygroup]

      enable_security_group = True

      firewall_driver =   neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

##用安全组并配置Linux 桥接 iptables 防火墙驱动:

4.配置计算机使用网络

1)编辑/etc/nova/nova.conf文件并完成下面的操作

      vi /etc/nova/nova.conf

      [neutron]

      url = http://controller:9696

      auth_url = http://controller:35357

      auth_type = password

      project_domain_name = default

      user_domain_name = default

      region_name = RegionOne

      project_name = service

      username = neutron

      password = 123123  ##配置访问参数

5.完成安装

1)重启计算服务

     systemctl restartopenstack-nova-compute.service

2)启动Linuxbridge代理并配置它开机自启动

     systemctl enableneutron-linuxbridge-agent.service

      systemctl start neutron-linuxbridge-agent.service

三、验证操作

1.获得admin凭证来获取只有管理员能执行命令的访问权限

      source admin-openrc

2.列出加载的扩展来验证neutron-server进程是否正常启动

      neutron ext-list

3.验证网络选项,列出代理验证启动neutron代理是否成功

 neutron agent-list