Drupal 7 MySQL Error / Slave Replication

I'm having problems with Drupal 7.7 using a subordinate MySQL database.

My settings.php is as follows:

$databases['default']['default'] = array( 'driver' => 'mysql', 'database' => 'my_db', 'username' => 'dbuser', 'password' => 'dbpw', 'host' => 'db-ip-address' ); $databases['default']['slave'][] = array( 'driver' => 'mysql', 'database' => 'my_db', 'username' => 'dbuser', 'password' => 'dbpw', 'host' => '127.0.0.1' ); 

Replication itself works great. When I add new content to the site, it is quickly replicated to the subordinate.

However, looking at tcpdump, I never see a local database call.

Is there something I'm missing to enable Drupal to use a slave?

+4
source share
3 answers

Using subordinate databases is practically not performed in the Drupal core. If you are developing your own modules, then call db_query to indicate that they want to use a subordinate database using the $ options array. See DatabaseConnection :: defaultOptions for how to set this array.

+1
source

This problem has a really good answer to the same question: https://drupal.stackexchange.com/questions/10806/how-to-get-core-to-leverage-a-mysql-master-slave-configuration

It is possible that most of the main and contributing resources use a slave server to select, without fixing the kernel :)

+1
source

The AutoSlave module redirects SELECT queries to read-only replication databases, and which it accepts account replication lag.

According to the moduleโ€™s documents, it uses a read-only replicant when all of the following conditions are true:

  • A request is a select request.
  • The tables in the select query were not written during the query and within the estimated replication delay
  • The transaction has not been started.
  • The tables in the selection request are not specified in the "table" parameters in the driver settings.
  • The lock is not running (db kernel lock and memcache lock are supported)
0
source

All Articles