八、网络服务集群

概述

neutron-server

接收和路由API请求到合适的OpenStack网络插件,以达到预想的目的。

5.1、控制节点安装

5.1.1、先决条件

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

1、创建数据库

$ mysql -u rgalera -p galera -h 192.168.16.10

创建``neutron`` 数据库:

MariaDB [(none)] CREATE DATABASE neutron;

对``neutron`` 数据库授予合适的访问权限,使用合适的密码替换``NEUTRON_DBPASS``:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' \

  IDENTIFIED BY 'NEUTRON_DBPASS';

MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' \

  IDENTIFIED BY 'NEUTRON_DBPASS';

退出数据库客户端。

2、创建角色、用户

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

$ . admin-openrc

创建``neutron``用户:

$ openstack user create --domain default --password-prompt neutron

User Password:

Repeat User Password:

+---------------------+----------------------------------+

| Field               | Value                            |

+---------------------+----------------------------------+

| domain_id           | default                          |

| enabled             | True                             |

| id                  | fdb0f541e28141719b6a43c8944bf1fb |

| name                | neutron                          |

| options             | {}                               |

| password_expires_at | None                             |

+---------------------+----------------------------------+

3、添加``admin`` 角色到``neutron`` 用户

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

4、创建``neutron``服务实体:

$ openstack service create --name neutron \

  --description "OpenStack Networking" network

+-------------+----------------------------------+

| Field       | Value                            |

+-------------+----------------------------------+

| description | OpenStack Networking             |

| enabled     | True                             |

| id          | f71529314dab4a4d8eca427e701d209e |

| name        | neutron                          |

| type        | network                          |

+-------------+----------------------------------+

5、创建网络服务API端点:

$ openstack endpoint create --region RegionOne \

  network public http://controller:9696

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           | 85d80a6d02fc4b7683f611d7fc1493a3 |

| interface    | public                           |

| region       | RegionOne                        |

| region_id    | RegionOne                        |

| service_id   | f71529314dab4a4d8eca427e701d209e |

| service_name | neutron                          |

| service_type | network                          |

| url          | http://controller:9696           |

+--------------+----------------------------------+

$ openstack endpoint create --region RegionOne \

  network internal http://controller:9696

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           | 09753b537ac74422a68d2d791cf3714f |

| interface    | internal                         |

| region       | RegionOne                        |

| region_id    | RegionOne                        |

| service_id   | f71529314dab4a4d8eca427e701d209e |

| service_name | neutron                          |

| service_type | network                          |

| url          | http://controller:9696           |

+--------------+----------------------------------+

$ openstack endpoint create --region RegionOne \

  network admin http://controller:9696

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           | 1ee14289c9374dffb5db92a5c112fc4e |

| interface    | admin                            |

| region       | RegionOne                        |

| region_id    | RegionOne                        |

| service_id   | f71529314dab4a4d8eca427e701d209e |

| service_name | neutron                          |

| service_type | network                          |

| url          | http://controller:9696           |

+--------------+----------------------------------+

5.1.2、提供者网络服务安装配置

所有控制节点上安装安装软件

yum install openstack-neutron openstack-neutron-ml2 \

 openstack-neutron-linuxbridge ebtables

Networking 服务器组件的配置包括数据库、认证机制、消息队列、拓扑变化通知和插件。

编辑``/etc/neutron/neutron.conf`` 文件并完成如下操作:

在 [database] 部分,配置数据库访问:

[database]

connection = mysql+pymysql://neutron:NEUTRON_DBPASS@controller/neutron

使用你设置的数据库密码替换 NEUTRON_DBPASS 。

在``[DEFAULT]``部分,启用ML2插件并禁用其他插件:

[DEFAULT]

core_plugin = ml2

service_plugins =

在``[DEFAULT]``部分,配置``RabbitMQ``消息队列访问权限:

[DEFAULT]

transport_url = rabbit://openstack:RABBIT_PASS@controller1

用你在RabbitMQ中为``openstack``选择的密码替换 “RABBIT_PASS”。

在 “[DEFAULT]” 和 “[keystone_authtoken]” 部分,配置认证服务访问:

