Neutron是OpenStack管理网络的服务,需要在Controller和Compute节点都做相应的配置。
1. Controller节点
创建数据库(注意替换NEUTRON_DBPASS)
sudo mysql -u root -p
MariaDB [(none)] CREATE DATABASE neutron;
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';
加载环境变量
. admin-openrc
创建用户并加入角色
openstack user create --domain default --password-prompt neutron
openstack role add --project service --user neutron admin
创建服务
openstack service create --name neutron --description "OpenStack Networking" network
创建api端点
openstack endpoint create --region RegionOne network public http://controller:9696
openstack endpoint create --region RegionOne network internal http://controller:9696
openstack endpoint create --region RegionOne network admin http://controller:9696
OpenStack有两种网络模式,这里选用Self-Service模式,安装程序
sudo apt-get install neutron-server neutron-plugin-ml2 \
neutron-linuxbridge-agent neutron-l3-agent neutron-dhcp-agent \
neutron-metadata-agent
修改配置文件
sudo vim /etc/neutron/neutron.conf
修改database(注意替换NEUTRON_DBPASS)
[database]
# ...
connection = mysql+pymysql://neutron:NEUTRON_DBPASS@controller/neutron
修改Default(注意替换RABBIT_PASS)
[DEFAULT]
# ...
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = true
transport_url = rabbit://openstack:RABBIT_PASS@controller
auth_strategy = keystone
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
修改keystone_authtoken(注意替换NEUTRON_PASS)
[keystone_authtoken]
# ...
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS
修改nova(注意替换NOVA_PASS)
[nova]
# ...
auth_url = http://controller:5000
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
修改配置文件
sudo vim /etc/neutron/plugins/ml2/ml2_conf.ini
修改ml2
[ml2]
# ...
type_drivers = flat,vlan,vxlan
tenant_network_types = vxlan
mechanism_drivers = linuxbridge,l2population
extension_drivers = port_security
修改ml2_type_flat
[ml2_type_flat]
# ...
flat_networks = provider
修改ml2_type_vxlan
[ml2_type_vxlan]
# ...
vni_ranges = 1:1000
修改securitygroup
[securitygroup]
# ...
enable_ipset = true
修改配置文件
sudo vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
修改linux_bridge,这里PROVIDER_INTERFACE_NAME是接入互联网的网络接口名
[linux_bridge]
physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
修改vxlan,OVERLAY_INTERFACE_IP_ADDRESS是我们内部使用的网络接口地址
[vxlan]
enable_vxlan = true
local_ip = OVERLAY_INTERFACE_IP_ADDRESS
l2_population = true
修改securitygroup
[securitygroup]
# ...
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
修改系统配置
sudo vim /etc/sysctl.conf
加入两行
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
使之生效
sudo sysctl -p
修改配置文件
sudo vim /etc/neutron/l3_agent.ini
修改Default
[DEFAULT]
# ...
interface_driver = linuxbridge
修改配置文件
sudo vim /etc/neutron/dhcp_agent.ini
修改Default
[DEFAULT]
# ...
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
修改配置文件
sudo vim /etc/neutron/metadata_agent.ini
修改Default,注意METADATA_SECRET应该是和之前Compute节点配置的一样
[DEFAULT]
# ...
nova_metadata_host = controller
metadata_proxy_shared_secret = METADATA_SECRET
创建数据库
sudo 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
重启nova-api服务
sudo systemctl restart nova-api.service
sudo systemctl enable nova-api.service
启动网络服务
sudo systemctl restart neutron-server
sudo systemctl enable neutron-server
sudo systemctl restart neutron-linuxbridge-agent
sudo systemctl enable neutron-linuxbridge-agent
sudo systemctl restart neutron-dhcp-agent
sudo systemctl enable neutron-dhcp-agent
sudo systemctl restart neutron-metadata-agent
sudo systemctl enable neutron-metadata-agent
sudo systemctl restart neutron-l3-agent
sudo systemctl enable neutron-l3-agent
2. Compute节点
安装程序
sudo apt-get install neutron-linuxbridge-agent
修改配置文件
sudo vim /etc/neutron/neutron.conf
修改Default(注意替换RABBIT_PASS)
[DEFAULT]
# ...
transport_url = rabbit://openstack:RABBIT_PASS@controller
auth_strategy = keystone
修改keystone_authtoken(注意替换NEUTRON_PASS)
[keystone_authtoken]
# ...
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
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
这里选择Self-Service网络,修改配置文件
sudo vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
修改linux_bridge,这里PROVIDER_INTERFACE_NAME是连接互联网的物理网卡名称
[linux_bridge]
physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
修改vxlan,OVERLAY_INTERFACE_IP_ADDRESS是我们内部使用的网络接口地址
[vxlan]
enable_vxlan = true
local_ip = OVERLAY_INTERFACE_IP_ADDRESS
l2_population = true
修改securitygroup
[securitygroup]
# ...
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
修改系统配置
sudo vim /etc/sysctl.conf
加入两行
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
使之生效
sudo sysctl -p
重启服务
sudo systemctl restart nova-compute
sudo systemctl enable nova-compute
sudo systemctl restart neutron-linuxbridge-agent
sudo systemctl enable neutron-linuxbridge-agent
3. 验证服务
. admin-openrc
openstack network agent list
应该看到五个active的服务