I am having trouble getting Drupal 7.7 to use a MySQL slave 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 is working great. When I add new content to the site it quickly is replicated on the slave.
Looking at tcpdump though, I never see a call to the local database.
Is there anything I’m missing to enable Drupal to use the slave?
Using slave databases is barely implemented in Drupal core. If you are developing your own modules then calls to db_query need to specify that they want to use the slave database using the $options array. See DatabaseConnection::defaultOptions for how to set this array.