Chris Mague 2 rokov pred
commit
db7aaa979b
4 zmenil súbory, kde vykonal 134 pridanie a 0 odobranie
  1. 18 0
      README.md
  2. 38 0
      docker-compose.yml
  3. 71 0
      proxysql.cnf
  4. 7 0
      setup_servers.sql

+ 18 - 0
README.md

@@ -0,0 +1,18 @@
+## Checking the ProxySQL
+
+```
+mysql -u radmin -pradmin --protocol=tcp -h 127.0.0.1 -P16032 --prompt='RAdmin> '
+```
+
+## Connecting to the two MySQL DBs
+
+```
+mysql --protocol tcp  -P 3307 -u root -pmysql1
+mysql --protocol tcp  -P 3308 -u root -pmysql2
+```
+
+## Connectiong through the proxy
+
+```
+mysql --protocol tcp -P 16033 -u monitoruser -pmonitorpass
+```

+ 38 - 0
docker-compose.yml

@@ -0,0 +1,38 @@
+version: '3'
+
+services:
+  mysql1:
+    container_name: mysql1
+    command: --default-authentication-plugin=mysql_native_password
+    image: "mysql"
+    ports:
+      - "3307:3307"
+    environment:
+      - MYSQL_ROOT_PASSWORD=mysql1
+      - MYSQL_TCP_PORT=3307
+      - MYSQL_USER=monitoruser
+      - MYSQL_PASSWORD=monitorpass
+      - MYSQL_DATABASE=application
+  mysql2:
+    container_name: mysql2
+    image: "mysql"
+    ports:
+      - "3308:3308"
+    environment:
+      - MYSQL_ROOT_PASSWORD=mysql2
+      - MYSQL_TCP_PORT=3308
+      - MYSQL_USER=monitoruser
+      - MYSQL_PASSWORD=monitorpass
+      - MYSQL_DATABASE=application
+  mysqlproxy:
+    container_name: mysqlproxy
+    image: "proxysql/proxysql"
+    volumes: 
+      - ./proxysql.cnf:/etc/proxysql.cnf
+    links: 
+      - "mysql1:mysql1"
+      - "mysql2:mysql2"
+    ports:
+      - "16032:6032"
+      - "16033:6033"
+      - "16070:6070"

+ 71 - 0
proxysql.cnf

@@ -0,0 +1,71 @@
+datadir="/var/lib/proxysql"
+
+admin_variables=
+{
+	admin_credentials="admin:admin;radmin:radmin"
+	mysql_ifaces="0.0.0.0:6032"
+}
+
+global_variables=
+{
+	mysql-monitor_username="monitoruser"
+	mysql-monitor_password="monitorpass"
+	mysql-monitor_connect_interval=2000
+	mysql-monitor_ping_interval=1000
+	mysql-monitor_read_only_interval=2000
+}
+
+mysql_variables=
+{
+	threads=4
+	max_connections=2048
+	default_query_delay=0
+	default_query_timeout=36000000
+	have_compress=true
+	poll_timeout=2000
+	interfaces="0.0.0.0:6033"
+	default_schema="information_schema"
+	stacksize=1048576
+	server_version="5.5.30"
+	connect_timeout_server=3000
+	monitor_username="monitoruser"
+	monitor_password="monitorpass"
+	monitor_history=600000
+	monitor_connect_interval=60000
+	monitor_ping_interval=10000
+	monitor_read_only_interval=1500
+	monitor_read_only_timeout=500
+	ping_interval_server_msec=120000
+	ping_timeout_server=500
+	commands_stats=true
+	sessions_sort=true
+	connect_retries_on_failure=10
+}
+
+mysql_servers =
+(
+  {
+    address="mysql1"
+    port=3307
+    hostgroup=1
+    max_connections=200
+  },
+  {
+    address="mysql2"
+    port=3308
+    hostgroup=1
+    max_connections=200
+  }
+)
+
+mysql_users:
+(
+  {
+    username = "monitoruser"
+    password = "monitorpass"
+    default_hostgroup = 1
+    max_connections=1000
+    default_schema="application"
+    active = 1
+  }
+)

+ 7 - 0
setup_servers.sql

@@ -0,0 +1,7 @@
+INSERT INTO mysql_servers(hostgroup_id,hostname,port) VALUES (1,'mysql1',3307);
+INSERT INTO mysql_servers(hostgroup_id,hostname,port) VALUES (1,'mysql2',3308);
+UPDATE global_variables SET variable_value='monitoruser' WHERE variable_name='mysql-monitor_username';
+UPDATE global_variables SET variable_value='monitorpass' WHERE variable_name='mysql-monitor_password';
+UPDATE global_variables SET variable_value='2000' WHERE variable_name IN ('mysql-monitor_connect_interval','mysql-monitor_ping_interval','mysql-monitor_read_only_interval');
+LOAD MYSQL VARIABLES TO RUNTIME;
+SAVE MYSQL VARIABLES TO DISK;