在控制節點上執行
controllerHost='controller'
MYSQL_PASSWD='m4r!adbOP'
RABBIT_PASSWD='0penstackRMQ'
NOVA_PASSWD='nova1234!'
NEUTRON_PASSWD='neutron1234!'
controllerTunnelIP='172.31.240.49'
controllerProviderInterface='ens224'
1.創建數據庫
mysql -uroot -p${MYSQL_PASSWD} << EOF
DROP DATABASE IF EXISTS neutron;
CREATE DATABASE neutron;
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY '${NEUTRON_PASSWD}';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY '${NEUTRON_PASSWD}';
EOF
2.創建認證用戶並授權
source ~/admin-openrc
openstack user create --domain default --password ${NEUTRON_PASSWD} neutron
openstack role add --project service --user neutron admin
3.創建服務實體和端點
openstack service create --name neutron --description "OpenStack Networking" network
openstack endpoint create --region RegionOne network public http://${controllerHost}:9696
openstack endpoint create --region RegionOne network admin http://${controllerHost}:9696
openstack endpoint create --region RegionOne network internal http://${controllerHost}:9696
4.安裝neutron服務
yum -y install openstack-neutron openstack-neutron-ml2 ebtables ipset
5.配置neutron服務訪問數據庫
openstack-config --set /etc/neutron/neutron.conf database connection mysql+pymysql://neutron:${NEUTRON_PASSWD}@${controllerHost}/neutron
6.配置neutron服務訪問memcached
openstack-config --set /etc/neutron/neutron.conf cache backend oslo_cache.memcache_pool
openstack-config --set /etc/neutron/neutron.conf cache enabled true
openstack-config --set /etc/neutron/neutron.conf cache memcache_servers ${controllerHost}:11211
7.配置neutron服務訪問rabbitmq
openstack-config --set /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:${RABBIT_PASSWD}@${controllerHost}:5672
8.配置neutron服務訪問認證服務
openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_uri http://${controllerHost}:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://${controllerHost}:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password ${NEUTRON_PASSWD}
9.配置neutron服務啓用ML2插件,路由器服務和浮動IP功能
openstack-config --set /etc/neutron/neutron.conf DEFAULT core_plugin ml2
openstack-config --set /etc/neutron/neutron.conf DEFAULT service_plugins router
openstack-config --set /etc/neutron/neutron.conf DEFAULT allow_overlapping_ips true
10.配置neutron服務將網絡拓撲變化的消息通知給計算節點
openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_status_changes true
openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_data_changes true
11.配置neutron服務使用nova身份訪問認證服務
openstack-config --set /etc/neutron/neutron.conf nova auth_url http://${controllerHost}:5000
openstack-config --set /etc/neutron/neutron.conf nova project_domain_name default
openstack-config --set /etc/neutron/neutron.conf nova user_domain_name default
openstack-config --set /etc/neutron/neutron.conf nova region_name RegionOne
openstack-config --set /etc/neutron/neutron.conf nova project_name service
openstack-config --set /etc/neutron/neutron.conf nova auth_type password
openstack-config --set /etc/neutron/neutron.conf nova username nova
openstack-config --set /etc/neutron/neutron.conf nova password ${NOVA_PASSWD}
12.配置neutron中oslo庫的鎖定路徑
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp
13.配置DHCP代理服務加載驅動程序並取消元數據隔離
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT dhcp_driver neutron.agent.linux.dhcp.Dnsmasq
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT enable_isolated_metadata true
14.配置元數據代理服務的共享密鑰和位置
openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT nova_metadata_host ${controllerHost}
openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT metadata_proxy_shared_secret 123456
15.創建neutron-server服務啓動時需要的軟連接
ln -sv /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
16.使能網橋調用內核過濾器netfilter功能
sed -i "/net.bridge.bridge-nf-call-ip6tables/c\net.bridge.bridge-nf-call-ip6tables = 1" /usr/lib/sysctl.d/00-system.conf
sed -i "/net.bridge.bridge-nf-call-iptables/c\net.bridge.bridge-nf-call-iptables = 1" /usr/lib/sysctl.d/00-system.conf
sysctl -p
17.配置nova服務使能對neutron服務的支持
openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron true
openstack-config --set /etc/nova/nova.conf neutron url http://${controllerHost}:9696
openstack-config --set /etc/nova/nova.conf neutron auth_url http://${controllerHost}:5000
openstack-config --set /etc/nova/nova.conf neutron project_domain_name default
openstack-config --set /etc/nova/nova.conf neutron user_domain_name default
openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne
openstack-config --set /etc/nova/nova.conf neutron project_name service
openstack-config --set /etc/nova/nova.conf neutron auth_type password
openstack-config --set /etc/nova/nova.conf neutron username neutron
openstack-config --set /etc/nova/nova.conf neutron password ${NEUTRON_PASSWD}
18.配置nova服務使能對元數據代理的支持
openstack-config --set /etc/nova/nova.conf neutron service_metadata_proxy true
openstack-config --set /etc/nova/nova.conf neutron metadata_proxy_shared_secret 123456
19.重啓nova服務
systemctl restart openstack-nova-api.service && systemctl status openstack-nova-api.service
在控制節點上使用linuxbridge作爲虛擬交換機
20.安裝linuxbridge組件
yum -y install openstack-neutron-linuxbridge
21.配置L3代理服務的接口驅動爲Linux網橋驅動
openstack-config --set /etc/neutron/l3_agent.ini DEFAULT interface_driver linuxbridge
22.配置DHCP代理服務的接口驅動爲Linux網橋驅動
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT interface_driver linuxbridge
23.啓用flat和vxlan網絡
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vxlan
24.啓用Linux網橋和L2集羣機制
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers linuxbridge,l2population
25.在端口上使能安全擴展驅動
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security
26.開啓安全組功能,並加載防火牆驅動程序
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
27.將提供商網絡設置爲flat並關聯通向提供商網絡的物理接口
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks provider
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:${controllerProviderInterface}
28.將租戶網絡設置成VXLAN並設置VXLAN的VNI範圍
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vxlan vni_ranges 1:1000
29.創建vxlan隧道並設置隧道的物理接口IP
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip ${controllerTunnelIP}
30.同步數據庫
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
31.啓動neutron服務
systemctl enable neutron-server.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service neutron-linuxbridge-agent.service
systemctl start neutron-server.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service neutron-linuxbridge-agent.service
systemctl status neutron-server.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service neutron-linuxbridge-agent.service
在控制節點上使用OVS作爲虛擬交換機
20.安裝openvswitch組件
yum -y install openstack-neutron-openvswitch
21.配置L3代理服務的接口驅動爲OVS網橋驅動並關聯外部網橋
openstack-config --set /etc/neutron/l3_agent.ini DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
openstack-config --set /etc/neutron/l3_agent.ini DEFAULT external_network_bridge br-ex
22.配置DHCP代理服務的接口驅動爲OVS網橋驅動
openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
23.啓用flat和vxlan網絡
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vxlan
24.啓用OVS網橋和L2集羣機制
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers openvswitch,l2population
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini agent l2_population True
25.在端口上使能安全擴展驅動
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security
26.開啓安全組功能,並加載防火牆驅動程序
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini securitygroup enable_security_group True
27.將提供商網絡設置爲flat並關聯通向提供商網絡的外部網橋
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks provider
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs bridge_mappings provider:br-ex
28.將租戶網絡設置成VXLAN並設置VXLAN的VNI範圍
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vxlan vni_ranges 1:1000
29.創建vxlan隧道並設置隧道的物理接口IP
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini agent tunnel_types vxlan
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs integration_bridge br-int
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs tunnel_bridge br-tun
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs enable_tunneling True
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs local_ip ${controllerTunnelIP}
30.同步數據庫
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
31.創建br-ex網橋並添加通向提供商網絡的物理接口
ovs-vsctl add-br br-ex
ovs-vsctl add-port br-ex ${controllerProviderInterface}
32.啓動neutron服務
systemctl enable neutron-server.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service neutron-openvswitch-agent.service
systemctl start neutron-server.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service neutron-openvswitch-agent.service
systemctl status neutron-server.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service neutron-openvswitch-agent.service
在計算節點上執行
controllerHost='controller'
RABBIT_PASSWD='0penstackRMQ'
NEUTRON_PASSWD='neutron1234!'
computeTunnelIP='172.31.240.45'
1.安裝neutron組件
yum -y install openstack-neutron-ml2 ebtables ipset
2.配置neutron服務訪問memcached服務
openstack-config --set /etc/neutron/neutron.conf cache backend oslo_cache.memcache_pool
openstack-config --set /etc/neutron/neutron.conf cache enabled true
openstack-config --set /etc/neutron/neutron.conf cache memcache_servers ${controllerHost}:11211
3.配置neutron服務訪問rabbitmq服務
openstack-config --set /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:${RABBIT_PASSWD}@${controllerHost}:5672
4.配置neutron服務訪問認證服務
openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_uri http://${controllerHost}:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://${controllerHost}:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password ${NEUTRON_PASSWD}
5.配置neutron中oslo庫的鎖定路徑
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp
6.使能網橋調用內核過濾器netfilter功能
sed -i "/net.bridge.bridge-nf-call-ip6tables/c\net.bridge.bridge-nf-call-ip6tables = 1" /usr/lib/sysctl.d/00-system.conf
sed -i "/net.bridge.bridge-nf-call-iptables/c\net.bridge.bridge-nf-call-iptables = 1" /usr/lib/sysctl.d/00-system.conf
sysctl -p
7.配置nova服務使能對neutron服務的支持
openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron true
openstack-config --set /etc/nova/nova.conf neutron url http://${controllerHost}:9696
openstack-config --set /etc/nova/nova.conf neutron auth_url http://${controllerHost}:5000
openstack-config --set /etc/nova/nova.conf neutron project_domain_name default
openstack-config --set /etc/nova/nova.conf neutron user_domain_name default
openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne
openstack-config --set /etc/nova/nova.conf neutron project_name service
openstack-config --set /etc/nova/nova.conf neutron auth_type password
openstack-config --set /etc/nova/nova.conf neutron username neutron
openstack-config --set /etc/nova/nova.conf neutron password ${NEUTRON_PASSWD}
8.重啓nova服務
systemctl restart openstack-nova-api.service && systemctl status openstack-nova-api.service
在計算節點上使用linuxbridge作爲虛擬交換機
9.安裝linuxbridge組件
yum -y install openstack-neutron-linuxbridge
10.開啓安全組功能,並加載防火牆驅動程序
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
11.啓動L2集羣機制
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
12.創建vxlan隧道並設置隧道的物理接口IP
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip ${computeTunnelIP}
13.啓動neutron服務
systemctl enable neutron-linuxbridge-agent.service
systemctl restart neutron-linuxbridge-agent.service
systemctl status neutron-linuxbridge-agent.service
在計算節點上使用OVS作爲虛擬交換機
9.安裝openvswitch組件
yum -y install openstack-neutron-openvswitch
10.開啓安全組功能,並加載防火牆驅動程序
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini securitygroup firewall_driver neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini securitygroup enable_security_group True
11.啓用L2集羣機制
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini agent l2_population True
12.創建vxlan隧道並設置隧道的物理接口IP
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini agent tunnel_types vxlan
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs integration_bridge br-int
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs tunnel_bridge br-tun
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs enable_tunneling True
openstack-config --set /etc/neutron/plugins/ml2/openvswitch_agent.ini ovs local_ip ${computeTunnelIP}
13.啓動neutron服務
systemctl enable neutron-openvswitch-agent.service
systemctl restart neutron-openvswitch-agent.service
systemctl status neutron-openvswitch-agent.service