Jump to content

Using Slave Database Server


JimNutt

Recommended Posts

Has anyone had any luck with using a Slave server for reads?

 

I have added the slave to config/db_slave_server.inc.php

 

return array(
        array('server' => 'xxxxxxxxxxxxxxx.rds.amazonaws.com', 'user' => 'xxxxxx', 'password' => 'xxxxxxxx', 'database' => 'upshop'),
        );
 
I have set 
define('_PS_USE_SQL_SLAVE_', 1);
in config/defines.inc.php
 
I restarted apache just to be sure PS would pick up the settings, which it did, yet no activity on the slave server (more precisely no connection with the username provided in the connection string)
 
In classes/db/Db.php
I see 2 total servers (master + slave) if I echo $total_servers, I also see the correct server info if I echo self::$instance.
 
I have verified the following:
I can connect and run a select query against my slave server from the PS web server
I did try turning on debug profiling as I saw mention that it would indicate if queries were running against a slave, but I don't see anything that identifies if it is running against the master or the slave
define('_PS_DEBUG_PROFILING_', true);
 
So as far as I can tell PS is not using the Slave Server in any of the queries it is using, any help would be appreciated
 
 
 
Link to comment
Share on other sites

  • 2 years later...

I know this is late reply, but if anyone looking for answer this will be a time saving deal for them.

You need to use zero instead of 1 in the definition.

define('_PS_USE_SQL_SLAVE_', 0);

define('_PS_USE_SQL_SLAVE_', 1); Here, 1 will be used to consider data from master db instead of slave db.

 

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...