[DEFAULT]

auth_strategy = keystone

[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 = NEUTRON_PASS

在``[DEFAULT]``和``[nova]``部分,配置网络服务来通知计算节点的网络拓扑变化:

[DEFAULT]

notify_nova_on_port_status_changes = true

notify_nova_on_port_data_changes = true

[nova]

auth_url = http://controller:35357

auth_type = password

project_domain_name = default

user_domain_name = default

region_name = RegionOne

project_name = service

username = nova

password = NOVA_PASS

在 [oslo_concurrency] 部分,配置锁路径:

[oslo_concurrency]

lock_path = /var/lib/neutron/tmp

配置 Modular Layer 2 (ML2) 插件¶

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

编辑``/etc/neutron/plugins/ml2/ml2_conf.ini``文件并完成以下操作:

在``[ml2]``部分,启用flat和VLAN网络:

[ml2]

type_drivers = flat,vlan

在``[ml2]``部分,禁用私有网络:

[ml2]

tenant_network_types =

在``[ml2]``部分,启用Linuxbridge机制:

[ml2]

mechanism_drivers = linuxbridge

 警告

在你配置完ML2插件之后,删除可能导致数据库不一致的``type_drivers``项的值。

在``[ml2]`` 部分,启用端口安全扩展驱动:

[ml2]

extension_drivers = port_security

在``[ml2_type_flat]``部分,配置公共虚拟网络为flat网络:

[ml2_type_flat]

flat_networks = provider

在 ``[securitygroup]``部分,启用 ipset 增加安全组的方便性:

[securitygroup]

enable_ipset = true

配置Linuxbridge代理¶

Linuxbridge代理为实例建立layer-2虚拟网络并且处理安全组规则。

编辑``/etc/neutron/plugins/ml2/linuxbridge_agent.ini``文件并且完成以下操作:

在``[linux_bridge]``部分,将公共虚拟网络和公共物理网络接口对应起来:

[linux_bridge]

physical_interface_mappings = provider:ens160

将``PUBLIC_INTERFACE_NAME`` 替换为底层的物理公共网络接口。请查看:ref:environment-networking for more information。

在``[vxlan]``部分,禁止VXLAN覆盖网络:

[vxlan]

enable_vxlan = false

在 ``[securitygroup]``部分,启用安全组并配置 Linux 桥接 iptables 防火墙驱动:

[securitygroup]

enable_security_group = true

firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

配置DHCP代理¶

The DHCP agent provides DHCP services for virtual networks.

编辑``/etc/neutron/dhcp_agent.ini``文件并完成下面的操作:

在``[DEFAULT]``部分,配置Linuxbridge驱动接口,DHCP驱动并启用隔离元数据,这样在公共网络上的实例就可以通过网络来访问元数据

[DEFAULT]

interface_driver = linuxbridge

dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq

enable_isolated_metadata = true

1、配置元数据代理

编辑``/etc/neutron/metadata_agent.ini``文件并完成以下操作:

在``[DEFAULT]`` 部分,配置元数据主机以及共享密码:

[DEFAULT]

nova_metadata_ip = controller

metadata_proxy_shared_secret = METADATA_SECRET

用你为元数据代理设置的密码替换 METADATA_SECRET。

2、配置计算服务来使用网络服务

编辑``/etc/nova/nova.conf``文件并完成以下操作:

在``[neutron]``部分,配置访问参数,启用元数据代理并设置密码:

[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 = NEUTRON_PASS

service_metadata_proxy = true

metadata_proxy_shared_secret = METADATA_SECRET

将 NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码。

使用你为元数据代理设置的密码替换``METADATA_SECRET``

3、完成安装

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

 注解

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

# systemctl restart openstack-nova-api.service

当系统启动时,启动 Networking 服务并配置它启动。

Controller2、controller3节点修改同上,nova_metadata_ip改成对应的主机名

对于两种网络选项:

4、启动并开机启动服务

# 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

systemctl status neutron-server.service \

  neutron-linuxbridge-agent.service neutron-dhcp-agent.service \

  neutron-metadata-agent.service | grep running

对于网络选项2,同样启用layer-3服务并设置其随系统自启动

# systemctl enable neutron-l3-agent.service

# systemctl start neutron-l3-agent.service

5、把neutron服务添加到haproxy里

Vim /etc/harpoxy/haproxy.cfg

listen neutron_api_cluster

  bind 192.168.16.10:9696

  balance  source

  option  tcpka

  option  httpchk

  option  tcplog

  server controller1 192.168.16.11:9696 check inter 2000 rise 2 fall 5

  server controller2 192.168.16.12:9696 check inter 2000 rise 2 fall 5

  server controller3 192.168.16.13:9696 check inter 2000 rise 2 fall 5

copy到其他控制节点上重启haproxy

5.2、计算节点安装

计算节点处理实例的连接和 security groups 。

1、安装组件

# yum install openstack-neutron-linuxbridge ebtables ipset

2、配置通用组件

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

/etc/neutron/neutron.conf

在``[database]`` 部分,注释所有``connection`` 项,因为计算节点不直接访问数据库。(默认已完全注释)

在``[DEFAULT]``部分,配置``RabbitMQ``消息队列访问权限:

[DEFAULT]

transport_url = rabbit://openstack:RABBIT_PASS@controller1

用你在RabbitMQ中为``openstack``选择的密码替换 “RABBIT_PASS”。

在 “[DEFAULT]” 和 “[keystone_authtoken]” 部分,配置认证服务访问:

[DEFAULT]

auth_strategy = keystone

[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 = NEUTRON_PASS

在 [oslo_concurrency] 部分,配置锁路径:

[oslo_concurrency]

lock_path = /var/lib/neutron/tmp

3、配置Linuxbridge代理

Linuxbridge代理为实例建立layer-2虚拟网络并且处理安全组规则。

编辑``/etc/neutron/plugins/ml2/linuxbridge_agent.ini``文件并且完成以下操作:

在``[linux_bridge]``部分,将公共虚拟网络和公共物理网络接口对应起来:

[linux_bridge]

physical_interface_mappings = provider:ens160

将``PUBLIC_INTERFACE_NAME`` 替换为底层的物理公共网络接口。请查看:ref:environment-networking for more information。

在``[vxlan]``部分,禁止VXLAN覆盖网络:

[vxlan]

enable_vxlan = false

在 ``[securitygroup]``部分,启用安全组并配置 Linux 桥接 iptables 防火墙驱动:

[securitygroup]

enable_security_group = true

firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

4、配置计算服务来使用网络服务

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

在``[neutron]`` 部分,配置访问参数:

[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 = NEUTRON_PASS

将 NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码。

完成安装

重启计算服务:

# systemctl restart openstack-nova-compute.service

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

5、启动、开机启动服务

# systemctl enable neutron-linuxbridge-agent.service

# systemctl start neutron-linuxbridge-agent.service

5.3、验证操作

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

$ . admin-openrc

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

$ openstack extension list--network(太多,略)

列出代理以验证启动 neutron 代理是否成功:

$ openstack network agent list

+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+

| ID                                   | Agent Type         | Host       | Availability Zone | Alive | State | Binary                    |

+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+

| 0400c2f6-4d3b-44bc-89fa-99093432f3bf | Metadata agent     | controller | None              | True  | UP    | neutron-metadata-agent    |

| 83cf853d-a2f2-450a-99d7-e9c6fc08f4c3 | DHCP agent         | controller | nova              | True  | UP    | neutron-dhcp-agent        |

| ec302e51-6101-43cf-9f19-88a78613cbee | Linux bridge agent | compute    | None              | True  | UP    | neutron-linuxbridge-agent |

| fcb9bc6e-22b1-43bc-9054-272dd517d025 | Linux bridge agent | controller | None              | True  | UP    | neutron-linuxbridge-agent |

+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+

输出结果应该包括控制节点上的三个代理和每个计算节点上的一个代理。

猜你喜欢

转载自www.cnblogs.com/hanjingzheng/p/9082255.html
今日推荐