使用openstack构建虚拟机高可用

3250阅读 0评论2016-05-22 sak0
分类:云计算

用户在云平台中创建了虚机跑了应用,但想为这些应用配置高可用/负载均衡时遇到了麻烦,怎样更好地为虚机提供高可用方案?

使用需求
/对应方案

基于openstack平台创建vm,为vm中的应用配置高可用/负载均衡,为vm的应用提供共享文件系统

 

其中对于负载均衡的构建有两种方案:

A.在vm中使用集群管理软件(比如haproxy)配置

B.使用openstack提供的lbaas服务配置

 

版本的不足

1.loadbalance一个vip对应一个port的模式,配置复杂,占用过多的vip;

2.neutron为了防止arp欺骗行为,在防火墙中禁止vm中使用平台分配之外的ip,使用者在vm中手工配置haproxy的方案不可行;

3.Manila 服务不可用

 

新版本带来的改进

1.使用loadbalance v2模型,一个vip可以对应多个port

2.使用neutron提供的no_security功能或ip_address_pair功能,使vm中能够使用平台分配之外的ip地址,解决在vm中配置haproxy带来的问题

3.使用manila服务为应用创建共享文件系统(share)

了解更多

① loadbalance v1->v2

V1



使用方法:

neutron lb-pool-create --lb-method ROUND_ROBIN --name mypool --protocol HTTP --subnet-id SUBNET_UUID --provider PROVIDER_NAME

neutron lb-member-create --address  WEBSERVER1_IP --protocol-port 80 mypool

neutron lb-member-create --address  WEBSERVER2_IP --protocol-port 80 mypool

neutron lb-healthmonitor-create --delay 3 --type HTTP --max-retries 3 --timeout 3

neutron lb-healthmonitor-associate  HEALTHMONITOR_UUID mypool

neutron lb-vip-create --name myvip --protocol-port 80 --protocol HTTP --subnet-id SUBNET_UUID mypool



V2


neutron lbaas-loadbalancer-create --name test-lb private-subnet

neutron lbaas-listener-create --name test-lb-http --loadbalancer test-lb --protocol HTTP --protocol-port 80

neutron lbaas-pool-create --name test-lb-pool-http --lb-algorithm ROUND_ROBIN --listener test-lb-http --protocol HTTP

neutron lbaas-member-create --subnet private-subnet --address 192.168.1.16 --protocol-port 80 test-lb-pool-http

neutron lbaas-member-create --subnet private-subnet --address 192.168.1.17 --protocol-port 80 test-lb-pool-http

neutron lbaas-healthmonitor-create --delay 5 --max-retries 2 --timeout 10 --type HTTP --pool test-lb-pool-http



②neutron arp spoofing protection

在br-int流表中实现

neutron/plugins/ml2/drivers/openvswitch/agent/openflow/ovs_ofctl/br-int.py

点击(此处)折叠或打开

  1. def install_arp_spoofing_protection(self, port, ip_addresses):
  2.         # allow ARPs as long as they match addresses that actually
  3.         # belong to the port.
  4.         for ip in ip_addresses:
  5.             self.install_normal(
  6.                 table_id=constants.ARP_SPOOF_TABLE, priority=2,
  7.                 proto='arp', arp_spa=ip, in_port=port)

  8.         # Now that the rules are ready, direct ARP traffic from the port into
  9.         # the anti-spoof table.
  10.         # This strategy fails gracefully because OVS versions that can't match
  11.         # on ARP headers will just process traffic normally.
  12.         self.add_flow(table=constants.LOCAL_SWITCHING,
  13.                       priority=10, proto='arp



在iptables规则中实现

neutron/agent/linux/iptables_firewall.py



点击(此处)折叠或打开

  1. def _setup_spoof_filter_chain(self, port, table, mac_ip_pairs, rules):
  2.         if mac_ip_pairs:
  3.             chain_name = self._port_chain_name(port, SPOOF_FILTER)
  4.             table.add_chain(chain_name)
  5.             for mac, ip in mac_ip_pairs:
  6.                 if ip is None:
  7.                     # If fixed_ips is [] this rule will be added to the end
  8.                     # of the list after the allowed_address_pair rules.
  9.                     table.add_rule(chain_name,
  10.                                    '-m mac --mac-source %s -j RETURN'
  11.                                    % mac.upper(), comment=ic.PAIR_ALLOW)
  12.                 else:
  13.                     table.add_rule(chain_name,
  14.                                    '-s %s -m mac --mac-source %s -j RETURN'
  15.                                    % (ip, mac.upper()), comment=ic.PAIR_ALLOW)
  16.             table.add_rule(chain_name, '-j DROP', comment=ic.PAIR_DROP)
  17.             rules.append('-j $%s' % chain_name)



neutron no_security & allow_ip_pair

对于LVS、基于虚拟机的路由器、基于虚拟机的防火墙等应用,需要在一个无防火墙、安全组和 antispoof 规则的私有网络(虚拟网卡)下运行,如果保持着 anti-spoof规则的话,上述的应用很多都完全无法工作

bp: https://blueprints.launchpad.net/neutron/+spec/ml2-ovs-portsecurity




manila service



创建步骤

manila share-network-create --neutron-net-id 92ac0283-e071-49e3-b7d7-a5f2029ac86a --neutron-subnet-id 31abd918-0df9-4986-bf98-6c9e4ede6336 --name shared_network-1

manila create NFS 1 --name share_nfs --share-network 2490060b-95f0-4228-9028-1a90006e4ed5

实现说明
Manila在创建一个nfs share的时候,实际是创建一个nova instance;它会通过neutron规划存储网络,并通过nova ssh-key进入虚机,配置nfs服务



上一篇:【群分享】OpenStack管理VMware的几点实践
下一篇:Docker Volume Plugin试用