Master/Slave Database [Deleted]

digitalpoint

Well-known member
digitalpoint submitted a new resource:

Master/Slave Database (version 1.0.0) - Gives XenForo master/slave database support

This gives master/slave database support to XenForo without needing to edit any standard XenForo files (other than adding your slave DB servers to your config.php file).

The "$25 cost" is actually the maximum cost for 1 month of premium membership on our site. If you are already a premium member, it's free (as is support and upgrades).

This is the database adapter we are using on https://forums.digitalpoint.com

Read more about this resource...
 
It should have an install.txt file with it... basically just need to install the database adapter and put the slave DB servers in your normal config.php file.

It's a little odd that it does have to use $GLOBALS for the slave DB servers, but there's no way around that unfortunately.
 
It should have an install.txt file with it... basically just need to install the database adapter and put the slave DB servers in your normal config.php file.

It's a little odd that it does have to use $GLOBALS for the slave DB servers, but there's no way around that unfortunately.

Thanks!
Is it possible to support Fail over for master/other slave?
 
As in the master DB failing or one of the slaves? Normally there's a lot that needs to happen on the backend (outside the application) to promote a slave to be a new master in the case of the master failing.

That being said, what I do is I have a servers.php file that I include in my XenForo config... the servers.php does nothing other than set the master and slave DB server variables... then there's a different monitoring process that monitors the servers and basically just updates that server.php file whenever that process decides it needs to rearrange servers for whatever reason.

But does this system control all your database servers and go through the monitoring process and promotion process? No.
 
I've just started to use Replication with your addon. Both servers are working fine. Load shares to slave server now.
Could you please share us some experiences on solving issues if: master down or die, slave down or die?

Thank you so much.
 
@digitalpoint

I have an error report:
After set read_only mysql variable to ON on slaves, wait some minutes, I see this error on /admin.php?logs/server-error :

Error Info
Zend_Db_Statement_Mysqli_Exception: Mysqli statement execute error : The MariaDB server is running with the --read-only option so it cannot execute this statement - library/Zend/Db/Statement/Mysqli.php:214
Generated By: 4 Love Lily, 14 minutes ago

Stack Trace
#0 /var/www/html/library/Zend/Db/Statement.php(297): Zend_Db_Statement_Mysqli->_execute(Array)
#1 /var/www/html/library/Zend/DigitalPoint/Mysqli.php(127): Zend_Db_Statement->execute(Array)
#2 /var/www/html/library/Zend/Db/Adapter/Abstract.php(753): DigitalPoint_Mysqli->query('?????SELECT *??...', 1451)
#3 /var/www/html/library/XenForo/Discussion/Definition/Thread.php(87): Zend_Db_Adapter_Abstract->fetchRow('?????SELECT *??...', 1451)
#4 /var/www/html/library/XenForo/DataWriter/Discussion.php(1170): XenForo_Discussion_Definition_Thread->getDiscussionForUpdate(Object(DigitalPoint_Mysqli), 1451)
#5 /var/www/html/library/XenForo/DataWriter/DiscussionMessage.php(449): XenForo_DataWriter_Discussion->getDiscussionForUpdate()
#6 /var/www/html/library/XenForo/DataWriter/DiscussionMessage.php(353): XenForo_DataWriter_DiscussionMessage->_setPosition()
#7 /var/www/html/library/XenForo/DataWriter.php(1434): XenForo_DataWriter_DiscussionMessage->_preSave()
#8 /var/www/html/library/XenForo/ControllerPublic/Thread.php(541): XenForo_DataWriter->preSave()
#9 /var/www/html/library/XenForo/FrontController.php(337): XenForo_ControllerPublic_Thread->actionAddReply()
#10 /var/www/html/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#11 /var/www/html/index.php(13): XenForo_FrontController->run()
#12 {main}

Request State
array(3) {
["url"] => string(84) "https://sandinh.com/threads/chắn-hội-kinh-bắc.1451/add-reply"
["_GET"] => array(1) {
["/threads/chắn-hội-kinh-bắc_1451/add-reply"] => string(0) ""
}
["_POST"] => array(9) {
["message_html"] => string(3099) "some removed html content"
["_xfRelativeResolver"] => string(83) "https://sandinh.com/threads/chắn-hội-kinh-bắc.1451/page-113"
["attachment_hash"] => string(32) "e3d90f5c1c59b9cdbffc7018f03af28e"
["last_date"] => string(10) "1375232240"
["last_known_date"] => string(10) "1375232240"
["_xfToken"] => string(8) "********"
["_xfRequestUri"] => string(64) "/threads/ch%E1%BA%AFn-h%E1%BB%99i-kinh-b%E1%BA%AFc.1451/page-113"
["_xfNoRedirect"] => string(1) "1"
["_xfResponseType"] => string(4) "json"
}
}
 
I think we could fix this error by changing DigitalPoint_Mysqli/ line 93
from
if (substr($sql, 0, 6) == 'SELECT')
to
if (substr($sql, 0, 6) == 'SELECT' && strpos(strtoupper($sql), 'FOR UPDATE') === false)
 
Yeah... looks like there are a couple places where the "FOR UPDATE" clauses is used. The above code should take care of it. Can you change it and let me know if it does indeed make the error go away for you? My DB servers aren't set up in a way that I'd see the error, so a little hard to test on my end.
 
How to config Master Slave in 2 individual server
I have 2 server individual use xenforo: 2DB, 2 Code file
1, Master xen: I copy folder DigitalPoint to -> library/Zend
I add code in config.php
$config['db']['adapterNamespace'] = 'DigitalPoint';
$GLOBALS['digitalPoint']['SlaveServerAll'][] = '192.168.1.1' -> replaced by ip Slave;
2, Slave xen ->
I copy folder DigitalPoint to -> library/Zend
I add code in config.php
$config['db']['adapterNamespace'] = 'DigitalPoint';
$GLOBALS['digitalPoint']['SlaveServerAll'][] = '192.168.1.1' -> replaced by ip Slave;

-> I test it not working. when i create a threads in server2, it DOESN'T has in server Master.
How to config in Slave server to know ip of master server?

Thanks you so much!
 
Back
Top Bottom