openstack pike + ceph +高可用集成 -- Neutron控制节点 Cluster (九)

时间:2021-12-31 20:31:26
#Neutron控制节点Cluster

############以下全部在controller1执行

source ./admin-openstack.sh 
# 创建Neutron服务实体,API端点
openstack service create --name neutron --description "OpenStack Networking" network
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

#安装 所有controller节点可以同时安装 省时间
yum install -y openstack-neutron openstack-neutron-ml2 \
 openstack-neutron-linuxbridge python-neutronclient ebtables ipset

#Neutron 备份配置
cp /etc/neutron/neutron.conf{,.bak2}
cp /etc/neutron/plugins/ml2/ml2_conf.ini{,.bak}
ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini{,.bak}
cp /etc/neutron/dhcp_agent.ini{,.bak}
cp /etc/neutron/metadata_agent.ini{,.bak}
cp /etc/neutron/l3_agent.ini{,.bak}

Netname=em1 #网卡名称
myIP=192.168.0.51 # echo ' [DEFAULT] nova_metadata_ip = controller metadata_proxy_shared_secret = metadata #'>/etc/neutron/metadata_agent.ini # echo '#
#
[ml2]
tenant_network_types = vxlan
type_drivers = flat,vlan,vxlan
mechanism_drivers = linuxbridge,l2population
extension_drivers = port_security
[ml2_type_flat]
flat_networks = provider
[securitygroup]
enable_ipset = True
[ml2_type_vxlan]
vni_ranges = 3001:4000
#'>/etc/neutron/plugins/ml2/ml2_conf.ini
# provider:网卡名
echo '#
#
[linux_bridge]
physical_interface_mappings = provider:'$Netname'
[vxlan]
enable_vxlan = true
l2_population = true
local_ip = '$myIp'
[agent]
prevent_arp_spoofing = True
[securitygroup]
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
enable_security_group = True
#
#'>/etc/neutron/plugins/ml2/linuxbridge_agent.ini
#
echo '#
[DEFAULT]
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
#'>/etc/neutron/dhcp_agent.ini
#
echo '
[DEFAULT]
bind_port = 9696
bind_host = controller1
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = true
transport_url = rabbit://openstack:openstack@controller
auth_strategy = keystone
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true

[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller1:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = neutron

[nova]
auth_url = http://controller:35357
auth_type = password
project_domain_id = default
user_domain_id = default
region_name = RegionOne
project_name = service
username = nova
password = nova

[database]
connection = mysql://neutron:neutron@controller:3306/neutron

[oslo_concurrency]
lock_path = /var/lib/neutron/tmp 
#
#'>/etc/neutron/neutron.conf
#
echo '
[DEFAULT]
interface_driver = linuxbridge
#'>/etc/neutron/l3_agent.ini
#

#同步数据库
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

#检测数据
mysql -h controller -u neutron -pneutron -e "use neutron;show tables;" 

#haproxy高可用配置
echo '
#Neutron_API
listen Neutron_API_cluster
bind controller:9696
balance source
option tcpka
option tcplog
server controller1 controller1:9696 check inter 2000 rise 2 fall 5
server controller2 controller2:9696 check inter 2000 rise 2 fall 5
server controller3 controller3:9696 check inter 2000 rise 2 fall 5
'>>/etc/haproxy/haproxy.cfg
systemctl restart haproxy.service
netstat -antp|grep haproxy


#重启相关服务
systemctl restart openstack-nova-api.service

#启动neutron
systemctl enable neutron-server.service \
  neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
  neutron-metadata-agent.service
systemctl start neutron-server.service \
  neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
  neutron-metadata-agent.service
#
# echo "查看网络节点,正常是:控制节点3个ID,计算节点1个ID"
# openstack network agent list
#

############在controller2安装配置############
#安装 上面已经安装
#yum install -y openstack-neutron openstack-neutron-ml2 \
# openstack-neutron-linuxbridge python-neutronclient ebtables ipset
#同步controller1配置并修改
Node=controller2
rsync -avzP  -e 'ssh -p 22'  controller1:/etc/nova/*  /etc/nova/
rsync -avzP  -e 'ssh -p 22'  controller1:/etc/neutron/*  /etc/neutron/
#sed -i 's/controller1/'$Node'/'  /etc/nova/nova.conf
sed -i 's/controller1/'$Node'/'  /etc/neutron/neutron.conf
rsync -avzP  -e 'ssh -p 22'  controller1:/etc/haproxy/* /etc/haproxy/

#重启相关服务
systemctl restart  haproxy openstack-nova-api.service
#启动neutron
systemctl enable neutron-server.service \
  neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
  neutron-metadata-agent.service
systemctl start neutron-server.service \
  neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
  neutron-metadata-agent.service

########controller3安装配置,同上