├── 1.4 ├── Dockerfile └── entrypoint.sh ├── 2.0 ├── Dockerfile └── entrypoint.sh ├── 2.1 ├── Dockerfile └── entrypoint.sh ├── 2.2 ├── Dockerfile └── entrypoint.sh ├── 2.3 ├── Dockerfile └── entrypoint.sh ├── 2.4 ├── Dockerfile └── entrypoint.sh ├── 2.5 ├── Dockerfile └── entrypoint.sh └── README.md /1.4/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:buster 2 | MAINTAINER Ashraf Sharif 3 | 4 | ENV VERSION 1.4.16 5 | 6 | RUN apt-get update && \ 7 | apt-get install -y wget mariadb-client inotify-tools procps && \ 8 | wget https://github.com/sysown/proxysql/releases/download/v${VERSION}/proxysql_${VERSION}-debian10_amd64.deb -O /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 9 | dpkg -i /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 10 | rm -f /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 11 | rm -rf /var/lib/apt/lists/* 12 | 13 | VOLUME /var/lib/proxysql 14 | EXPOSE 6032 6033 15 | 16 | COPY entrypoint.sh /entrypoint.sh 17 | ENTRYPOINT ["bash","/entrypoint.sh"] 18 | -------------------------------------------------------------------------------- /1.4/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ## ProxySQL entrypoint 5 | ## =================== 6 | ## 7 | ## Supported environment variable: 8 | ## 9 | ## MONITOR_CONFIG_CHANGE={true|false} 10 | ## - Monitor /etc/proxysql.cnf for any changes and reload ProxySQL automatically 11 | 12 | # If command has arguments, prepend proxysql 13 | if [ "${1:0:1}" = '-' ]; then 14 | CMDARG="$@" 15 | fi 16 | 17 | if [ $MONITOR_CONFIG_CHANGE ]; then 18 | 19 | echo 'Env MONITOR_CONFIG_CHANGE=true' 20 | CONFIG=/etc/proxysql.cnf 21 | oldcksum=$(cksum ${CONFIG}) 22 | 23 | # Start ProxySQL in the background 24 | proxysql --reload -f $CMDARG & 25 | 26 | echo "Monitoring $CONFIG for changes.." 27 | inotifywait -e modify,move,create,delete -m --timefmt '%d/%m/%y %H:%M' --format '%T' ${CONFIG} | \ 28 | while read date time; do 29 | newcksum=$(cksum ${CONFIG}) 30 | if [ "$newcksum" != "$oldcksum" ]; then 31 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 32 | echo "At ${time} on ${date}, ${CONFIG} update detected." 33 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 34 | oldcksum=$newcksum 35 | echo "Reloading ProxySQL.." 36 | killall -15 proxysql 37 | proxysql --initial --reload -f $CMDARG 38 | fi 39 | done 40 | fi 41 | 42 | # Start ProxySQL with PID 1 43 | exec proxysql -f $CMDARG 44 | -------------------------------------------------------------------------------- /2.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:buster 2 | MAINTAINER Ashraf Sharif 3 | 4 | ENV VERSION 2.0.18 5 | 6 | RUN apt-get update && \ 7 | apt-get install -y wget mariadb-client inotify-tools procps && \ 8 | wget https://github.com/sysown/proxysql/releases/download/v${VERSION}/proxysql_${VERSION}-debian10_amd64.deb -O /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 9 | dpkg -i /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 10 | rm -f /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 11 | rm -rf /var/lib/apt/lists/* 12 | 13 | VOLUME /var/lib/proxysql 14 | EXPOSE 6032 6033 6080 15 | 16 | COPY entrypoint.sh /entrypoint.sh 17 | ENTRYPOINT ["bash","/entrypoint.sh"] 18 | -------------------------------------------------------------------------------- /2.0/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ## ProxySQL entrypoint 5 | ## =================== 6 | ## 7 | ## Supported environment variable: 8 | ## 9 | ## MONITOR_CONFIG_CHANGE={true|false} 10 | ## - Monitor /etc/proxysql.cnf for any changes and reload ProxySQL automatically 11 | 12 | # If command has arguments, prepend proxysql 13 | if [ "${1:0:1}" == '-' ]; then 14 | CMDARG="$@" 15 | fi 16 | 17 | if [ $MONITOR_CONFIG_CHANGE ]; then 18 | 19 | echo 'Env MONITOR_CONFIG_CHANGE=true' 20 | CONFIG=/etc/proxysql.cnf 21 | oldcksum=$(cksum ${CONFIG}) 22 | 23 | # Start ProxySQL in the background 24 | proxysql --reload -f $CMDARG & 25 | 26 | echo "Monitoring $CONFIG for changes.." 27 | inotifywait -e modify,move,create,delete -m --timefmt '%d/%m/%y %H:%M' --format '%T' ${CONFIG} | \ 28 | while read date time; do 29 | newcksum=$(cksum ${CONFIG}) 30 | if [ "$newcksum" != "$oldcksum" ]; then 31 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 32 | echo "At ${time} on ${date}, ${CONFIG} update detected." 33 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 34 | oldcksum=$newcksum 35 | echo "Reloading ProxySQL.." 36 | killall -15 proxysql 37 | proxysql --initial --reload -f $CMDARG 38 | fi 39 | done 40 | fi 41 | 42 | # Start ProxySQL with PID 1 43 | exec proxysql -f $CMDARG 44 | -------------------------------------------------------------------------------- /2.1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:buster 2 | MAINTAINER Ashraf Sharif 3 | 4 | ENV VERSION 2.1.1 5 | 6 | RUN apt-get update && \ 7 | apt-get install -y wget mariadb-client inotify-tools procps && \ 8 | wget https://github.com/sysown/proxysql/releases/download/v${VERSION}/proxysql_${VERSION}-debian10_amd64.deb -O /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 9 | dpkg -i /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 10 | rm -f /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 11 | rm -rf /var/lib/apt/lists/* 12 | 13 | VOLUME /var/lib/proxysql 14 | EXPOSE 6032 6033 6080 15 | 16 | COPY entrypoint.sh /entrypoint.sh 17 | ENTRYPOINT ["bash","/entrypoint.sh"] 18 | -------------------------------------------------------------------------------- /2.1/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ## ProxySQL entrypoint 5 | ## =================== 6 | ## 7 | ## Supported environment variable: 8 | ## 9 | ## MONITOR_CONFIG_CHANGE={true|false} 10 | ## - Monitor /etc/proxysql.cnf for any changes and reload ProxySQL automatically 11 | 12 | # If command has arguments, prepend proxysql 13 | if [ "${1:0:1}" == '-' ]; then 14 | CMDARG="$@" 15 | fi 16 | 17 | if [ $MONITOR_CONFIG_CHANGE ]; then 18 | 19 | echo 'Env MONITOR_CONFIG_CHANGE=true' 20 | CONFIG=/etc/proxysql.cnf 21 | oldcksum=$(cksum ${CONFIG}) 22 | 23 | # Start ProxySQL in the background 24 | proxysql --reload -f $CMDARG & 25 | 26 | echo "Monitoring $CONFIG for changes.." 27 | inotifywait -e modify,move,create,delete -m --timefmt '%d/%m/%y %H:%M' --format '%T' ${CONFIG} | \ 28 | while read date time; do 29 | newcksum=$(cksum ${CONFIG}) 30 | if [ "$newcksum" != "$oldcksum" ]; then 31 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 32 | echo "At ${time} on ${date}, ${CONFIG} update detected." 33 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 34 | oldcksum=$newcksum 35 | echo "Reloading ProxySQL.." 36 | killall -15 proxysql 37 | proxysql --initial --reload -f $CMDARG 38 | fi 39 | done 40 | fi 41 | 42 | # Start ProxySQL with PID 1 43 | exec proxysql -f $CMDARG 44 | -------------------------------------------------------------------------------- /2.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:buster 2 | MAINTAINER Ashraf Sharif 3 | 4 | ENV VERSION 2.2.2 5 | 6 | RUN apt-get update && \ 7 | apt-get install -y wget mariadb-client inotify-tools procps && \ 8 | wget https://github.com/sysown/proxysql/releases/download/v${VERSION}/proxysql_${VERSION}-debian10_amd64.deb -O /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 9 | dpkg -i /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 10 | rm -f /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 11 | rm -rf /var/lib/apt/lists/* 12 | 13 | VOLUME /var/lib/proxysql 14 | EXPOSE 6032 6033 6080 15 | 16 | COPY entrypoint.sh /entrypoint.sh 17 | ENTRYPOINT ["bash","/entrypoint.sh"] 18 | -------------------------------------------------------------------------------- /2.2/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ## ProxySQL entrypoint 5 | ## =================== 6 | ## 7 | ## Supported environment variable: 8 | ## 9 | ## MONITOR_CONFIG_CHANGE={true|false} 10 | ## - Monitor /etc/proxysql.cnf for any changes and reload ProxySQL automatically 11 | 12 | # If command has arguments, prepend proxysql 13 | if [ "${1:0:1}" == '-' ]; then 14 | CMDARG="$@" 15 | fi 16 | 17 | if [ $MONITOR_CONFIG_CHANGE ]; then 18 | 19 | echo 'Env MONITOR_CONFIG_CHANGE=true' 20 | CONFIG=/etc/proxysql.cnf 21 | oldcksum=$(cksum ${CONFIG}) 22 | 23 | # Start ProxySQL in the background 24 | proxysql --reload -f $CMDARG & 25 | 26 | echo "Monitoring $CONFIG for changes.." 27 | inotifywait -e modify,move,create,delete -m --timefmt '%d/%m/%y %H:%M' --format '%T' ${CONFIG} | \ 28 | while read date time; do 29 | newcksum=$(cksum ${CONFIG}) 30 | if [ "$newcksum" != "$oldcksum" ]; then 31 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 32 | echo "At ${time} on ${date}, ${CONFIG} update detected." 33 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 34 | oldcksum=$newcksum 35 | echo "Reloading ProxySQL.." 36 | killall -15 proxysql 37 | proxysql --initial --reload -f $CMDARG 38 | fi 39 | done 40 | fi 41 | 42 | # Start ProxySQL with PID 1 43 | exec proxysql -f $CMDARG 44 | -------------------------------------------------------------------------------- /2.3/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:buster 2 | MAINTAINER Ashraf Sharif 3 | 4 | ENV VERSION 2.3.2 5 | 6 | RUN apt-get update && \ 7 | apt-get install -y wget mariadb-client inotify-tools procps && \ 8 | wget https://github.com/sysown/proxysql/releases/download/v${VERSION}/proxysql_${VERSION}-debian10_amd64.deb -O /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 9 | dpkg -i /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 10 | rm -f /opt/proxysql_${VERSION}-debian10_amd64.deb && \ 11 | rm -rf /var/lib/apt/lists/* 12 | 13 | VOLUME /var/lib/proxysql 14 | EXPOSE 6032 6033 6080 15 | 16 | COPY entrypoint.sh /entrypoint.sh 17 | ENTRYPOINT ["bash","/entrypoint.sh"] 18 | -------------------------------------------------------------------------------- /2.3/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ## ProxySQL entrypoint 5 | ## =================== 6 | ## 7 | ## Supported environment variable: 8 | ## 9 | ## MONITOR_CONFIG_CHANGE={true|false} 10 | ## - Monitor /etc/proxysql.cnf for any changes and reload ProxySQL automatically 11 | 12 | # If command has arguments, prepend proxysql 13 | if [ "${1:0:1}" == '-' ]; then 14 | CMDARG="$@" 15 | fi 16 | 17 | if [ $MONITOR_CONFIG_CHANGE ]; then 18 | 19 | echo 'Env MONITOR_CONFIG_CHANGE=true' 20 | CONFIG=/etc/proxysql.cnf 21 | oldcksum=$(cksum ${CONFIG}) 22 | 23 | # Start ProxySQL in the background 24 | proxysql --reload -f $CMDARG & 25 | 26 | echo "Monitoring $CONFIG for changes.." 27 | inotifywait -e modify,move,create,delete -m --timefmt '%d/%m/%y %H:%M' --format '%T' ${CONFIG} | \ 28 | while read date time; do 29 | newcksum=$(cksum ${CONFIG}) 30 | if [ "$newcksum" != "$oldcksum" ]; then 31 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 32 | echo "At ${time} on ${date}, ${CONFIG} update detected." 33 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 34 | oldcksum=$newcksum 35 | echo "Reloading ProxySQL.." 36 | killall -15 proxysql 37 | proxysql --initial --reload -f $CMDARG 38 | fi 39 | done 40 | fi 41 | 42 | # Start ProxySQL with PID 1 43 | exec proxysql -f $CMDARG 44 | -------------------------------------------------------------------------------- /2.4/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:bullseye 2 | MAINTAINER Agus Syafaat 3 | 4 | ENV VERSION 2.4.8 5 | 6 | RUN apt-get update && \ 7 | apt-get install -y wget default-mysql-client inotify-tools procps && \ 8 | wget https://github.com/sysown/proxysql/releases/download/v${VERSION}/proxysql_${VERSION}-debian11_amd64.deb -O /opt/proxysql_${VERSION}-debian11_amd64.deb && \ 9 | dpkg -i /opt/proxysql_${VERSION}-debian11_amd64.deb && \ 10 | rm -f /opt/proxysql_${VERSION}-debian11_amd64.deb && \ 11 | rm -rf /var/lib/apt/lists/* 12 | 13 | VOLUME /var/lib/proxysql 14 | EXPOSE 6032 6033 6080 15 | 16 | COPY entrypoint.sh /entrypoint.sh 17 | ENTRYPOINT ["bash","/entrypoint.sh"] 18 | -------------------------------------------------------------------------------- /2.4/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ## ProxySQL entrypoint 5 | ## =================== 6 | ## 7 | ## Supported environment variable: 8 | ## 9 | ## MONITOR_CONFIG_CHANGE={true|false} 10 | ## - Monitor /etc/proxysql.cnf for any changes and reload ProxySQL automatically 11 | 12 | # If command has arguments, prepend proxysql 13 | if [ "${1:0:1}" == '-' ]; then 14 | CMDARG="$@" 15 | fi 16 | 17 | if [ $MONITOR_CONFIG_CHANGE ]; then 18 | 19 | echo 'Env MONITOR_CONFIG_CHANGE=true' 20 | CONFIG=/etc/proxysql.cnf 21 | oldcksum=$(cksum ${CONFIG}) 22 | 23 | # Start ProxySQL in the background 24 | proxysql --reload -f $CMDARG & 25 | 26 | echo "Monitoring $CONFIG for changes.." 27 | inotifywait -e modify,move,create,delete -m --timefmt '%d/%m/%y %H:%M' --format '%T' ${CONFIG} | \ 28 | while read date time; do 29 | newcksum=$(cksum ${CONFIG}) 30 | if [ "$newcksum" != "$oldcksum" ]; then 31 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 32 | echo "At ${time} on ${date}, ${CONFIG} update detected." 33 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 34 | oldcksum=$newcksum 35 | echo "Reloading ProxySQL.." 36 | killall -15 proxysql 37 | proxysql --initial --reload -f $CMDARG 38 | fi 39 | done 40 | fi 41 | 42 | # Start ProxySQL with PID 1 43 | exec proxysql -f $CMDARG 44 | -------------------------------------------------------------------------------- /2.5/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:bullseye 2 | MAINTAINER Agus Syafaat 3 | 4 | ENV VERSION 2.5.3 5 | 6 | RUN apt-get update && \ 7 | apt-get install -y wget default-mysql-client inotify-tools procps && \ 8 | wget https://github.com/sysown/proxysql/releases/download/v${VERSION}/proxysql_${VERSION}-debian11_amd64.deb -O /opt/proxysql_${VERSION}-debian11_amd64.deb && \ 9 | dpkg -i /opt/proxysql_${VERSION}-debian11_amd64.deb && \ 10 | rm -f /opt/proxysql_${VERSION}-debian11_amd64.deb && \ 11 | rm -rf /var/lib/apt/lists/* 12 | 13 | VOLUME /var/lib/proxysql 14 | EXPOSE 6032 6033 6080 15 | 16 | COPY entrypoint.sh /entrypoint.sh 17 | ENTRYPOINT ["bash","/entrypoint.sh"] 18 | -------------------------------------------------------------------------------- /2.5/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ## ProxySQL entrypoint 5 | ## =================== 6 | ## 7 | ## Supported environment variable: 8 | ## 9 | ## MONITOR_CONFIG_CHANGE={true|false} 10 | ## - Monitor /etc/proxysql.cnf for any changes and reload ProxySQL automatically 11 | 12 | # If command has arguments, prepend proxysql 13 | if [ "${1:0:1}" == '-' ]; then 14 | CMDARG="$@" 15 | fi 16 | 17 | if [ $MONITOR_CONFIG_CHANGE ]; then 18 | 19 | echo 'Env MONITOR_CONFIG_CHANGE=true' 20 | CONFIG=/etc/proxysql.cnf 21 | oldcksum=$(cksum ${CONFIG}) 22 | 23 | # Start ProxySQL in the background 24 | proxysql --reload -f $CMDARG & 25 | 26 | echo "Monitoring $CONFIG for changes.." 27 | inotifywait -e modify,move,create,delete -m --timefmt '%d/%m/%y %H:%M' --format '%T' ${CONFIG} | \ 28 | while read date time; do 29 | newcksum=$(cksum ${CONFIG}) 30 | if [ "$newcksum" != "$oldcksum" ]; then 31 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 32 | echo "At ${time} on ${date}, ${CONFIG} update detected." 33 | echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++" 34 | oldcksum=$newcksum 35 | echo "Reloading ProxySQL.." 36 | killall -15 proxysql 37 | proxysql --initial --reload -f $CMDARG 38 | fi 39 | done 40 | fi 41 | 42 | # Start ProxySQL with PID 1 43 | exec proxysql -f $CMDARG 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ProxySQL Docker Image # 2 | 3 | ## Supported Tags ## 4 | 5 | * [2, 2.5, 2.5.3, latest (2.5/Dockerfile)](//github.com/severalnines/proxysql-docker/blob/master/2.5/Dockerfile) 6 | * [2, 2.4, 2.4.8 (2.4/Dockerfile)](//github.com/severalnines/proxysql-docker/blob/master/2.4/Dockerfile) 7 | * [2, 2.3, 2.3.2 (2.3/Dockerfile)](//github.com/severalnines/proxysql-docker/blob/master/2.3/Dockerfile) 8 | * [2.2, 2.2.2 (2.2/Dockerfile)](//github.com/severalnines/proxysql-docker/blob/master/2.2/Dockerfile) 9 | * [2.1, 2.1.1, (2.1/Dockerfile)](//github.com/severalnines/proxysql-docker/blob/master/2.1/Dockerfile) 10 | * [2.0, 2.0.18 (2.0/Dockerfile)](https://github.com/severalnines/proxysql-docker/blob/master/2.0/Dockerfile) 11 | * [1, 1.4, 1.4.16 (1.4/Dockerfile)](https://github.com/severalnines/proxysql-docker/blob/master/1.4/Dockerfile) 12 | 13 | 14 | ## Overview ## 15 | 16 | ProxySQL is a high-performance SQL proxy. Details at [ProxySQL](http://www.proxysql.com/) website. 17 | 18 | ## Image Description ## 19 | 20 | This image is maintained by Severalnines and will be updated regularly on best-effort basis. The image is based on Debian 11 (Bullseye) and consists of: 21 | * mysql/mariadb client 22 | * ProxySQL package for Debian 11 23 | 24 | ## Run ## 25 | 26 | To run a ProxySQL container with a custom ProxySQL configuration file: 27 | ```bash 28 | $ docker run -d \ 29 | --name proxysql2 \ 30 | --publish 6033:6033 \ 31 | --publish 6032:6032 \ 32 | --publish 6080:6080 \ 33 | --restart=unless-stopped \ 34 | -v /root/proxysql/proxysql.cnf:/etc/proxysql.cnf \ 35 | severalnines/proxysql 36 | ``` 37 | 38 | For a list of available Docker image version, please refer to [Supported Tags](#supported-tags) section. 39 | 40 | ## Example Configurations, proxysql.cnf ## 41 | 42 | For Kubernetes, check out the following blog posts for explanation and examples: 43 | * [MySQL on Docker: Running ProxySQL as a Helper Container on Kubernetes](https://severalnines.com/blog/mysql-docker-running-proxysql-helper-container-kubernetes) 44 | * [MySQL on Docker: Running ProxySQL as Kubernetes Service](https://severalnines.com/blog/mysql-docker-running-proxysql-kubernetes-service) 45 | * [MySQL on Docker: ProxySQL Native Clustering with Kubernetes](https://severalnines.com/database-blog/mysql-docker-proxysql-native-clustering-kubernetes) 46 | 47 | Here are some examples of ProxySQL configuration: 48 | - [Galera (ProxySQL 2.x) with web stats port 6080](#galera-proxysql-2x-with-web-stats-port-6080) 49 | - [Galera (ProxySQL 1.x)](#galera-proxysql-1x) 50 | - [MySQL Replication](#mysql-replication) 51 | 52 | For greater detail and explanation, check out [How to Run and Configure ProxySQL 2.0 for MySQL Galera Cluster on Docker](https://severalnines.com/blog/how-run-and-configure-proxysql-20-mysql-galera-cluster-docker). 53 | 54 | You can also find some examples of proxysql.cnf in the official repository: https://github.com/sysown/proxysql/blob/master/doc/configuration.md 55 | 56 | ### Galera (ProxySQL 2.x) with web stats port 6080 ### 57 | 58 | ```bash 59 | datadir="/var/lib/proxysql" 60 | 61 | admin_variables= 62 | { 63 | admin_credentials="admin:admin" 64 | mysql_ifaces="0.0.0.0:6032" 65 | refresh_interval=2000 66 | web_enabled=true 67 | web_port=6080 68 | stats_credentials="stats:admin" 69 | } 70 | 71 | mysql_variables= 72 | { 73 | threads=4 74 | max_connections=2048 75 | default_query_delay=0 76 | default_query_timeout=36000000 77 | have_compress=true 78 | poll_timeout=2000 79 | interfaces="0.0.0.0:6033;/tmp/proxysql.sock" 80 | default_schema="information_schema" 81 | stacksize=1048576 82 | server_version="5.1.30" 83 | connect_timeout_server=10000 84 | monitor_history=60000 85 | monitor_connect_interval=200000 86 | monitor_ping_interval=200000 87 | ping_interval_server_msec=10000 88 | ping_timeout_server=200 89 | commands_stats=true 90 | sessions_sort=true 91 | monitor_username="proxysql" 92 | monitor_password="proxysqlpassword" 93 | monitor_galera_healthcheck_interval=2000 94 | monitor_galera_healthcheck_timeout=800 95 | } 96 | 97 | mysql_galera_hostgroups = 98 | ( 99 | { 100 | writer_hostgroup=10 101 | backup_writer_hostgroup=20 102 | reader_hostgroup=30 103 | offline_hostgroup=9999 104 | max_writers=1 105 | writer_is_also_reader=2 106 | max_transactions_behind=30 107 | active=1 108 | } 109 | ) 110 | 111 | mysql_servers = 112 | ( 113 | { address="db1.cluster.local" , port=3306 , hostgroup=10, max_connections=100 }, 114 | { address="db2.cluster.local" , port=3306 , hostgroup=10, max_connections=100 }, 115 | { address="db3.cluster.local" , port=3306 , hostgroup=10, max_connections=100 } 116 | ) 117 | 118 | mysql_query_rules = 119 | ( 120 | { 121 | rule_id=100 122 | active=1 123 | match_pattern="^SELECT .* FOR UPDATE" 124 | destination_hostgroup=10 125 | apply=1 126 | }, 127 | { 128 | rule_id=200 129 | active=1 130 | match_pattern="^SELECT .*" 131 | destination_hostgroup=30 132 | apply=1 133 | }, 134 | { 135 | rule_id=300 136 | active=1 137 | match_pattern=".*" 138 | destination_hostgroup=10 139 | apply=1 140 | } 141 | ) 142 | 143 | mysql_users = 144 | ( 145 | { username = "wordpress", password = "passw0rd", default_hostgroup = 10, transaction_persistent = 0, active = 1 }, 146 | { username = "sbtest", password = "passw0rd", default_hostgroup = 10, transaction_persistent = 0, active = 1 } 147 | ) 148 | ``` 149 | 150 | ### Galera (ProxySQL 1.x) ### 151 | 152 | ```bash 153 | datadir="/var/lib/proxysql" 154 | 155 | admin_variables= 156 | { 157 | admin_credentials="admin:admin" 158 | mysql_ifaces="0.0.0.0:6032" 159 | refresh_interval=2000 160 | } 161 | 162 | mysql_variables= 163 | { 164 | threads=4 165 | max_connections=2048 166 | default_query_delay=0 167 | default_query_timeout=36000000 168 | have_compress=true 169 | poll_timeout=2000 170 | interfaces="0.0.0.0:6033;/tmp/proxysql.sock" 171 | default_schema="information_schema" 172 | stacksize=1048576 173 | server_version="5.1.30" 174 | connect_timeout_server=10000 175 | monitor_history=60000 176 | monitor_connect_interval=200000 177 | monitor_ping_interval=200000 178 | ping_interval_server_msec=10000 179 | ping_timeout_server=200 180 | commands_stats=true 181 | sessions_sort=true 182 | monitor_username="proxysql" 183 | monitor_password="proxysqlpassword" 184 | } 185 | 186 | mysql_servers = 187 | ( 188 | { address="db1.cluster.local" , port=3306 , hostgroup=10, max_connections=100 }, 189 | { address="db2.cluster.local" , port=3306 , hostgroup=10, max_connections=100 }, 190 | { address="db3.cluster.local" , port=3306 , hostgroup=10, max_connections=100 }, 191 | { address="db1.cluster.local" , port=3306 , hostgroup=20, max_connections=100 }, 192 | { address="db2.cluster.local" , port=3306 , hostgroup=20, max_connections=100 }, 193 | { address="db3.cluster.local" , port=3306 , hostgroup=20, max_connections=100 } 194 | ) 195 | 196 | mysql_query_rules = 197 | ( 198 | { 199 | rule_id=100 200 | active=1 201 | match_pattern="^SELECT .* FOR UPDATE" 202 | destination_hostgroup=10 203 | apply=1 204 | }, 205 | { 206 | rule_id=200 207 | active=1 208 | match_pattern="^SELECT .*" 209 | destination_hostgroup=20 210 | apply=1 211 | }, 212 | { 213 | rule_id=300 214 | active=1 215 | match_pattern=".*" 216 | destination_hostgroup=10 217 | apply=1 218 | } 219 | ) 220 | 221 | scheduler = 222 | ( 223 | { 224 | id = 1 225 | filename = "/usr/share/proxysql/tools/proxysql_galera_checker.sh" 226 | active = 1 227 | interval_ms = 2000 228 | arg1 = "10" 229 | arg2 = "20" 230 | arg3 = "1" 231 | arg4 = "1" 232 | arg5 = "/var/lib/proxysql/proxysql_galera_checker.log" 233 | } 234 | ) 235 | 236 | mysql_users = 237 | ( 238 | { username = "sbtest" , password = "passw0rd" , default_hostgroup = 10 , active = 1 } 239 | ) 240 | 241 | ``` 242 | 243 | ### MySQL Replication ### 244 | 245 | ```bash 246 | datadir="/var/lib/proxysql" 247 | 248 | admin_variables= 249 | { 250 | admin_credentials="admin:admin" 251 | mysql_ifaces="0.0.0.0:6032" 252 | refresh_interval=2000 253 | } 254 | 255 | mysql_variables= 256 | { 257 | threads=4 258 | max_connections=2048 259 | default_query_delay=0 260 | default_query_timeout=36000000 261 | have_compress=true 262 | poll_timeout=2000 263 | interfaces="0.0.0.0:6033;/tmp/proxysql.sock" 264 | default_schema="information_schema" 265 | stacksize=1048576 266 | server_version="5.1.30" 267 | connect_timeout_server=10000 268 | monitor_history=60000 269 | monitor_connect_interval=200000 270 | monitor_ping_interval=200000 271 | ping_interval_server_msec=10000 272 | ping_timeout_server=200 273 | commands_stats=true 274 | sessions_sort=true 275 | monitor_username="proxysql" 276 | monitor_password="proxysqlpassword" 277 | } 278 | 279 | mysql_replication_hostgroups = 280 | ( 281 | { writer_hostgroup=10 , reader_hostgroup=20 , comment="host groups" } 282 | ) 283 | 284 | mysql_servers = 285 | ( 286 | { address="master.replication.local" , port=3306 , hostgroup=10, max_connections=100 , max_replication_lag = 5 }, 287 | { address="slave1.replication.local" , port=3306 , hostgroup=20, max_connections=100 , max_replication_lag = 5 }, 288 | { address="slave2.replication.local" , port=3306 , hostgroup=20, max_connections=100 , max_replication_lag = 5 } 289 | ) 290 | 291 | mysql_query_rules = 292 | ( 293 | { 294 | rule_id=100 295 | active=1 296 | match_pattern="^SELECT .* FOR UPDATE" 297 | destination_hostgroup=10 298 | apply=1 299 | }, 300 | { 301 | rule_id=200 302 | active=1 303 | match_pattern="^SELECT .*" 304 | destination_hostgroup=20 305 | apply=1 306 | }, 307 | { 308 | rule_id=300 309 | active=1 310 | match_pattern=".*" 311 | destination_hostgroup=10 312 | apply=1 313 | } 314 | ) 315 | 316 | mysql_users = 317 | ( 318 | { username = "sbtest" , password = "password" , default_hostgroup = 10 , active = 1 } 319 | ) 320 | ``` 321 | --------------------------------------------------------------------------------