Neutron 为整个 OpenStack 环境提供网络支持,包括二层交换,三层路由,负载均衡,防火墙和
VPN 等。Neutron 提供了一个灵活的框架,通过配置,无论是开源还是商业软件都可以被用来实现
这些功能。下面我们来搭建neutron服务。
创建数据库
[[email protected] ~]# 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‘;
创建neutron用户
[[email protected] ~]# openstack user create --domain default --password NEUTRON_PASS neutron
将admin角色添加到neutron项目中
[[email protected] ~]# openstack role add --project service --user neutron admin
创建neutron实体
[[email protected] ~]# openstack service create --name neutron \
> --description "OpenStack Networking" network
创建neutron的api
[[email protected] ~]# openstack endpoint create --region RegionOne \
> network public http://wang02:9696
[[email protected] ~]# openstack endpoint create --region RegionOne \
> network internal http://wang02:9696
[[email protected] ~]# openstack endpoint create --region RegionOne \
> network admin http://wang02:9696
下载neutron的安装包
[[email protected] ~]# yum install openstack-neutron openstack-neutron-ml2 \
> openstack-neutron-linuxbridge ebtables -y
修改配置文件
<1> /etc/neutron/neutron.conf
[[email protected] ~]# sed -i ‘/^\[database\]$/a\
connection = mysql+pymysql://neutron:[email protected]/neutron‘ /etc/neutron/neutron.conf
[[email protected] ~]# sed -i ‘/^\[DEFAULT\]$/a\
core_plugin = ml2 \
service_plugins = \
transport_url = rabbit://openstack:[email protected] \
auth_strategy = keystone \
notify_nova_on_port_status_changes = true \
notify_nova_on_port_data_changes = true‘ /etc/neutron/neutron.conf
[[email protected] ~]# sed -i ‘/^\[keystone_authtoken\]$/a\
auth_uri = http://wang02:5000 \
auth_url = http://wang02:35357 \
memcached_servers = wang01:11211 \
auth_type = password \
project_domain_name = default \
user_domain_name = default \
project_name = service \
username = neutron \
password = neutron_pass‘ /etc/neutron/neutron.conf
[[email protected] ~]# sed -i ‘/^\[nova\]$/a\
auth_url = http://wang02:35357 \
auth_type = password \
project_domain_name = default \
user_domain_name = default \
region_name = RegionOne \
project_name = service \
username = nova \
password = nova_pass‘ /etc/neutron/neutron.conf
[[email protected] ~]# sed -i ‘/^\[oslo_concurrency\]$/a\
lock_path = /var/lib/neutron/tmp‘ /etc/neutron/neutron.conf
<2>
/etc/neutron/plugins/ml2/ml2_conf.ini
[[email protected] ~]# cp /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini.bak
[[email protected] ~]# cat /etc/neutron/plugins/ml2/ml2_conf.ini.bak | grep -v ^# | uniq > /etc/neutron/plugins/ml2/ml2_conf.ini
[[email protected] ~]# sed -i ‘/^\[ml2\]$/a\
type_drivers = flat,vlan,gre,vxlan,geneve \
tenant_network_types = flat,vlan,gre,vxlan,geneve \
mechanism_drivers = linuxbridge \
extension_drivers = port_security‘ /etc/neutron/plugins/ml2/ml2_conf.ini
[[email protected] ~]# sed -i ‘/^\[ml2_type_flat\]$/a\
flat_networks = provider‘ /etc/neutron/plugins/ml2/ml2_conf.ini
[[email protected] ~]# sed -i ‘/^\[securitygroup\]$/a\
enable_ipset = true‘ /etc/neutron/plugins/ml2/ml2_conf.ini
<3>
/etc/neutron/dhcp_agent.ini
[[email protected] ~]# cp /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.bak
[[email protected] ~]# cat /etc/neutron/dhcp_agent.ini.bak | grep -v ^# | uniq > /etc/neutron/dhcp_agent.ini
[[email protected] ~]# sed -i ‘/^\[DEFAULT\]$/a\
interface_driver = linuxbridge \
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq \
enable_isolated_metadata = true‘ /etc/neutron/dhcp_agent.ini
<5>/etc/neutron/plugins/ml2/linuxbridge_agent.ini
[[email protected] ~]#cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak
[[email protected] ~]#cat /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak | grep -v ^# | uniq > /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[[email protected] ~]#sed -i ‘/^\[linux_bridge\]$/a\
physical_interface_mappings = provider:eth0‘ /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[[email protected] ~]#sed -i ‘/^\[vxlan\]$/a\
enable_vxlan = false‘ /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[[email protected] ~]#sed -i ‘/^\[securitygroup\]$/a\
enable_security_group = true \
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver‘ /etc/neutron/plugins/ml2/linuxbridge_agent.ini
<4>/etc/neutron/metadata_agent.ini
[[email protected] ~]#cp /etc/neutron/metadata_agent.ini /etc/neutron/metadata_agent.ini.bak
[[email protected] ~]#cat /etc/neutron/metadata_agent.ini.bak | grep -v ^# | uniq > /etc/neutron/metadata_agent.ini
[[email protected] ~]#sed -i ‘/^\[DEFAULT\]$/a\
nova_metadata_ip = ctrl.ryb.edu \
metadata_proxy_shared_secret = metadata_secret‘ /etc/neutron/metadata_agent.ini
[[email protected] ~]#sed -i ‘/^\[neutron\]$/a\
url = http://ctrl.ryb.edu:9696 \
auth_url = http://ctrl.ryb.edu: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‘ /etc/nova/nova.conf
[[email protected] ~]#ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
同步数据库
[[email protected] ~]# 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服务
[[email protected] ~]# systemctl restart openstack-nova-api.service
启动NEUTRON服务
[[email protected] ~]# systemctl enable neutron-server.service \
neutron-linuxbridge-agent.service \
neutron-dhcp-agent.service \
neutron-metadata-agent.service
[[email protected] ~]# systemctl restart neutron-server.service \
neutron-linuxbridge-agent.service \
neutron-dhcp-agent.service \
neutron-metadata-agent.service
计算节点配置
下载安装包
[r[email protected] ~] yum install openstack-neutron-linuxbridge ebtables ipset
修改配置文件
[[email protected] ~] cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak
[[email protected] ~] cat /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak | grep -v ^# | uniq > /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[[email protected] ~] sed -i ‘/^\[linux_bridge\]$/a\
physical_interface_mappings = provider:eth0‘ /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[[email protected] ~] sed -i ‘/^\[vxlan\]$/a\
enable_vxlan = false‘ /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[[email protected] ~] sed -i ‘/^\[securitygroup\]$/a\
enable_security_group = true \
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver‘ /etc/neutron/plugins/ml2/linuxbridge_agent.ini
修改NOVA的配置文件
[[email protected] ~] sed -i ‘/^\[neutron\]$/a\
url = http://wang02:9696 \
auth_url = http://wang02:35357 \
auth_type = password \
project_domain_name = default \
user_domain_name = default \
region_name = RegionOne \
project_name = service \
username = neutron \
password = neutron_pass‘ /etc/nova/nova.conf
重启NOVA服务
[[email protected] ~] systemctl restart openstack-nova-compute.service
启动neutron服务
[[email protected] ~] systemctl enable neutron-linuxbridge-agent.service
[[email protected] ~] systemctl restart neutron-linuxbridge-agent.service
控制节点验证服务
[[email protected] ~]# openstack network agent list