首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Galera集群负载均衡器部署

Galera集群负载均衡器部署
EN

Ask Ubuntu用户
提问于 2019-01-24 15:22:50
回答 1查看 426关注 0票数 1

我们有多个网站连接到一个运行MariaDB - 10.3.11的服务器上,由于负载过重,我们决定实现Galera Cluster replication,并且在数据库中更新记录时得到了预期的结果。

我们需要在这些Galera集群节点之间分配流量(而不是单个服务器连接),因此我们需要部署Galera Cluster Load Balancer。我们在一个新服务器上安装了它,配置在/etc/default/glbd中,如下所示:(在Ubuntu 16.04上运行的所有服务器)。

代码语言:javascript
复制
# This is a configuration file for glbd service script
#
# On Red Hat and derivatives it should be placed in /etc/sysconfig/glbd
#
# On Debian  and derivatives it should be placed in /etc/default/glbd
#
# All settings besides LISTEN_ADDR are optional.
#

# Address to listen for client connections at. Mandatory parameter.
# To bind to all interfaces only port should be specified.
LISTEN_ADDR="3306"

# Address for controlling connection. Mandatory part is port.
# If not specified control socket will not be opened
CONTROL_ADDR="4444"

# Control FIFO name. It is opened always. glbd will refuse to start if
# this file already exists.
CONTROL_FIFO="/var/run/glbd.fifo"

# Number of threads (connection pools) to use. It is always a good idea
# to have a few per CPU core.
THREADS="3"

# Maximum connections. System open files limit will be modified to accommodate
# at least that many client connections provided sufficient privileges.
# Normally you should set it if you plan to go above 500.
#MAX_CONN=

# Target servers for client connections, space separated.
# Target specification: IP[:PORT[:WEIGHT]] (WEIGHT and PORT optional)
# WEIGHT defaults to 1, PORT defaults to LISTEN_ADDR port.
DEFAULT_TARGETS="node1_ip:3306:1 node2_ip:3306:1 node3_ip:3306:1"

# Other glbd options if any as they would appear on the command line.
OTHER_OPTIONS="--round"

我们假设LISTEN_ADDR是3306,因为我们需要与安装了Galera集群负载均衡器的新服务器交换数据库连接&监听3306来代替单个服务器(运行MariaDB)。如果我们对端口的猜测是错误的,请纠正我们。

Section A定义了当前的体系结构,Section B在下面的图中定义了拟议的架构更改:

以下是服务启动时Galera集群负载均衡器的日志。

代码语言:javascript
复制
Jan 24 12:49:54 galera-lb-server systemd[1]: Starting LSB: run glbd daemon...
Jan 24 12:49:54 galera-lb-server glb[12112]: [Thu Jan 24 12:49:54 UTC 2019] glbd: starting...
Jan 24 12:49:54 galera-lb-server glb[12112]:    INFO: glb_daemon.c:44: Changing effective user to 'daemon'
Jan 24 12:49:54 galera-lb-server glb[12112]: glb v1.0.1 (epoll)
Jan 24 12:49:54 galera-lb-server glb[12112]: Incoming address: 0.0.0.0:3306, control FIFO: /var/run/glbd.fifo
Jan 24 12:49:54 galera-lb-server glb[12112]: Control  address:  127.0.0.1:4444
Jan 24 12:49:54 galera-lb-server glb[12112]: Number of threads: 3, max conn: 493, nodelay: ON, keepalive: ON, defer accept: OFF, linger: OFF, daemon: YES, lat.count: 0, policy: 'round-robin', top: NO, verbose: NO
Jan 24 12:49:54 galera-lb-server glb[12112]: Destinations: 3
Jan 24 12:49:54 galera-lb-server glb[12112]:    0:   node1_ip:3306 , w: 1.000
Jan 24 12:49:54 galera-lb-server glb[12112]:    1:  node2_ip:3306 , w: 1.000
Jan 24 12:49:54 galera-lb-server glb[12112]:    2:  node3_ip:3306 , w: 1.000
Jan 24 12:49:54 galera-lb-server glb[12112]: glb v1.0.1 (epoll)
Jan 24 12:49:54 galera-lb-server glb[12112]: Incoming address: 0.0.0.0:3306, control FIFO: /var/run/glbd.fifo
Jan 24 12:49:54 galera-lb-server glb[12112]: Control  address:  127.0.0.1:4444
Jan 24 12:49:54 galera-lb-server glb[12112]: Number of threads: 3, max conn: 493, nodelay: ON, keepalive: ON, defer accept: OFF, linger: OFF, daemon: YES, lat.count: 0, policy: 'round-robin', top: NO, verbose: NO
Jan 24 12:49:54 galera-lb-server glb[12112]: Destinations: 3
Jan 24 12:49:54 galera-lb-server glb[12112]:    0:   node1_ip:3306 , w: 1.000
Jan 24 12:49:54 galera-lb-server glb[12112]:    1:  node2_ip:3306 , w: 1.000
Jan 24 12:49:54 galera-lb-server glb[12112]:    2:  node2_ip:3306 , w: 1.000
Jan 24 12:49:54 galera-lb-server glbd[12133]: glb_main.c:194: Started.
Jan 24 12:49:54 galera-lb-server glb[12112]: [Thu Jan 24 12:49:54 UTC 2019] glbd: started, pid=12133
Jan 24 12:49:54 galera-lb-server systemd[1]: Started LSB: run glbd daemon.

但是我们注意到日志中的错误如下:

代码语言:javascript
复制
Jan 24 13:36:58 galera-lb-server glbd[12133]: glb_pool.c:687: Async connection to node1_ip:3306 failed: 111 (Connection refused)
Jan 24 13:36:58 galera-lb-server glbd[12133]: glb_pool.c:699: Reconnecting to node1_ip:3306

这是service glb getinfo的输出

代码语言:javascript
复制
root@galera-lb-server:/# service glb getinfo
Router:
------------------------------------------------------
        Address       :   weight   usage    map  conns
 node1_ip:3306  :    1.000   0.000    N/A      0
 node2_ip:3306  :    1.000   0.000    N/A      0
 node3_ip:3306  :    1.000   0.000    N/A      0
------------------------------------------------------
Destinations: 3, total connections: 0 of 493 max

我们可以通过复制直接将不同的网站组连接到任何一个节点,但这不是正确的方法。请告诉我们如何部署,如果我们在这里漏掉了什么,请告诉我们。

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2019-01-25 12:13:45

我们在所有节点中绑定了IP地址,这对于所有节点来说都是一样的。

代码语言:javascript
复制
[mysqld]
bind-address = IP

Granted privileges适用于所有MariaDB to load balancer IP用户,并更改了所有网站的连接。设置正确的MariaDB用户访问权限是愚蠢的错误。答案似乎很愚蠢,但希望能对其他用户有所帮助。

票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1112535

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档