Open twn39 opened 9 years ago
配置文件:/etc/mysqlrouter/mysqlrouter.ini
[DEFAULT]
logging_folder = /var/log/mysqlrouter/
plugin_folder = /usr/lib/x86_64-linux-gnu/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
[routing:slave]
bind_port = 7001
mode = read-only
destinations = slave.example.com,slave2.example.com
max_connections = 1500
bind_port
为链接本地的路由端口,destinations
为链接后端的mysql
地址。
测试:
import mysql.connector
cnx = mysql.connector.connect(host='localhost',port=7001,user='user',password='password')
cur = cnx.cursor()
cur.execute("SHOW DATABASES")
print cur.fetchall()
mysql-router 路由配置