Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
375 views
in Technique[技术] by (71.8m points)

drupal - Proxysql Isn't sending data to MySQL replicas/slaves in a multi db cluster

TLDR; Proxysql isn't sending any data to or replicas. The master works just fine, and the replicas are all caught up, but they aren't serving traffic.

Overview: The main issue is that no traffic is going to the replicas:

  • We have 4 mysql clusters. Each one has a master, and two replicas.
  • The replicas are all caught up to master and replicating fine.
  • We are on... Drupal (sigh) for now, so we have multiple databases per cluster. All with their own proxysql user and default host group.
  • Proxysql shows null on connection errors to the replicas. It looks like it can connect.
  • But all the traffic just hits the master. It serves all select, update, and delete statement.
  • We have our masters and replicas set up in their own write and read groups (not in the same host group as we'd prefer to manually dictate which is a master and which are replicas).

Question: How do we get data hitting our replicas and not just the master?

Configs:

mysql_users=
(
{ username = "company1", password = "aaaaaabbbbbbccccccdddddddfffffff", default_hostgroup = 10, max_connections = 200, active = 1, transaction_persistent = 0 },
{ username = "company2", password = "aaaaaabbbbbbccccccdddddddggggggg", default_hostgroup = 10, max_connections = 200, active = 1, transaction_persistent = 0 },
{ username = "company3", password = "aaaaaabbbbbbccccccdddddddhhhhhhh", default_hostgroup = 20, max_connections = 200, active = 1, transaction_persistent = 0 },
{ username = "company4", password = "aaaaaabbbbbbccccccdddddddiiiiiii", default_hostgroup = 20, max_connections = 200, active = 1, transaction_persistent = 0 }
.... and lots more. 
)

mysql_servers =
(
# Cluster 1 (Master|Write Hostgroup)
{ address = "10.0.0.1", port  = 3306, hostgroup = 10, status = "ONLINE", weight = 1000, compression = 0, max_replication_lag = 2, max_connections = 300, max_latency_ms = 2000, comment="Cluster 1 (Master DB-1)" },
# Cluster 1 (Slave|Read Hostgroup)
{ address = "10.0.0.2", port  = 3306, hostgroup = 11, status = "ONLINE", weight = 1000, compression = 0, max_replication_lag = 2, max_connections = 300, max_latency_ms = 2000, comment="Cluster 1 (Slave DB-2)" },
{ address = "10.0.0.3", port  = 3306, hostgroup = 11, status = "ONLINE", weight = 1000, compression = 0, max_replication_lag = 2, max_connections = 300, max_latency_ms = 2000, comment="Cluster 1 (Slave DB-3)" },

# Cluster 2 (Master|Write Hostgroup)
{ address = "10.0.0.4", port  = 3306, hostgroup = 20, status = "ONLINE", weight = 1000, compression = 0, max_replication_lag = 2, max_connections = 300, max_latency_ms = 2000, comment="Cluster 2 (Master DB-4)" },  
# Cluster 2 (Slave|Read Hostgroup)
{ address = "10.0.0.5", port  = 3306, hostgroup = 21, status = "ONLINE", weight = 1000, compression = 0, max_replication_lag = 2, max_connections = 300, max_latency_ms = 2000, comment="Cluster 2 (Slave DB-5)" },
{ address = "10.0.0.6", port  = 3306, hostgroup = 21, status = "ONLINE", weight = 1000, compression = 0, max_replication_lag = 2, max_connections = 300, max_latency_ms = 2000, comment="Cluster 2 (Slave DB-6)" },
)

mysql_replication_hostgroups=
(
# Cluster 1
{ writer_hostgroup=10, reader_hostgroup=11, comment="Cluster 1 Master / Slave 1 " },
# Cluster 2 
{ writer_hostgroup=20, reader_hostgroup=21, comment="Cluster 2 Master / Slave 1" },
)

mysql_query_rules=
(
  { rule_id = 1, active = 0, match_digest = ".", log = 1, apply = 0 },
  { rule_id = 2, active = 1, match_digest = "^SELECTsname,stypesfromssystemsWHEREsstatus.*", cache_ttl = 3600000, flagOUT = 2, apply = 1 },
  { rule_id = 3, active = 1, match_digest = "SELECTsDISTINCTsregistry.namesASsname,sregistry.filenamesASsfilenamesFROMsregistry.*", cache_ttl = 3600000, flagOUT = 2, apply = 1 },
  { rule_id = 4, active = 1, match_digest = "SELECTs.*sFROMsmenu_routersWHEREspathsIN.*", cache_ttl = 3600000, flagOUT = 2, apply = 1 },
  { rule_id = 5, active = 1, match_digest = "SELECTsbase.vidsASsvid,sbase.namesASsname,sbase.machine_namesASsmachine_name,sbase.descriptionsASsdescription,sbase.hierarchysASshierarchy,sbase.modulesASsmodule,sbase.weightsASsweightsFROMstaxonomy_vocabularysbasesWHERE", cache_ttl = 300000, flagOUT = 2, apply = 1 },
  { rule_id = 6, active = 1, match_digest = "^SELECTsnid,sdatasFROMscompany_sync_nodes", flagOUT = 2, apply = 1 },
  { rule_id = 7, active = 1, match_digest = "^SELECTsclient_name_displaysFROMsiss_dispatch_clients", flagOUT = 2, apply = 1 },
  { rule_id = 8, active = 1, match_digest = "SELECTsf.fidsASsfidsFROMsfile_managedsfsWHEREs(f.statuss=s.*)sANDs(f.urisLIKEs.*sESCAPEs.*)sANDs(f.urisNOTsLIKEs.*sESCAPEs.*)sANDs(f.filemimesNOTsLIKEs.*sESCAPEs.*sORDERsBYsf.fidsDESCsLIMITs.*sOFFSETs.*", flagOUT = 2, apply = 1 },
  { rule_id = 9, active = 1, digest = "0x6C21FFE9B05A6873", flagOUT = 2, apply = 1 },
  { rule_id = 10, active = 1, digest = "0x6C21FFE9B05A6873", flagOUT = 2, apply = 1 },
  { rule_id = 11, active = 1, digest = "0x7E8E89B6752B147F", flagOUT = 2, apply = 1 },
  { rule_id = 12, active = 1, digest = "0xF41E2E690383C416", flagOUT = 2, apply = 1 },
  { rule_id = 13, active = 1, match_pattern = ".*ProxySQLSendToSlave.*", flagOUT = 2, apply = 1 },
  { rule_id = 99, active = 1, match_digest = ".", flagOUT = 1, apply = 1 }
)

mysql_variables=
{
  threads=4
  max_connections=2048
  connection_max_age_ms=1200000
  max_transaction_idle_time=1200000
  monitor_replication_lag_count=3
  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="myusername"
  monitor_password="mypassword"
  monitor_history=600000
  monitor_connect_interval=30000
  monitor_slave_lag_when_null=60
  monitor_replication_lag_interval=30000
  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
  monitor_writer_is_also_reader=false
  eventslog_filename="queries.log"
  log_unhealthy_connections="false"
  query_cache_size_MB=2000
}
question from:https://stackoverflow.com/questions/66068255/proxysql-isnt-sending-data-to-mysql-replicas-slaves-in-a-multi-db-cluster

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The answer is that mysql_query_rules_fast_routing rules don't get applied if the last mysql_query_rules rule has an apply of 1. You need to leave that as apply=0 and then the fast query rules will then get applied.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...