目標(biāo)
緊接著《Ubuntu16手動(dòng)安裝OpenStack——nova篇》,本文我們來(lái)安裝neutron推汽,主要參考Networking service莫换、Install and configure for Ubuntu和OpenStack Queens : Configure Neutron。
neutron簡(jiǎn)介
OpenStack Networking(neutron)允許用戶創(chuàng)建和連接接口設(shè)備没讲,這些設(shè)備由其他OpenStack服務(wù)管理并連入網(wǎng)絡(luò)轰驳『裰溃可以實(shí)現(xiàn)插件以適應(yīng)不同的網(wǎng)絡(luò)設(shè)備和軟件,為OpenStack架構(gòu)和部署提供靈活性级解。
它包括以下組件:
neutron-server
接受API請(qǐng)求冒黑,并將請(qǐng)求通過(guò)路由找到適當(dāng)?shù)腛penStack Networking插件以進(jìn)行操作。
OpenStack Networking plug-ins and agents
插拔端口勤哗,創(chuàng)建網(wǎng)絡(luò)或子網(wǎng)抡爹,并提供IP尋址。這些插件和代理程序因特定云中使用的供應(yīng)商和技術(shù)而異芒划。OpenStack Networking附帶了很多插件和代理冬竟,可以用于思科虛擬和物理交換機(jī)欧穴,NEC OpenFlow產(chǎn)品,Open vSwitch泵殴,Linux橋接和VMware NSX產(chǎn)品涮帘。
公共代理是L3(第3層),DHCP(動(dòng)態(tài)主機(jī)IP尋址)和插件代理笑诅。
Messaging queue
大多數(shù)OpenStack Networking安裝使用messaging queue调缨,在neutron-server和各種代理之間傳遞信息。還用于存儲(chǔ)特定插件的網(wǎng)絡(luò)狀態(tài)吆你,算是一個(gè)數(shù)據(jù)庫(kù)弦叶。
OpenStack Networking主要與OpenStack Compute交互,為其實(shí)例提供網(wǎng)絡(luò)和連接妇多。
更多信息請(qǐng)參考Networking (neutron) concepts伤哺。
主機(jī)網(wǎng)絡(luò)
在每個(gè)節(jié)點(diǎn)上安裝操作系統(tǒng)后,必須配置網(wǎng)絡(luò)接口者祖。官方建議禁用任何自動(dòng)網(wǎng)絡(luò)管理工具默责,并手動(dòng)編輯配置文件。有關(guān)如何配置網(wǎng)絡(luò)的詳細(xì)信息咸包,請(qǐng)參閱文檔。
出于管理目的杖虾,所有節(jié)點(diǎn)都需要Internet訪問(wèn)烂瘫,例如程序包安裝,安全更新奇适,域名系統(tǒng)(DNS)和網(wǎng)絡(luò)時(shí)間協(xié)議(NTP)坟比。在大多數(shù)情況下,節(jié)點(diǎn)應(yīng)通過(guò)管理網(wǎng)絡(luò)接口獲得Internet訪問(wèn)嚷往。為了突出網(wǎng)絡(luò)分離的重要性葛账,示例體系結(jié)構(gòu)使用專用地址空間用于管理網(wǎng)絡(luò),并假設(shè)物理網(wǎng)絡(luò)基礎(chǔ)結(jié)構(gòu)通過(guò)網(wǎng)絡(luò)地址轉(zhuǎn)換(NAT)或其他方法提供Internet訪問(wèn)皮仁。
在provider網(wǎng)絡(luò)架構(gòu)中籍琳,所有實(shí)例都直接連接到provider網(wǎng)絡(luò)。在私網(wǎng)體系結(jié)構(gòu)中贷祈,實(shí)例可以連接到一個(gè)私網(wǎng)或多個(gè)私網(wǎng)趋急。私網(wǎng)可以完全屬于OpenStack,不接入外網(wǎng)势誊;也可以通過(guò)provider網(wǎng)絡(luò)接入外部網(wǎng)絡(luò)呜达。
控制節(jié)點(diǎn)
root用戶
為了避免權(quán)限問(wèn)題,建議切換到root用戶進(jìn)行操作(否則要加很多sudo)粟耻。
sudo -i
數(shù)據(jù)庫(kù)
1查近、登錄數(shù)據(jù)庫(kù)
mysql -uroot -p
眉踱,密碼為openstack。
2霜威、創(chuàng)建neutron數(shù)據(jù)庫(kù)
CREATE DATABASE neutron;
3谈喳、授權(quán)
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'openstack';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'openstack';
4、退出數(shù)據(jù)庫(kù)
exit;
證書和端點(diǎn)
1侥祭、使admin環(huán)境生效
. admin-openrc
2叁执、創(chuàng)建neutron用戶
openstack user create --domain default --password-prompt neutron
根據(jù)提示設(shè)置密碼為openstack。
3矮冬、添加admin角色給neutron用戶
openstack role add --project service --user neutron admin
4谈宛、創(chuàng)建neutron服務(wù)實(shí)體
openstack service create --name neutron --description "OpenStack Networking" network
5、創(chuàng)建網(wǎng)絡(luò)服務(wù)端點(diǎn)
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
安裝配置
1胎署、安裝相關(guān)組件
apt-get -y install neutron-server neutron-plugin-ml2 neutron-plugin-linuxbridge-agent neutron-l3-agent neutron-dhcp-agent neutron-metadata-agent python-neutronclient
2吆录、備份neutron.conf
mv /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak
3、vim /etc/neutron/neutron.conf
琼牧,新建neutron.conf內(nèi)容為:
[DEFAULT]
core_plugin = ml2
service_plugins = router
auth_strategy = keystone
state_path = /var/lib/neutron
dhcp_agent_notification = True
allow_overlapping_ips = True
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
# RabbitMQ connection info
transport_url = rabbit://openstack:openstack@controller
[agent]
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
# Keystone auth info
[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 = openstack
# MariaDB connection info
[database]
connection = mysql+pymysql://neutron:openstack@controller/neutron
# Nova connection info
[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 = openstack
[oslo_concurrency]
lock_path = $state_path/tmp
4恢筝、更改權(quán)限
chmod 640 /etc/neutron/neutron.conf
chgrp neutron /etc/neutron/neutron.conf
5、vi /etc/neutron/l3_agent.ini
巨坊,如下修改:
# line 17: add
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
6撬槽、vi /etc/neutron/dhcp_agent.ini
,如下修改:
# line 17: add
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
# line 28: uncomment
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
# line 37: uncomment and change
enable_isolated_metadata = true
7趾撵、vi /etc/neutron/metadata_agent.ini
侄柔,如下修改:
# line 22: uncomment and specify Nova API server
nova_metadata_host = controller
# line 34: uncomment and specify any secret key you like
metadata_proxy_shared_secret = openstack
# line 260: uncomment and specify Memcache Server
memcache_servers = controller:11211
8、vi /etc/neutron/plugins/ml2/ml2_conf.ini
占调,如下修改:
# line 129: add ( it's OK with no value for "tenant_network_types" (set later if need) )
[ml2]
type_drivers = flat,vlan,vxlan
tenant_network_types =
mechanism_drivers = linuxbridge,l2population
extension_drivers = port_security
# line 262: uncomment and add
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
# end line: uncomment
enable_ipset = True
9暂题、vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini
,如下修改:
# line 235: add own IP address
local_ip = 192.168.56.110
10究珊、vi /etc/nova/nova.conf
薪者,如下修改:
# add follows into [DEFAULT] section
use_neutron = True
linuxnet_interface_driver = nova.network.linux_net.LinuxBridgeInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
vif_plugging_is_fatal = True
vif_plugging_timeout = 300
# add follows to the end : Neutron auth info
# the value of metadata_proxy_shared_secret is the same with the one in metadata_agent.ini
[neutron]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = openstack
service_metadata_proxy = True
metadata_proxy_shared_secret = openstack
完成安裝
1、創(chuàng)建鏈接
ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
2剿涮、生成數(shù)據(jù)庫(kù)表結(jié)構(gòu)
su -s /bin/bash neutron -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head"
3言津、重啟網(wǎng)絡(luò)服務(wù)并設(shè)置開(kāi)機(jī)啟動(dòng)
for service in server l3-agent dhcp-agent metadata-agent linuxbridge-agent; do
systemctl restart neutron-$service
systemctl enable neutron-$service
done
4、重啟nova
systemctl restart nova-api nova-compute
5取试、查看網(wǎng)絡(luò)agent
openstack network agent list
如上圖纺念,看到4個(gè)agent,都在controller節(jié)點(diǎn)上想括。
計(jì)算節(jié)點(diǎn)
主要參考OpenStack Queens : Configure Neutron陷谱。
root用戶
為了避免權(quán)限問(wèn)題,建議切換到root用戶進(jìn)行操作(否則要加很多sudo)。
sudo -i
安裝配置
1烟逊、安裝組件
apt-get -y install neutron-common neutron-plugin-ml2 neutron-plugin-linuxbridge-agent
2渣窜、備份neutron.conf
mv /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak
3、vim /etc/neutron/neutron.conf
宪躯,新建neutron.conf如下:
[DEFAULT]
core_plugin = ml2
service_plugins = router
auth_strategy = keystone
state_path = /var/lib/neutron
allow_overlapping_ips = True
# RabbitMQ connection info
transport_url = rabbit://openstack:openstack@controller
[agent]
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
# Keystone auth info
[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 = openstack
[oslo_concurrency]
lock_path = $state_path/lock
4乔宿、修改權(quán)限
chmod 640 /etc/neutron/neutron.conf
chgrp neutron /etc/neutron/neutron.conf
5、vi /etc/neutron/plugins/ml2/ml2_conf.ini
访雪,如下修改:
# line 129: add ( it's OK with no value for "tenant_network_types" (set later if need) )
[ml2]
type_drivers = flat,vlan,vxlan
tenant_network_types =
mechanism_drivers = linuxbridge,l2population
extension_drivers = port_security
# line 262: uncomment and add
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
# end line: uncomment
enable_ipset = True
6详瑞、vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini
,如下修改:
# line 235: add own Ip address
local_ip = 192.168.56.111
7臣缀、vi /etc/nova/nova.conf
坝橡,如下修改:
# add follows into [DEFAULT] section
use_neutron = True
linuxnet_interface_driver = nova.network.linux_net.LinuxBridgeInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
vif_plugging_is_fatal = True
vif_plugging_timeout = 300
# add follows to the end: Neutron auth info
# the value of metadata_proxy_shared_secret is the same with the one in metadata_agent.ini
[neutron]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = openstack
service_metadata_proxy = True
metadata_proxy_shared_secret = openstack
8、創(chuàng)建鏈接
ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
9精置、重啟網(wǎng)絡(luò)服務(wù)
systemctl restart nova-compute neutron-linuxbridge-agent
10计寇、設(shè)置開(kāi)啟自啟動(dòng)
systemctl enable neutron-linuxbridge-agent
驗(yàn)證操作
在控制節(jié)點(diǎn)執(zhí)行以下命令。
1脂倦、使admin環(huán)境生效
. admin-openrc
2番宁、查看agents
openstack network agent list
如上圖,此時(shí)就能看到5個(gè)agent赖阻,其中4個(gè)在controller節(jié)點(diǎn)蝶押,1個(gè)在compute節(jié)點(diǎn)。