FUDforum - خوراک RDF
http://fudforum.org/forum/index.php
slave database mysql
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=186548&th=123627#msg_186548
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).]]>demaglio2014-09-27T17:39:54-00:00Re: slave database mysql
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=186551&th=123627#msg_186551
That said, it should be very easy to change in the DB driver.]]>naudefj2014-09-27T18:25:51-00:00Re: slave database mysql
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=186552&th=123627#msg_186552
demaglio2014-09-27T18:35:51-00:00Re: slave database mysql
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=186553&th=123627#msg_186553
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');
}
}