ludicrousdb icon indicating copy to clipboard operation
ludicrousdb copied to clipboard

Failover?

Open stevenmunro opened this issue 6 years ago • 5 comments

I might be completely missing something here. If I take the DB server specified in wp-config.php offline, I get the dreaded 'Error establishing a database connection' message. I thought that one of the other servers defined in db-config.php would kick in?

stevenmunro avatar Jan 19 '18 22:01 stevenmunro

I just had a look at https://github.com/stuttter/ludicrousdb/issues/36 and it appears that perhaps mine isn't loading either. I'll do some more troubleshooting.

stevenmunro avatar Jan 19 '18 22:01 stevenmunro

It wasn't working because line 20 was being executed (return;) in ludicrousdb.php // Bail if database object is already set

I have no idea why $GLOBALS['wpdb'] would already be set. I had previously experimented with hyperDB and that worked..

stevenmunro avatar Jan 19 '18 22:01 stevenmunro

It works for me if I place the ludicrousdb files in the plugins folder. I was having issues when these were placed under mu-plugins.

stevenmunro avatar Jan 21 '18 22:01 stevenmunro

@stevenmunro - Hi Steve, apologies for hijacking the thread, but did you manage to get this working with a "failover" type scenario? And if so, how on earth did you manage it?? I have a multisite set up, with a master and slave MySQL both working as they should in a private network, but when I added this to the plugins directory and activated, I was expecting to be able to "reset" my master db and while that was whirring away for a few seconds, still be able to access the sites as the slave would kick in?

Any help or advice would be much appreciated ;¬)

The error I'm getting is:

Warning: mysqli_real_connect(): (HY000/2002): Connection refused in /var/www/html/wp-includes/wp-db.php on line 1531.

I'm using Php7 and MySQL 5.7 - cheers!

digitalle avatar May 24 '18 22:05 digitalle

hey digitalle,

the reason you get this error is that WP is writing something to db on (almost) all requests, but since your master (for writes) is down, you get this error. (I assume you have activated the plugin, placed db.php in your wp-content folder & set up db-config.php correctly of course)

hyperdb/ludicrousdb mostly is for splitting reads among multiple slaves or failover of read slaves. if you have a mysql cluster (or master-master) you can also failover writes by specifiying a higher value for 'write' => for the backup master in db-config.php, then it should work for you.

Important to notice is that you might still get this error (but only in error log) bc the plugin tries to connect to a downed server, before it finds one that works.

kkmuffme avatar Nov 14 '18 19:11 kkmuffme