【Mysql路由中间件之GLB 】

GLB (Galera Load Balancer) 是一个与 Pen 类似的 TCP 负载均衡器,它功能没有 Pen 那么强大,其主要的目的是做一个非常快速的 TCP 协议代理。通过利用多核CPU的优势,GLB 的速度有显著的提升。

Pen 是一个负载均衡器,支持 UDP 和 TCP 基础协议,比如 HTTP 和 SMTP,在外部允许把多个服务器显示为一个,可以自动检测可用服务器上的分布式客户端和停掉的服务器。Pen 提供高可用性,高性能的特性。

这个负载算法会继续追踪客户端,也会尝试把他们访问的最后时间发送给服务器。客户端表有大量的插槽(默认是 2048,通过命令行参数可设置)。当表满了的时候,当前最小使用的那个会抛出去,换成新的。

这是个简单的优先轮询算法,会重复的连接发送客户端到不同的服务器。

当 Pen 检测到一个服务器不可用,就会扫描启动其他服务器,这样就可以避免负载平衡和”平滑“故障的问题。

Galera Load Balancer 0.9.2 包含一个 “single” 负载均衡策略,该策略让所有的连接都直接导向单个权重最高的目标,--top 选项用于强制只在最高权重的目标节点进行负载均衡,SO_KEEPALIE 选项用于检测目标节点的失败连接。

Galera Cluster guarantees node consistency regardless of where and when the query is issued. In other words, you are free to choose a load-balancing approach that best suits your purposes. If you decide to place the load balancing mechanism between the database and the application, you can consider, for example, the following tools:

1)HAProxy an open source TCP/HTTP load balancer.

2)Pen another open source TCP/HTTP load balancer. Pen performs better than HAProxy on SQL traffic.

3)Galera Load Balancer inspired by Pen, but is limited to balancing generic TCP connections only.

CONFIGURATION

When you run Galera Load Balancer, you can configure its use through the command-line options, which you can reference through the --help command. For users that run Galera Load Balancer as a service, you can manage it through the glbd.cfg configuration file.

  • LISTEN_ADDR Defines the address that Galera Load Balancer monitors for incoming client connections.
  • DEFAULT_TARGETS Defines the default servers that Galera Load Balancer routes incoming client connections to. For this parameter, use the IP addresses for the nodes in your cluster.
  • OTHER_OPTIONS Defines additional Galera Load Balancer options, such as the balancing policy you want to use. Use the same format as they would appear on the command-line.

For instance,

# Galera Load Balancer COnfigurations
LISTEN_ADDR="8010"
DEFAULT_TARGETS="192.168.1.1 192.168.1.2 192.168.1.3"
OTHER_OPTIONS="--random --top 3"

Destination Selection Policies

Galera Load Balancer, both the system daemon and the shared library, support five destination selection policies. When you run it from the command-line, you can define these using the command-line arguments, otherwise add the arguments to the OTHER_OPTIONS parameter in theglbd.cfg configuration file.

  • Least Connected Directs new connections to the server using the smallest number of connections possible, which is adjusted for the server weight. This is the default policy.
  • Round Robin Directs new connections to the next destination in the circular order list. You can enable it through the –round option.
  • Single Directs all connections to the single server with the highest weight of those available. Routing continues to that server until it fails or a server with a higher weight becomes available. You can enable it through the –single option.
  • Random Directs connections randomly to available servers. You can enable it through the–random option
  • Source Tracking Directs connections originating from the same address to the same server. You can enable it through the –source option.

猜你喜欢

转载自gaojingsong.iteye.com/blog/2381759
今日推荐