Skip to content

Instantly share code, notes, and snippets.

@miyu4u
Created January 19, 2020 09:56
Show Gist options
  • Save miyu4u/f7f0ebe8c45140ce7b3940c84a87f69c to your computer and use it in GitHub Desktop.
Save miyu4u/f7f0ebe8c45140ce7b3940c84a87f69c to your computer and use it in GitHub Desktop.
Proxy sql with query routing
FROM debian:stretch
RUN apt-get update && apt-get install -y wget lsb-release gnupg apt-transport-https ca-certificates && \
wget -O - 'https://repo.proxysql.com/ProxySQL/repo_pub_key' | apt-key add - && echo deb https://repo.proxysql.com/ProxySQL/proxysql-2.0.x/$(lsb_release -sc)/ ./ | tee /etc/apt/sources.list.d/proxysql.list && \
apt-get update && apt-get install proxysql && apt-get install -y mysql-client vim && \
rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["proxysql", "-f", "-D", "/var/lib/proxysql"]
datadir="/var/lib/proxysql"
admin_variables=
{
admin_credentials="admin:admin"
mysql_ifaces="0.0.0.0:6032"
refresh_interval=2000
web_enabled=true
web_port=6080
stats_credentials="stats:admin"
}
mysql_variables=
{
threads=4
max_connections=2048
default_query_delay=0
default_query_timeout=36000000
have_compress=false
poll_timeout=2000
interfaces="0.0.0.0:6033;/tmp/proxysql.sock"
default_schema="information_schema"
stacksize=1048576
server_version="5.1.30"
connect_timeout_server=10000
monitor_history=60000
monitor_connect_interval=200000
monitor_ping_interval=200000
ping_interval_server_msec=10000
ping_timeout_server=200
commands_stats=true
sessions_sort=true
monitor_username="proxysql"
monitor_password="proxysqlpassword"
monitor_galera_healthcheck_interval=2000
monitor_galera_healthcheck_timeout=800
}
mysql_servers =
(
{ address="dbip1" , port=3306 , hostgroup=1, max_connections=100 },
{ address="dbip2" , port=3306 , hostgroup=2, max_connections=100 },
)
mysql_query_rules =
(
{
rule_id=100
active=1
match_pattern="FROM subdb01\."
replace_pattern="FROM "
destination_hostgroup=1
apply=1
},
{
rule_id=200
active=1
match_pattern="FROM subdb02\."
replace_pattern="FROM "
destination_hostgroup=2
apply=1
},
)
mysql_users =
(
{ username = "root", password = "password", transaction_persistent = 0, active = 1 },
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment