I had an issue when activating the slave. ProxySQL started to direct write queries to it.
This is the current configuration:
datadir="/var/lib/proxysql"
admin_variables=
{
admin_credentials="x:y"
mysql_ifaces="127.0.0.1:6032"
# refresh_interval=2000
debug=true
}
mysql_variables=
{
threads=8
max_connections=1000
default_query_delay=0
default_query_timeout=36000000
have_compress=true
poll_timeout=2000
# interfaces="0.0.0.0:6033;/tmp/proxysql.sock"
interfaces="127.0.0.1:3306"
default_schema="information_schema"
stacksize=1048576
server_version="5.7.23"
connect_timeout_server=3000
monitor_username="x"
monitor_password="y"
monitor_history=600000
monitor_connect_interval=60000
monitor_ping_interval=1500
monitor_read_only_interval=1500
monitor_read_only_timeout=500
monitor_replication_lag_interval=1000
monitor_slave_lag_when_null=86400
ping_interval_server_msec=120000
ping_timeout_server=500
commands_stats=true
sessions_sort=true
connect_retries_on_failure=10
}
# defines all the MySQL servers
mysql_servers =
(
{ address="10.164.0.4", port=3306, hostgroup=10 },
{ address="10.164.0.4", port=3306, hostgroup=20 },
{ address="10.164.0.11", port=3306, hostgroup=20, max_replication_lag=1 },
{ address="10.164.0.12", port=3306, hostgroup=20, max_replication_lag=1 }
)
mysql_replication_hostgroups =
(
{ writer_hostgroup=10, reader_hostgroup=20, comment="Master/Slave" }
)
mysql_users:
(
{ username = "x", password = "y", default_hostgroup = 10, active = 1}
)
10.164.0.4 is the master, stick in hostgrup 10 and hostgroup 20
hostgroup 10 is write-only
hostgroup 20 is read-only
10.164.0.11 and 10.164.0.12 are read only slaves (only 10.164.0.11 will be powered on, when needed) and they are both stick to hostgroup 20
When 10.164.0.11 is up, proxysql detect it properly, wait for it to be in sync (replication lag < 1 second) but when ready, it tries to use it for write operations:
2018-11-25 19:53:54 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:53:55 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'b'
2018-11-25 19:53:55 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:53:56 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1290, The MySQL server is running with the --read-only option so it cannot execute this statement
2018-11-25 19:53:56 MySQL_Session.cpp:95:kill_query_thread(): [WARNING] KILL CONNECTION 138 on 10.164.0.11:3306
2018-11-25 19:53:56 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:53:56 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:53:57 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:53:57 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1290, The MySQL server is running with the --read-only option so it cannot execute this statement
2018-11-25 19:53:57 MySQL_Session.cpp:95:kill_query_thread(): [WARNING] KILL CONNECTION 180 on 10.164.0.11:3306
2018-11-25 19:53:57 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:53:57 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:53:58 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'c'
2018-11-25 19:53:59 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:53:59 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:54:00 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:54:00 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'a'
2018-11-25 19:54:01 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, INSERT command denied to user 'x'@'10.164.0.3' for table 'd'
2018-11-25 19:54:01 MySQL_Session.cpp:2949:handler(): [WARNING] Error during query on (20,10.164.0.11,3306): 1142, UPDATE command denied to user 'x'@'10.164.0.3' for table 'e'
What i’m missing?
Any time we change the configuration from the configuration file, we call
LOAD MYSQL VARIABLES FROM CONFIG;
SAVE MYSQL VARIABLES TO DISK;
Is this enough ?