首先,看到标题可能比较晕,为什么又多了个网络节点,一般情况下,这里介绍的都是物理环境,一个控制节点,一个计算节点,但是我们虚拟机之间也存在内部网络,所以我们也需要有一个逻辑的网络节点,我们又经常将网络节点和计算节点放在一起,所以标题就成为了网络(计算)节点。
如果网络节点和计算节点放在一块,我们就需要在虚拟机添加一个新的网卡。
添加完毕之后,我们需要为新网卡赋予相关的网络信息
sm@computer:~$ sudo more /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.3.181
netmask 255.255.255.0
gateway 192.168.3.1
auto eth1
iface eth1 inet manual
up ip link set dev $IFACE up
down ip link set dev $IFACE down
我们看到,原来我们设置的网卡eth0的IP信息,现在我们为新网卡eth1设置相关信息。
一、预备工作【network】
1. 编辑/etc/sysctl.conf文件,
[ sudo vi /etc/sysctl.conf ]
更新设置如下:
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
2. 执行命令
sudo sysctl -p
sm@computer:~$ sudo sysctl -p
[sudo] password for sm:
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
二、安装网络服务neutron
1. 安装网络服务包
sudo apt-get install neutron-plugin-ml2 neutron-plugin-openvswitch-agent openvswitch-datapath-dkms neutron-l3-agent neutron-dhcp-agent
2. 编辑/etc/neutron/neutron.conf文件,设置数据库、消息服务及IP相关参数,
[ sudo vi /etc/neutron/neutron.conf ]
更新设置如下:
core_plugin = neutron.plugins.ml2.plugin.Ml2Plugin
service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin
auth_strategy = keystone
dhcp_agent_notification = True
rpc_backend = neutron.openstack.common.rpc.impl_kombu
control_exchange = neutron
rabbit_host = 192.168.3.180
rabbit_password = mq4smtest
rabbit_port = 5672
rabbit_userid = guest
auth_host = 192.168.3.180
auth_port = 35357
auth_protocol = http
auth_uri = http://192.168.3.180:5000
admin_tenant_name = service
admin_user = neutron
admin_password = neutron4smtest
signing_dir = $state_path/keystone-signing
notification_driver = neutron.openstack.common.notifier.rpc_notifier
service_provider=VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default
虽然打印出来的内容不多,但是neutron.conf文件有几百行的记录,包括注释信息,所以还需要用户保证在相关的section下面将正确的Value对应到相应的key上。
sm@computer:~$ sudo grep ^[a-z] /etc/neutron/neutron.conf
state_path = /var/lib/neutron
lock_path = $state_path/lock
core_plugin = neutron.plugins.ml2.plugin.Ml2Plugin
service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin
auth_strategy = keystone
dhcp_agent_notification = True
rpc_backend = neutron.openstack.common.rpc.impl_kombu
control_exchange = neutron
rabbit_host = 192.168.3.180
rabbit_password = mq4smtest
rabbit_port = 5672
rabbit_userid = guest
notification_driver = neutron.openstack.common.notifier.rpc_notifier
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
auth_host = 192.168.3.180
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = neutron
admin_password = neutron4smtest
signing_dir = $state_path/keystone-signing
service_provider=VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default
3. 编辑/etc/neutron/l3_agent.ini文件,
[ sudo vi /etc/neutron/l3_agent.ini ]
更新设置如下:
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
use_namespaces = True
external_network_bridge =br-ex
sm@computer:~$ sudo grep ^[a-z] /etc/neutron/l3_agent.ini
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
use_namespaces = True
external_network_bridge = br-ex
4. 编辑/etc/neutron/dhcp_agent.ini文件,
[ sudo vi /etc/neutron/dhcp_agent.ini ]
更新设置如下:
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
use_namespaces = True
sm@computer:~$ sudo grep ^[a-z] /etc/neutron/dhcp_agent.ini
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
use_namespaces = True
5. 编辑/etc/neutron/metadata_agent.ini文件,
[ sudo vi /etc/neutron/metadata_agent.ini ]
更新设置如下:
auth_url = http://192.168.3.180:35357/v2.0
admin_tenant_name = service
admin_user = neutron
admin_password = neutron4smtest
nova_metadata_ip = 192.168.3.180
nova_metadata_port = 8775
metadata_proxy_shared_secret = neutron4smtest
sm@computer:~$ sudo grep ^[a-z] /etc/neutron/metadata_agent.ini
auth_url = http://192.168.3.180:5000/v2.0
auth_region = RegionOne
admin_tenant_name = service
admin_user = neutron
admin_password = neutron4smtest
nova_metadata_ip = 192.168.3.180
nova_metadata_port = 8775
metadata_proxy_shared_secret = neutron4smtest
6. 编辑/etc/neutron/plugins/ml2/ml2_conf.ini文件
[ sudo vi /etc/neutron/plugins/ml2/ml2_conf.ini ]
更新设置如下:
type_drivers = flat,vlan,gre
tenant_network_types = vlan,gre
mechanism_drivers = openvswitch
# 添加到最后
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
sm@computer:~$ sudo grep ^[a-z] /etc/neutron/plugins/ml2/ml2_conf.ini
type_drivers = flat,vlan,gre
tenant_network_types = vlan,gre
mechanism_drivers = openvswitch
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
7. 重启服务
sudo service openvswitch-switch restart
sm@computer:~$ sudo service openvswitch-switch restart
openvswitch-switch stop/waiting
openvswitch-switch start/running
8. 重启计算服务
sudo service neutron-l3-agent restart
sudo service neutron-dhcp-agent restart
sudo service neutron-metadata-agent restart
sudo service neutron-plugin-openvswitch-agent restart
sm@computer:~$ sudo service neutron-l3-agent restart
neutron-l3-agent stop/waiting
neutron-l3-agent start/running, process 31490
sm@computer:~$ sudo service neutron-dhcp-agent restart
neutron-dhcp-agent stop/waiting
neutron-dhcp-agent start/running, process 31514
sm@computer:~$ sudo service neutron-metadata-agent restart
neutron-metadata-agent stop/waiting
neutron-metadata-agent start/running, process 31528
sm@computer:~$ sudo service neutron-plugin-openvswitch-agent restart
neutron-plugin-openvswitch-agent stop/waiting
neutron-plugin-openvswitch-agent start/running, process 31594