1.9.2. 配置 MySQL Router

默认配置

# cat /etc/mysqlrouter/mysqlrouter.ini

# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.

#

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by

# the Free Software Foundation; version 2 of the License.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#

# MySQL Router configuration file

#

# Documentation is available at

# http://dev.mysql.com/doc/mysql-router/en/

[DEFAULT]

logging_folder = /var/log/mysqlrouter/

plugin_folder = /usr/lib64/mysqlrouter

runtime_folder = /var/run/mysqlrouter

config_folder = /etc/mysqlrouter

[logger]

level = info

# If no plugin is configured which starts a service, keepalive

# will make sure MySQL Router will not immediately exit. It is

# safe to remove once Router is configured.

[keepalive]

interval = 60

1.9.2.1. 主备配置

适用于 MySQL Master-Master / Master-Slave 方案,当一台Master出现故障后另一台Master或者Slave接管

[routing:failover]

bind_address = 192.168.0.5

bind_port = 3306

max_connections = 1024

mode = read-write

destinations = 192.168.0.10:3306,192.168.0.11:3306

1.9.2.2. 负载均衡配置

主要用于输在均衡

[routing:balancing]

bind_address = 192.168.0.5

bind_port = 3307

connect_timeout = 3

max_connections = 1024

mode = read-only

destinations = 192.168.0.20:3306,192.168.0.21:3306

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