FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » Database discussions » slave database mysql
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
slave database mysql [message #186548] Sat, 27 September 2014 17:39 Go to next message
demaglio is currently offline  demaglio   Italy
Messages: 7
Registered: August 2014
Karma: 0
Junior Member
Hi,
I have install fudforum.
I have two mysql database on two machine. One as master and one as slave.
In fudforum administration I insert Database Server and Database Slave Server.
with mysql -u user -p I see that on the machine with Master I connect with mysql on slave server. Slave is update by master.
If I stopped mysql on master Server forum go down. I'm in error or if master is down fudforum connect to slave mysql?
In apache log I have only an error that fudforum cannot connect the master(is down).
Re: slave database mysql [message #186551 is a reply to message #186548] Sat, 27 September 2014 18:25 Go to previous messageGo to next message
naudefj is currently offline  naudefj   
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
The current implementation is for offloading queries to the slave database, not for fail-over.
That said, it should be very easy to change in the DB driver.
Re: slave database mysql [message #186552 is a reply to message #186551] Sat, 27 September 2014 18:35 Go to previous messageGo to next message
demaglio is currently offline  demaglio   Italy
Messages: 7
Registered: August 2014
Karma: 0
Junior Member
ok, but in this case I must have not master slave mysql install, but master master. It's correct?
Re: slave database mysql [message #186553 is a reply to message #186552] Sat, 27 September 2014 19:21 Go to previous message
demaglio is currently offline  demaglio   Italy
Messages: 7
Registered: August 2014
Karma: 0
Junior Member
Hi, sorry for my other post.
In index .php I have:
db::$db = new mysqli($GLOBALS['DBHOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD'], $GLOBALS['DBHOST_DBNAME'], NULL, $socket);
if (mysqli_connect_errno()) {
fud_sql_error_handler('Failed to establish database connection', 'MySQLi says: '. mysqli_connect_error(), mysqli_connect_errno(), '');
}
db::$db->set_charset('utf8');

/* Connect to slave, if specified. */
if (!empty($GLOBALS['DBHOST_SLAVE_HOST']) && !$GLOBALS['is_post']) {
db::$slave = new mysqli($GLOBALS['DBHOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD'], $GLOBALS['DBHOST_DBNAME'], NULL, $socket);
if (mysqli_connect_errno()) {
fud_logerror('Unable to init SlaveDB, fallback to MasterDB: '. mysqli_connect_error(), 'sql_errors');
} else {
db::$db->set_charset('utf8');
}
}
but I thinks that is:
db::$slave = new mysqli($GLOBALS['DBHOST_SLAVE_HOST''], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD'], $GLOBALS['DBHOST_DBNAME'], NULL, $socket);

for my problem I have:
db::$db = new mysqli($GLOBALS['DBHOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD'], $GLOBALS['DBHOST_DBNAME'], NULL, $socket);
if (mysqli_connect_errno()) {
if (!empty($GLOBALS['DBHOST_SLAVE_HOST']) && !$GLOBALS['is_post']) {
db::$db = new mysqli($GLOBALS['DBHOST_SLAVE_HOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD'], $GLOBALS['DBHOST_DBNAME'], NULL, $socket);
if (mysqli_connect_errno()) {
fud_logerror('Unable to init SlaveDB, fallback to MasterDB: '. mysqli_connect_error(), 'sql_errors');
} else {
db::$db->set_charset('utf8');
}
}


}
//db::$db->set_charset('utf8');

/* Connect to slave, if specified. */
if (!empty($GLOBALS['DBHOST_SLAVE_HOST']) && !$GLOBALS['is_post']) {
db::$slave = new mysqli($GLOBALS['DBHOST_SLAVE_HOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD'], $GLOBALS['DBHOST_DBNAME'], NULL, $socket);
if (mysqli_connect_errno()) {
db:$$slave=null;
} else {
db::$db->set_charset('utf8');
}
}

[Updated on: Sun, 28 September 2014 21:03]

Report message to a moderator

  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Holes in MYSQL Databases?
Next Topic: database dump and phpmyadmin..
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Dec 03 17:01:34 GMT 2024

Total time taken to generate the page: 0.02374 seconds