注意:建议大家直接打开编辑复制,由于编辑器的编码问题,会出现自动将:
“sudo sed -i "/ \ [ DEFAULT \ ] / a \ rpc_backend = rabbit" /etc/nova/nova.conf”
转换为sudo sed -i "/ DEFAULT /a\rpc_backend = rabbit" /etc/nova/nova.conf
#=============================================================== # #Network Node Configuate OS Env # #=============================================================== export controller_eth=eth0 export data_eth=eth1 export external_eth=eth2 export SourceIP=192.168.3.199 export controller=192.168.3.180 export my_ip="$(/sbin/ifconfig $controller_eth | awk '/inet addr/ {print $2}' | cut -f2 -d ":")" export my_tunnel_ip="$(/sbin/ifconfig $data_eth | awk '/inet addr/ {print $2}' | cut -f2 -d ":")" export nova_pass=nova4smtest export rabbit_pass=mq4smtest export neutron_pass=neutron4smtest export nova_db_user=novadbadmin export nova_db_pass=nova4smtest export metadata_pass=neutron4smtest sleep 3s export is_configuate_openstack_source=0 export is_update_os=0 export is_Install_SoftWare=0 export is_NTP=0 export is_ip_forward=0 export is_Neutron_conf=0 export is_l3_agent=0 export is_dhcp_agent=0 export is_metadata_agent=0 export is_ml2_conf=0 export is_configuate_br_ex=0 #=============================================================== # #Network Node Configuate OpenStack Source # #=============================================================== configuate_openstack_source_func(){ file=/etc/apt/sources.list > $file echo "deb http://$SourceIP/openstack trusty icehouse" >> $file echo "deb http://$SourceIP/openstack trusty icehouse-ext" >> $file echo "deb http://$SourceIP/openstack trusty os" >> $file echo "deb http://$SourceIP/openstack trusty tools" >> $file } Update_os_func(){ sudo apt-get update } Install_SoftWare_func(){ sudo apt-get install openssh-server -y --force-yes sudo apt-get install ntp -y --force-yes sudo apt-get install python-mysqldb -y --force-yes sudo apt-get install python-software-properties -y --force-yes sudo apt-get install neutron-plugin-ml2 neutron-plugin-openvswitch-agent openvswitch-datapath-dkms neutron-l3-agent neutron-dhcp-agent -y --force-yes } #=============================================================== # #Network Node Configuate NTP # #=============================================================== NTP_func(){ echo "===============Start configuate ntp" sudo sed -i -e " s/server 0.ubuntu.pool.ntp.org/#server 0.ubuntu.pool.ntp.org/g;\ s/server 1.ubuntu.pool.ntp.org/#server 1.ubuntu.pool.ntp.org/g;\ s/server 2.ubuntu.pool.ntp.org/#server 2.ubuntu.pool.ntp.org/g;\ s/server 3.ubuntu.pool.ntp.org/#server 3.ubuntu.pool.ntp.org/g;\ s/server ntp.ubuntu.com/server $controller/g" /etc/ntp.conf sudo service ntp stop sudo ntpdate $controller sudo service ntp start echo "Successfull===================Start configuate ntp" sleep 3s } #=============================================================== # #Network Node Configuate Neutron # #=============================================================== Configuate_ip_forward_func(){ echo "===============Start configuate ip_forward" echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf echo "net.ipv4.conf.all.rp_filter=0" >> /etc/sysctl.conf echo "net.ipv4.conf.default.rp_filter=0" >> /etc/sysctl.conf sysctl -p echo "Successfull=================== Start configuate ip_forward" } #*************************************************************** #Neutron.conf #*************************************************************** Neutron_conf_func(){ echo "===============Start configuate neutron.conf" #Keystone sudo sed -i -e 's/# auth_strategy = keystone/auth_strategy = keystone/g' /etc/neutron/neutron.conf sudo sed -i -e " s/%SERVICE_TENANT_NAME%/service/g; s/%SERVICE_USER%/neutron/g; \ s/%SERVICE_PASSWORD%/$neutron_pass/g; \ s/auth_host = 127.0.0.1/auth_host = $controller/g" /etc/neutron/neutron.conf sudo sed -i "/\[keystone_authtoken\]/a\auth_uri = http://$controller:5000" /etc/neutron/neutron.conf #RabbitMQ sudo sed -i -e " s/# rpc_backend = neutron.openstack.common.rpc.impl_kombu/rpc_backend = neutron.openstack.common.rpc.impl_kombu/g; \ s/# rabbit_host = localhost/rabbit_host = $controller/g; \ s/# rabbit_password = guest/rabbit_password = $rabbit_pass/g; \ s/# rabbit_userid = guest/rabbit_userid = guest/g" \ /etc/neutron/neutron.conf #ML2 plug-in sudo sed -i -e 's/core_plugin = neutron.plugins.ml2.plugin.Ml2Plugin/core_plugin = ml2/g' /etc/neutron/neutron.conf sudo sed -i -e 's/# service_plugins =/service_plugins = router/g' /etc/neutron/neutron.conf sudo sed -i -e 's/# allow_overlapping_ips = False/allow_overlapping_ips = True/g' /etc/neutron/neutron.conf echo "Successfull=================== Start configuate neutron.conf" sleep 3s } #*************************************************************** #/etc/neutron/l3_agent.ini #*************************************************************** l3_agent_func(){ echo "===============Start configuate /etc/neutron/l3_agent.ini" sudo sed -i -e 's/# interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver/interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver/g' /etc/neutron/l3_agent.ini sudo sed -i -e 's/# use_namespaces = True/use_namespaces = True/g' /etc/neutron/l3_agent.ini sudo sed -i "/\[DEFAULT\]/a\verbose = True" /etc/neutron/l3_agent.ini echo "Successfull=================== Start configuate /etc/neutron/l3_agent.ini" sleep 3s } #*************************************************************** #/etc/neutron/dhcp_agent.ini #*************************************************************** dhcp_agent_func(){ echo "===============Start configuate /etc/neutron/dhcp_agent.ini" sudo sed -i -e 's/# interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver/interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver/g' /etc/neutron/dhcp_agent.ini sudo sed -i -e 's/# use_namespaces = True/use_namespaces = True/g' /etc/neutron/dhcp_agent.ini sudo sed -i -e 's/# dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq/dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq/g' /etc/neutron/dhcp_agent.ini sudo sed -i "/\[DEFAULT\]/a\verbose = True" /etc/neutron/dhcp_agent.ini echo "Successfull=================== Start configuate /etc/neutron/dhcp_agent.ini" sleep 3s } #*************************************************************** #/etc/neutron/metadata_agent.ini #*************************************************************** metadata_agent_func(){ echo "===============Start configuate /etc/neutron/metadata_agent.ini" sudo sed -i -e " s/%SERVICE_TENANT_NAME%/service/g; s/%SERVICE_USER%/neutron/g; \ s/%SERVICE_PASSWORD%/$neutron_pass/g" /etc/neutron/metadata_agent.ini sudo sed -i -e " s/auth_url = http:\/\/localhost:5000\/v2.0/auth_url = http:\/\/$controller:5000\/v2.0/g;\ s/# nova_metadata_ip = 127.0.0.1/nova_metadata_ip = $controller/g; \ s/# metadata_proxy_shared_secret =/metadata_proxy_shared_secret =$metadata_pass/g" \ /etc/neutron/metadata_agent.ini echo "Successfull=================== Start configuate /etc/neutron/metadata_agent.ini" sleep 3s } #*************************************************************** #Notice:Update Controller Nova.conf #[DEFAULT] #service_neutron_metadata_proxy = true #neutron_metadata_proxy_shared_secret = METADATA_SECRET #*************************************************************** #*************************************************************** #ml2_conf.ini #*************************************************************** ml2_conf_func(){ echo "===============Start configuate ml2_conf.ini" #[ml2] sudo sed -i -e 's/# type_drivers = local,flat,vlan,gre,vxlan/type_drivers = gre/g' /etc/neutron/plugins/ml2/ml2_conf.ini sudo sed -i -e 's/# tenant_network_types = local/tenant_network_types = gre/g' /etc/neutron/plugins/ml2/ml2_conf.ini sudo sed -i -e 's/# mechanism_drivers =/mechanism_drivers = openvswitch/g' /etc/neutron/plugins/ml2/ml2_conf.ini #[ml2_type_gre] sudo sed -i -e 's/# tunnel_id_ranges =/tunnel_id_ranges = 1:1000/g' /etc/neutron/plugins/ml2/ml2_conf.ini #[securitygroup] sudo sed -i -e 's/# enable_security_group = True/enable_security_group = True/g' /etc/neutron/plugins/ml2/ml2_conf.ini echo "firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver" >> /etc/neutron/plugins/ml2/ml2_conf.ini #[ovs] echo "[ovs]" >> /etc/neutron/plugins/ml2/ml2_conf.ini echo "local_ip = $my_tunnel_ip" >> /etc/neutron/plugins/ml2/ml2_conf.ini echo "tunnel_type = gre" >> /etc/neutron/plugins/ml2/ml2_conf.ini echo "enable_tunneling = True" >> /etc/neutron/plugins/ml2/ml2_conf.ini echo "Successfull=================== Start configuate ml2_conf.ini" sleep 3s } #*************************************************************** #Start configuate br-ex #*************************************************************** configuate_br_ex_func(){ echo "===============Start configuate br-ex" sudo ovs-vsctl add-br br-ex sudo ovs-vsctl add-port br-ex $external_eth sudo ethtool -K $external_eth gro off echo "Successfull=================== Start configuate br-ex" } if [ `id -u ` -ne "0" ]; then echo "please use root login in " exit 1 fi if [ "$is_configuate_openstack_source" = 0 ]; then configuate_openstack_source_func; fi if [ "$is_update_os" = 0 ]; then Update_os_func; fi if [ "$is_Install_SoftWare" = 0 ]; then Install_SoftWare_func; fi if [ "$is_NTP" = 0 ]; then NTP_func; fi if [ "$is_ip_forward" = 0 ]; then Configuate_ip_forward_func; fi if [ "$is_Neutron_conf" = 0 ]; then Neutron_conf_func; fi if [ "$is_l3_agent" = 0 ]; then l3_agent_func; fi if [ "$is_dhcp_agent" = 0 ]; then dhcp_agent_func; fi if [ "$is_metadata_agent" = 0 ]; then metadata_agent_func; fi if [ "$is_ml2_conf" = 0 ]; then ml2_conf_func; fi sudo service openvswitch-switch restart sleep 3s if [ "$is_configuate_br_ex" = 0 ]; then configuate_br_ex_func; fi #*************************************************************** #Start Service #*************************************************************** sudo service neutron-plugin-openvswitch-agent restart sudo service neutron-l3-agent restart sudo service neutron-dhcp-agent restart sudo service neutron-metadata-agent restart sleep 3s echo "*" sudo service neutron-plugin-openvswitch-agent restart sudo service neutron-l3-agent restart sudo service neutron-dhcp-agent restart sudo service neutron-metadata-agent restart