- 先在控制节点上配置Neutron服务。
控制节点安装配置Neutron组件
创建Neutron数据库并创建添加相关用户
1、创建数据库:
- 用数据库连接客户端以 root 用户连接到数据库服务器:
mysql -u root -p
- 创建
neutron
数据库:
CREATE DATABASE neutron;
- 对
neutron
数据库授予恰当的访问权限,使用合适的密码替换NEUTRON_DBPASS
:
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' \
IDENTIFIED BY 'NEUTRON_DBPASS';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' \
IDENTIFIED BY 'NEUTRON_DBPASS'; - 退出数据库客户端。
2、获得 admin 凭证来获取只有管理员能执行命令的访问权限:
source admin-openrc.sh
3、创建服务证书:
- 创建
neutron
用户:
openstack user create --domain default --password-prompt neutron
- 添加
admin
角色到neutron
用户:
openstack role add --project service --user neutron admin
- 创建
neutron
服务实体:
openstack service create --name neutron \
--description "OpenStack Networking" network
4、创建网络服务API端点:
# 创建public端点:
openstack endpoint create --region RegionOne \
network public http://controller:9696
# 创建internal端点:
openstack endpoint create --region RegionOne \
network internal http://controller:9696
# 创建admin端点:
openstack endpoint create --region RegionOne \
network admin http://controller:9696
配置网络(这里采用最简网络的方式——提供者网络)
- 注:该方式配置简单,没有引入L3的功能,不能够自己创建私有网络不能构建路由器等,如需创建请查看自服务网络:自服务网络配置(待更新)
1、安装Neutron组件:
apt-get install neutron-server neutron-plugin-ml2 \
neutron-plugin-linuxbridge-agent neutron-dhcp-agent \
neutron-metadata-agent python-neutronclient conntrack
2、编辑/etc/neutron/neutron.conf
文件并完成如下修改:
# 在 [database] 部分,配置数据库访问,用你选择的数据库密码替换 NEUTRON_DBPASS:
[database]
...
connection = mysql+pymysql://neutron:NEUTRON_DBPASS@controller/neutron
# 在[DEFAULT]部分,启用Modular Layer 2 (ML2) 插件并禁用其他插件:
[DEFAULT]
...
core_plugin = ml2
service_plugins =
#在[DEFAULT]和[oslo_messaging_rabbit]部分,配置RabbitMQ消息队列访问,用你在RabbitMQ中为openstack选择的密码替换RABBIT_PASS:
[DEFAULT]
...
rpc_backend = rabbit
[oslo_messaging_rabbit]
...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = RABBIT_PASS
# 在[DEFAULT]和[keystone_authtoken]部分,配置认证服务访问,将 NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码,并且 [keystone_authtoken] 中注释或者删除其他选项:
[DEFAULT]
...
auth_strategy = keystone
[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = neutron
password = NEUTRON_PASS
# 在[DEFAULT]和[nova]部分,配置网络以能够反映计算网络拓扑变化,用你在身份认证服务中选择的nova用户密码替换NOVA_PASS并启用日志:
[DEFAULT]
...
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
nova_url = http://controller:8774/v2
verbose = True
[nova]
...
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
region_name = RegionOne
project_name = service
username = nova
password = NOVA_PASS
3、编辑/etc/neutron/plugins/ml2/ml2_conf.ini
文件并完如下修改(配置 Modular Layer 2 (ML2) 插件)
# 在[ml2]部分,启用 flat 和 VLAN 网络,禁用项目(私有)网络并启用Linux 桥接机制和端口安全扩展驱动:
[ml2]
...
type_drivers = flat,vlan
tenant_network_types =
mechanism_drivers = linuxbridge
extension_drivers = port_security
# 注:在你配置ML2插件后,删除可能导致数据库不一致的type_drivers项的值
# 在[ml2_type_flat]部分,配置公共flat提供网络:
[ml2_type_flat]
...
flat_networks = public
# 在[securitygroup]部分,启用 ipset 增加安全组的方便性:
[securitygroup]
...
enable_ipset = True
4、编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini
文件并完成如下修改(配置Linux 桥接代理):
# 在[linux_bridge]部分,映射公共虚拟网络到公共物理网络接口,将PUBLIC_INTERFACE_NAME替换为物理公共网络接口:
[linux_bridge]
physical_interface_mappings = public:PUBLIC_INTERFACE_NAME
# 在[vxlan]部分,禁用 VXLAN overlay 网络:
[vxlan]
enable_vxlan = False
# 在[agent]部分,启用ARP欺骗防护:
[agent]
...
prevent_arp_spoofing = True
# 在[securitygroup]部分,启用安全组并配置 Linux 桥接 iptables 防火墙驱动:
[securitygroup]
...
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
5、编辑/etc/neutron/dhcp_agent.ini
文件并完成如下修改(配置DHCP代理):
# 在[DEFAULT]部分,配置Linux桥接网卡驱动,Dnsmasq DHCP驱动并启用隔离元数据以及日志服务,这样在公共网络上的实例就可以通过网络访问元数据:
[DEFAULT]
...
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = True
verbose = True
配置元数据代理
编辑/etc/neutron/metadata_agent.ini
文件并完成如下修改:
# 在[DEFAULT]部分,配置访问参数,将 NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码:
[DEFAULT]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_region = RegionOne
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = neutron
password = NEUTRON_PASS
# 在[DEFAULT]部分,启用日志,配置元数据主机,元数据代理共享密码(用你为元数据代理选择的密码替换 METADATA_SECRET):
[DEFAULT]
...
verbose = True
nova_metadata_ip = controller
metadata_proxy_shared_secret = METADATA_SECRET
配置计算使用网络
编辑/etc/nova/nova.conf
文件并完成如下修改:
# 在[neutron]部分,配置访问参数,启用元数据代理和配置secret,将 NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码,用你为元数据代理选择的密码替换 METADATA_SECRET:
[neutron]
...
url = http://controller:9696
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS
service_metadata_proxy = True
metadata_proxy_shared_secret = METADATA_SECRET
重启相关服务完成安装
1、同步数据库:
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
2、重启计算API 服务:
service nova-api restart
3、重启网络服务:
service neutron-server restart
service neutron-plugin-linuxbridge-agent restart
service neutron-dhcp-agent restart
service neutron-metadata-agent restart
4、删除Ubuntu默认创建的SQLite数据库:
rm -f /var/lib/neutron/neutron.sqlite
- 以下操作在计算节点上完成配置!!!
计算节点安装Neutron服务
安装Neutron组件
apt-get install neutron-plugin-linuxbridge-agent conntrack
配置通用组件
编辑/etc/neutron/neutron.conf
文件并完成如下修改:
# 在[database]部分,注释所有connection项,因为计算节点不直接访问数据库
#在[DEFAULT]和[oslo_messaging_rabbit]部分,配置RabbitMQ消息队列访问,并启用日志:
[DEFAULT]
...
verbose = True
rpc_backend = rabbit
[oslo_messaging_rabbit]
...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = RABBIT_PASS
#用你在RabbitMQ中为openstack选择的密码替换 RABBIT_PASS
# 在[DEFAULT]和[keystone_authtoken]部分,配置认证服务访问,在 [keystone_authtoken] 中注释或者删除其他选项:
[DEFAULT]
...
auth_strategy = keystone
[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = neutron
password = NEUTRON_PASS
#将 NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码
配置网络(这里采用最简网络的方式——提供者网络)
编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini
文件并完成如下修改(配置Linux 桥接代理):
# 在[linux_bridge]部分,映射公共虚拟网络到公共物理网络接口:
[linux_bridge]
physical_interface_mappings = public:PUBLIC_INTERFACE_NAME #将PUBLIC_INTERFACE_NAME 替换为物理公共网络接口
# 在[vxlan]部分,禁用 VXLAN overlay 网络:
[vxlan]
enable_vxlan = False
# 在[agent]部分,启用ARP欺骗防护:
[agent]
...
prevent_arp_spoofing = True
# 在[securitygroup]部分,启用安全组并配置 Linux 桥接 iptables 防火墙驱动:
[securitygroup]
...
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
配置计算使用网络
编辑/etc/nova/nova.conf
文件并完成如下配置:
# 在[neutron] 部分,配置访问参数:
[neutron]
...
url = http://controller:9696
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS #将 NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码
重启服务完成安装
1、重启计算服务:
service nova-compute restart
2、重启Linux桥接代理:
service neutron-plugin-linuxbridge-agent restart
验证Neutron服务(在控制节点上执行)
1、获得 admin 凭证来获取只有管理员能执行命令的访问权限:
source admin-openrc.sh
2、列出加载的扩展,对neutron-server
进程是否启动正常进行验证:
neutron ext-list
3、列出代理以验证启动 neutron 代理是否成功:
neutron agent-list
# 该输出应该显示在控制节点上有三个代理,在每个计算节点有一个代理
本文基于参考文章撰写,根据自己的理解对于翻译难以理解的部分进行了调整,此博文部署过程亲测可用。
参考文章:OpenStack官方文档