OpenStack安装流程(juno版)- 添加网络服务(neutron)
在controller节点上安装和配置
创建nova的数据库,服务证书和API端点
- 创建数据库:
使用root身份进入数据库:$ mysql -u root -p
创建nova数据库:
<pre>CREATE DATABASE neutron;
</pre>把neutron数据库的访问权限赋予名为neutron,来自任何主机地址的用户,并设定访问密码为NEUTRON_DBPASS(替换为合适的密码):
<pre>GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'NEUTRON_DBPASS';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'NEUTRON_DBPASS';</pre>
退出数据库。
- 启动
admin
证书:$ source admin-openrc.sh
- 创建服务证书:
创建neutron
用户:
<pre>$ keystone user-create --name neutron --pass NEUTRON_PASS
Property | Value |
---|---|
enabled | True |
id | 03fdaa93a85b4879a898d031947b81af |
name | neutron |
username | neutron |
+----------+----------------------------------+</pre>
用合适的密码代替NEUTRON_PASS。
把admin
角色赋予给neutron
用户:$ keystone user-role-add --user neutron --tenant service --role admin
这条命令不产生输出显示。
创建neutron
服务实体:
<pre>$ keystone service-create --name neutron --type network \
--description "OpenStack Networking" | |
---|---|
Property | Value |
description | OpenStack Networking |
enabled | True |
id | d3cf8211db414c069701f39e778d9765 |
name | neutron |
type | network |
+-------------+----------------------------------+</pre>
- 创建网络服务的API端点:
<pre>$ keystone endpoint-create \
--service-id $(keystone service-list | awk '/ network / {print $2}') \
--publicurl http://controller:9696 \
--adminurl http://controller:9696 \
--internalurl http://controller:9696 \
--region regionOne | |
---|---|
Property | Value |
adminurl | http://controller:9696 |
id | eb7fd6b67e4d4479886d164486a3fb71 |
internalurl | http://controller:9696 |
publicurl | http://controller:9696 |
region | regionOne |
service_id | d3cf8211db414c069701f39e778d9765 |
+-------------+----------------------------------+</pre>
安装neutron组件
# apt-get install neutron-server neutron-plugin-ml2 python-neutronclient
配置网络服务组件
编辑# vi /etc/neutron/neutron.conf
文件:
在[database]
部分,设定数据库的访问选项,需把原始设定注释掉:
<pre>[database]<br>...<br>connection = mysql://neutron:NEUTRON_DBPASS@controller/neutron
</pre>
NEUTRON_DBPASS为创建neutron数据库时设立的密码。
在[DEFAULT]
部分,设定RabbitMQ的访问选项:
<pre>[DEFAULT]<br>...<br>rpc_backend = rabbit<br>rabbit_host = controller<br>rabbit_password = RABBIT_PASS
</pre>
RABBIT_PASS为RabbitMQ guest账户的密码。
在[DEFAULT]
和[keystone_authtoken]
部分,设定认证服务的访问选项:
<pre>[DEFAULT]<br>...<br>auth_strategy = keystone
</pre>
<pre>[keystone_authtoken]<br>...<br>auth_uri = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:5000/v2.0<br>identity_uri = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:35357<br>admin_tenant_name = service<br>admin_user = neutron<br>admin_password = NEUTRON_PASS
</pre>
NEUTRON_PASS为创建neutron用户时使用的密码。在[keystone_authtoken]部分,注释掉 auth_host,auth_port,和auth_protocol的选项,因为identity_uri选项是直接代替它们的。
在[DEFAULT]
部分,开启Modular Layer 2(ML2)plug-in选项,设定router service和overlapping IP addresses选项:
<pre>[DEFAULT]<br>...<br>core_plugin = ml2<br>service_plugins = router<br>allow_overlapping_ips = True
</pre>
在[DEFAULT]
部分,设定网络服务可以通知计算服务网络拓扑的变化:
<pre>[DEFAULT]<br>...<br>notify_nova_on_port_status_changes = True<br>notify_nova_on_port_data_changes = True<br>nova_url = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:8774/v2<br>nova_admin_auth_url = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:35357/v2.0<br>nova_region_name = regionOne<br>nova_admin_username = nova<br>nova_admin_tenant_id = SERVICE_TENANT_ID<br>nova_admin_password = NOVA_PASS
</pre>
NEUTRON_PASS为创建neutron用户时使用的密码。SERVICE_TENANT_ID为认证服务中service
租户的ID,可以通过以下命令取得:
<pre>$ source admin-openrc.sh
$ keystone tenant-get service | |
---|---|
Property | Value |
description | Service Tenant |
enabled | True |
id | 5ab4d5c513f543cfbf8e3be97f5df5fb |
name | service |
+-------------+----------------------------------+</pre>
在[DEFAULT]
部分,开启“详细输出日志”选项:
<pre>[DEFAULT]<br>...<br>verbose = True
</pre>
配置 Modular Layer 2(ML2)plug-in
ML2 plug-in使用Open vSwitch(OVS)机制(agent)来创建虚拟网络框架。由于controller节点不处理实例之间的网络通信,故不需要OVS组件。
编辑# vi /etc/neutron/plugins/ml2/ml2_conf.ini
文件:
在[ml2]
部分,启用flat和generic routing encapsulation(GRE)网络类型的驱动( network type drivers),GRE 租户网络和OVS机制的驱动:
<pre>[ml2]<br>...<br>type_drivers = flat,gre<br>tenant_network_types = gre<br>mechanism_drivers = openvswitch
</pre>
在[ml2_type_gre]
部分,配置tunnel ID的范围:
<pre>[ml2_type_gre]<br>...<br>tunnel_id_ranges = 1:1000
</pre>
在[securitygroup]
部分,启用security groups,ipset, and configure,设定OVS iptables firewall driver:
<pre>[securitygroup]<br>...<br>enable_security_group = True<br>enable_ipset = True<br>firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
</pre>
配置计算服务使之使用网络服务
编辑# vi /etc/nova/nova.conf
文件:
在[DEFAULT]
部分,设定API和驱动:
<pre>[DEFAULT]<br>...<br>network_api_class = nova.network.neutronv2.api.API<br>security_group_api = neutron<br>linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver<br>firewall_driver = nova.virt.firewall.NoopFirewallDriver
</pre>
在[neutron]
部分,设定访问参数:
<pre>[neutron]<br>...<br>url = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:9696<br>auth_strategy = keystone<br>admin_auth_url = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:35357/v2.0<br>admin_tenant_name = service<br>admin_username = neutron<br>admin_password = NEUTRON_PASS
</pre>
NEUTRON_PASS为创建neutron用户时使用的密码。
完成安装
- 同步数据库:
# neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade juno
- 重启计算服务:
# service nova-api restart
# service nova-scheduler restart
# service nova-conductor restart
- 重启网络服务:
# service neutron-server restart
验证操作
- 启动
admin
证书:$ source admin-openrc.sh
- 显示装载的扩展列表,验证neutron-server进程已成功启动:
<pre>$ neutron ext-list
alias | name |
---|---|
security-group | security-group |
l3_agent_scheduler | L3 Agent Scheduler |
ext-gw-mode | Neutron L3 Configurable external gateway mode |
binding | Port Binding |
provider | Provider Network |
agent | agent |
quotas | Quota management support |
dhcp_agent_scheduler | DHCP Agent Scheduler |
l3-ha | HA Router extension |
multi-provider | Multi Provider Network |
external-net | Neutron external network |
router | Neutron L3 Router |
allowed-address-pairs | Allowed Address Pairs |
extraroute | Neutron Extra Route |
extra_dhcp_opt | Neutron Extra DHCP opts |
dvr | Distributed Virtual Router |
+-----------------------+-----------------------------------------------+</pre>
在network节点上安装和配置
设定kernel networking参数:
- 编辑
# vi /etc/sysctl.conf
文件:
<pre>net.ipv4.ip_forward=1<br>net.ipv4.conf.all.rp_filter=0<br>net.ipv4.conf.default.rp_filter=0
</pre>
- 使上述变化生效:
# sysctl -p
安装网络服务组件
# apt-get install neutron-plugin-ml2 neutron-plugin-openvswitch-agent \<br>neutron-l3-agent neutron-dhcp-agent
配置网络服务的通用组件
编辑# vi /etc/neutron/neutron.conf
文件:
在[database]
部分,注释掉connection选项,因为network节点不需要直接访问数据库。
在[DEFAULT]
部分,设定RabbitMQ的访问选项:
<pre>[DEFAULT]<br>...<br>rpc_backend = rabbit<br>rabbit_host = controller<br>rabbit_password = RABBIT_PASS
</pre>
RABBIT_PASS为RabbitMQ guest账户的密码。
在[DEFAULT]
和[keystone_authtoken]
部分,设定认证服务的访问选项:
<pre>[DEFAULT]<br>...<br>auth_strategy = keystone
</pre>
<pre>[keystone_authtoken]<br>...<br>auth_uri = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:5000/v2.0<br>identity_uri = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:35357<br>admin_tenant_name = service<br>admin_user = neutron<br>admin_password = NEUTRON_PASS
</pre>
NEUTRON_PASS为创建neutron用户时使用的密码。在[keystone_authtoken]部分,注释掉 auth_host,auth_port,和auth_protocol的选项,因为identity_uri选项是直接代替它们的。
在[DEFAULT]
部分,开启Modular Layer 2(ML2)plug-in选项,设定router service和overlapping IP addresses选项:
<pre>[DEFAULT]<br>...<br>core_plugin = ml2<br>service_plugins = router<br>allow_overlapping_ips = True
</pre>
在[DEFAULT]
部分,开启“详细输出日志”选项:
<pre>[DEFAULT]<br>...<br>verbose = True
</pre>
设定Modular Layer 2(ML2)plug-in
编辑# vi /etc/neutron/plugins/ml2/ml2_conf.ini
文件:
在[ml2]
部分,启用flat和generic routing encapsulation(GRE)网络类型的驱动( network type drivers),GRE 租户网络和OVS机制的驱动:
<pre>[ml2]<br>...<br>type_drivers = flat,gre<br>tenant_network_types = gre<br>mechanism_drivers = openvswitch
</pre>
在[ml2_type_flat]
部分,设定external flat provider network:
<pre>[ml2_type_flat]<br>...<br>flat_networks = external
</pre>
在[ml2_type_gre]
部分,设定tunnel ID范围:
<pre>[ml2_type_gre]<br>...<br>tunnel_id_ranges = 1:1000
</pre>
在[securitygroup]
部分,启用security groups,ipset, and configure,设定OVS iptables firewall driver:
<pre>[securitygroup]<br>...<br>enable_security_group = True<br>enable_ipset = True<br>firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
</pre>
在[ovs]
部分,启用tunnel,设定local tunnel endpoint,把external flat provider network和br-ex external network brigde绑定起来:
<pre>[ovs]<br>...<br>local_ip = INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS<br>enable_tunneling = True<br>bridge_mappings = external:br-ex
</pre>
INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS为network节点在tunnel network中的IP地址。
在[agent]
部分,启用GRE tunnels:
<pre>[agent]<br>...<br>tunnel_types = gre
</pre>
设定Layer-3(L3)agent
Layer-3(L3)agent为虚拟网络提供了routing service。
编辑# vi /etc/neutron/l3_agent.ini
文件:
在[DEFAULT]
部分,设定驱动,启用network namespace,设定external network bridge,启用deletion of defunct router namespaces:
<pre>[DEFAULT]<br>...<br>interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver<br>use_namespaces = True<br>external_network_bridge = br-ex<br>router_delete_namespaces = True
</pre>
在[DEFAULT]
部分,开启“详细输出日志”选项:
<pre>[DEFAULT]<br>...<br>verbose = True
</pre>
设定DHCP agent
DHCP agent为虚拟网络提供了DHCP服务。
编辑# vi /etc/neutron/dhcp_agent.ini
文件:
在[DEFAULT]
部分,设定驱动,启用namespaces,启用deletion of defunct DHCP namespaces:
<pre>[DEFAULT]<br>...<br>interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver<br>dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq<br>use_namespaces = True<br>dhcp_delete_namespaces = True
</pre>
在[DEFAULT]
部分,开启“详细输出日志”选项:
<pre>[DEFAULT]<br>...<br>verbose = True
</pre>
设定metadata agent
metadata agent提供了配置信息,比如实例的证书。
- 编辑
# vi /etc/neutron/metadata_agent.ini
文件:在
[DEFAULT]
部分,设定访问参数:
<pre>[DEFAULT]
...
auth_url = http://controller:5000/v2.0
auth_region = regionOne
admin_tenant_name = service
admin_user = neutron
admin_password = NEUTRON_PASS</pre>
NEUTRON_PASS为创建neutron用户时使用的密码。
在[DEFAULT]
部分,设定metadata host:
<pre>[DEFAULT]<br>...<br>nova_metadata_ip = controller
</pre>
在[DEFAULT]
部分,设定metadata proxy shared secret:
<pre>[DEFAULT]<br>...<br>metadata_proxy_shared_secret = METADATA_SECRET
</pre>
把METADATA_SECRET替换为合适的密码。
在[DEFAULT]
部分,开启“详细输出日志”选项:
<pre>[DEFAULT]<br>...<br>verbose = True
</pre>
- 在controller节点,编辑
# vi /etc/nova/nova.conf
文件:
在[neutron]
部分,启用metadata proxy,设定密码选项:
<pre>[neutron]
...
service_metadata_proxy = True
metadata_proxy_shared_secret = METADATA_SECRET</pre>
把METADATA_SECRET替换为metadata proxy中设定的密码。
- 在controller节点,重启计算的API服务:
# service nova-api restart
设定Open vSwitch(OVS)服务:
OVS服务为实例提供虚拟网络框架。integration bridge br-int处理内网通信,external bridge br-ex处理外网通信。external bridge需要物理外网提供一个访问端口,来连接物理网络和虚拟网络。
- 重启OVS服务:
# service openvswitch-switch restart
- 添加external bridge:
# ovs-vsctl add-br br-ex
- 把端口添加到external bridge中,来连接物理外网:
# ovs-vsctl add-port br-ex INTERFACE_NAME
INTERFACE_NAME替换为实际的interface name,本文的网络配置方案下为eth2
完成安装
重启网络服务:# service neutron-plugin-openvswitch-agent restart
# service neutron-l3-agent restart
# service neutron-dhcp-agent restart
# service neutron-metadata-agent restart
验证操作
在controller节点上进行如下操作。
- 启动
admin
证书:$ source admin-openrc.sh
- 显示agent列表,验证neutron agent已成功启动:
<pre>$ neutron agent-list
id | agent_type | host | alive | admin_state_up | binary |
---|---|---|---|---|---|
2be5bff5-2d4b-4308-9d8e-218f86f0884e | DHCP agent | network | :-) | True | neutron-dhcp-agent |
35e5874c-0e45-44b1-95e5-f5ac94a1b9d5 | L3 agent | network | :-) | True | neutron-l3-agent |
7debcbec-b316-490e-baa1-1a6bb74fcbbb | Open vSwitch agent | network | :-) | True | neutron-openvswitch-agent |
c35af91b-9f6b-4632-bc10-aa67c8a75ae1 | Metadata agent | network | :-) | True | neutron-metadata-agent |
+--------------------------------------+--------------------+---------+-------+----------------+---------------------------+</pre>
在compute节点上安装和配置
设定kernel networking参数:
- 编辑
# vi /etc/sysctl.conf
文件:
<pre>net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0</pre>
- 使上述变化生效:
# sysctl -p
安装网络服务组件
# apt-get install neutron-plugin-ml2 neutron-plugin-openvswitch-agent
配置网络服务的通用组件
编辑# vi /etc/neutron/neutron.conf
文件:
在[database]
部分,注释掉connection选项,因为compute节点不需要直接访问数据库。
在[DEFAULT]
部分,设定RabbitMQ的访问选项:
<pre>[DEFAULT]<br>...<br>rpc_backend = rabbit<br>rabbit_host = controller<br>rabbit_password = RABBIT_PASS
</pre>
RABBIT_PASS为RabbitMQ guest账户的密码。
在[DEFAULT]
和[keystone_authtoken]
部分,设定认证服务的访问选项:
<pre>[DEFAULT]<br>...<br>auth_strategy = keystone
</pre>
<pre>[keystone_authtoken]<br>...<br>auth_uri = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:5000/v2.0<br>identity_uri = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:35357<br>admin_tenant_name = service<br>admin_user = neutron<br>admin_password = NEUTRON_PASS
</pre>
NEUTRON_PASS为创建neutron用户时使用的密码。在[keystone_authtoken]部分,注释掉 auth_host,auth_port,和auth_protocol的选项,因为identity_uri选项是直接代替它们的。
在[DEFAULT]
部分,开启Modular Layer 2(ML2)plug-in选项,设定router service和overlapping IP addresses选项:
<pre>[DEFAULT]<br>...<br>core_plugin = ml2<br>service_plugins = router<br>allow_overlapping_ips = True
</pre>
在[DEFAULT]
部分,开启“详细输出日志”选项:
<pre>[DEFAULT]<br>...<br>verbose = True
</pre>
设定Modular Layer 2(ML2)plug-in
编辑# vi /etc/neutron/plugins/ml2/ml2_conf.ini
文件:
在[ml2]
部分,启用flat和generic routing encapsulation(GRE)网络类型的驱动( network type drivers),GRE 租户网络和OVS机制的驱动:
<pre>[ml2]<br>...<br>type_drivers = flat,gre<br>tenant_network_types = gre<br>mechanism_drivers = openvswitch
</pre>
在[ml2_type_gre]
部分,设定tunnel ID范围:
<pre>[ml2_type_gre]<br>...<br>tunnel_id_ranges = 1:1000
</pre>
在[securitygroup]
部分,启用security groups,ipset, and configure,设定OVS iptables firewall driver:
<pre>[securitygroup]<br>...<br>enable_security_group = True<br>enable_ipset = True<br>firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
</pre>
在[ovs]
部分,启用tunnel,设定local tunnel endpoint,把external flat provider network和br-ex external network brigde绑定起来:
<pre>[ovs]<br>...<br>local_ip = INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS<br>enable_tunneling = True<br>bridge_mappings = external:br-ex
</pre>
INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS为network节点在tunnel network中的IP地址。
在[agent]
部分,启用GRE tunnels:
<pre>[agent]<br>...<br>tunnel_types = gre
</pre>
配置Open vSwitch(OVS)服务
重启OVS服务:# service openvswitch-switch restart
配置计算服务使之使用网络服务
编辑# vi /etc/nova/nova.conf
文件:
在[DEFAULT]
部分,设定API和驱动:
<pre>[DEFAULT]<br>...<br>network_api_class = nova.network.neutronv2.api.API<br>security_group_api = neutron<br>linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver<br>firewall_driver = nova.virt.firewall.NoopFirewallDriver
</pre>
在[neutron]
部分,设定访问参数:
<pre>[neutron]<br>...<br>url = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:9696<br>auth_strategy = keystone<br>admin_auth_url = <a href="http://controller" rel="nofollow noreferrer">http://controller</a>:35357/v2.0<br>admin_tenant_name = service<br>admin_username = neutron<br>admin_password = NEUTRON_PASS
</pre>
NEUTRON_PASS为创建neutron用户时使用的密码。
完成安装
- 重启计算服务:
# service nova-compute restart
- 重启OVS agent:
# service neutron-plugin-openvswitch-agent restart
验证操作
在controller节点上执行如下操作:
- 启动
admin
证书:$ source admin-openrc.sh
- 显示agent列表,验证neutron agent已成功启动:
<pre>$ neutron agent-list
id | agent_type | host | alive | admin_state_up | binary |
---|---|---|---|---|---|
03586491-fbf0-495f-93d9-77704ffdba61 | Open vSwitch agent | compute | :-) | True | neutron-openvswitch-agent |
2be5bff5-2d4b-4308-9d8e-218f86f0884e | DHCP agent | network | xxx | True | neutron-dhcp-agent |
35e5874c-0e45-44b1-95e5-f5ac94a1b9d5 | L3 agent | network | xxx | True | neutron-l3-agent |
7debcbec-b316-490e-baa1-1a6bb74fcbbb | Open vSwitch agent | network | xxx | True | neutron-openvswitch-agent |
c35af91b-9f6b-4632-bc10-aa67c8a75ae1 | Metadata agent | network | xxx | True | neutron-metadata-agent |
+--------------------------------------+--------------------+---------+-------+----------------+---------------------------+</pre>