[[email protected] bin]# cat /etc/mysqlrouter/mysqlrouter.ini [DEFAULT]#mkdir -p /var/log/mysql-router logging_folder = /var/log/mysql-router plugin_folder = /usr/local/mysql-router/lib/mysqlrouter runtime_folder = /usr/local/mysql-router [logger] # 定义日志等级 level = INFO # 一个高可用的标签 [routing:failover] bind_address = 0.0.0.0 bind_port = 7001 max_connections = 1024 # 目前就支持两种 : read-write 和 read-only # read-write:用于高可用,用于可读可写 # read-only:用于负载均衡,只读 mode = read-write # 实际转发的地址 # 第一个socket如果可用,就一直会使用第一个 # 如果第一个socket无法连接了,才会连接到第二个socket destinations = 10.24.220.70:3306, 10.169.214.33:3306
起动: [[email protected] bin]# ./mysqlrouter -c /etc/mysqlrouter/mysqlrouter.ini & [1] 1203 [[email protected] bin]# Logging to /var/log/mysql-router/mysqlrouter.log ^C [[email protected] bin]# cat Logging to /var/log/mysql-router/mysqlrouter.log cat: Logging: No such file or directory cat: to: No such file or directory 2016-05-16 22:13:02 INFO [7f2cb44a4700] [routing:failover] listening on 0.0.0.0:7001; read-write 2016-05-16 22:13:23 INFO [7f13125a2700] [routing:failover] listening on 0.0.0.0:7001; read-write 2016-05-16 22:16:23 INFO [7f2816b4a700] [routing:failover] listening on 0.0.0.0:7001; read-write 2016-05-16 22:23:51 INFO [7fec2b5f4700] [routing:failover] listening on 0.0.0.0:7001; read-write 2016-05-16 22:24:04 INFO [7ff971019700] [routing:failover] listening on 0.0.0.0:7001; read-write [[email protected] bin]# mysql -u root -p123 -h 172.18.14.68^CP 7002 -e "show variables like ‘server_id‘";
[[email protected] bin]# mysql -u root -p -h 10.169.216.172 -P 7001 -e "show variables like ‘server_id‘"; Enter password: +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 101 | +---------------+-------+ [[email protected] bin]# mysql -u root -p -h 10.169.216.172 -P 7001 -e "show variables like ‘server_id‘"; Enter password: +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 101 | +---------------+-------+ server1:service mysq.server stop [[email protected] bin]# mysql -u root -p -h 10.169.216.172 -P 7001 -e "show variables like ‘server_id‘"; Enter password: +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 102 | +---------------+-------+ [[email protected] bin]# mysql -u root -p -h 10.169.216.172 -P 7001 -e "show variables like ‘server_id‘"; Enter password: +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 102 | +---------------+-------+
时间: 2024-12-28 16:43:23