Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL Router introduction

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

MySQL Router introduction

MySQL Router is a lightweight middleware that provides transparent routing between applications and back-end databases. Mysql is used to achieve load balancing and high availability functions. Router also provides a highly available way to use fabric.

Installation configuration MySQL Routershell > tar zxvf mysql-router-2.0.2-linux-glibc2.17-x86-64bit.tar.gzshell > mv mysql-router-2.0.2-linux-glibc2.17-x86-64bit / opt/mysqlroutershell > cd / opt/mysqlroutershell > mkdir config log create Router configuration file shell > more conf/ router.cnf [default] logging_folder = / opt/mysqlrouter/log/ [logger] level = InfoRouter [routing: read_only] bind_address = 10.106.58.174bind_port = 7001connector _ Timeout = 3max_connections = 1024destinations = 10.106.58.176 1024destinations 3307 read-write 10.106.58.177 1024destinations 3307 mode = read- onlyRouter [routing: read_write] bind_address = 10.106.58.174bind_port = 7002connect_timeout = 3max_connections = 1024destinations = 10.106.58.175virtual 3307Lyric 10.106.58.176virtual 3307mode = read-write upgrade gcc, Glibc

Upgrade gcc to version 4.8, upgrade glibc to version 2.14 or above

Check system GLIBCXX version shell > strings / usr/lib64/libstdc++.so.6 | grep GLIBCXX upgrade gcc Check GLIBCXX version shell > strings / usr/local/lib64/libstdc++.so.6.0.19 in gcc4.8.5 | grep GLIBCXX upgrade supports GLIBCXX_3.4.15shell > cp / usr/local/lib64/libstdc++.so.6.0.19 / usr/lib64/shell > cd / usr/lib64/shell > rm-f libstdc++.so.6shell > ln-s libstdc++.so.6.0.19 libstdc++.so.6 to view the version supported by system glibc: shell > strings / lib64/libc.so.6 | grep GLIBC_ upgrade glibc support version 2.14 or above introduction to running mode

When mode = read-only, the client request will be looped out to the configuration list. When the server in the configuration list is not available, the server will be skipped, and the next available machine in the list will process the request. If there are no available servers in the list, the routing will fail.

When mode = read-write, all client requests will be processed by the first available server in the list. When this server goes down, the next available machine in the list will process the client request. If there are no available servers in the list, the routing will fail. The information of the first successfully connected server will be stored in memory and will be invalidated after restarting router.

Start router

1. Before starting router, you need to ensure that the forwarded server in the configuration file is available.

2. Run router

Shell > / opt/mysqlrouter/bin/mysqlrouter-- config=/opt/mysqlrouter/config/router.cnf & 2016-02-24 06:10:35 INFO [7f898af9e700] routing:read_write started: listening on 10.106.58.174config=/opt/mysqlrouter/config/router.cnf 7002; read-write2016-02-24 06:10:35 INFO [7f898b99f700] routing:read_only started: listening on 10.106.58.174INFO 7001 Read-onlyshell > netstat-an | grep 700tcp 00 10.106.58.174an 7001 0.0.0.0an * LISTENtcp 00 10.106.58.174an 7002 0.0.0.0an * LISTEN

3. Test the connection

Shell > mysql-h 10.106.58.174-P 7001-u test-p-e "select @ @ hostname;" shell > mysql-h 10.106.58.174-P 7002-u test-p-e "select @ @ hostname;" reference:

Http://mysqlhighavailability.com/setting-up-mysql-router/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report