Ejemplo n.º 1
0
/**
 * @param String $user - replication user on master
 * @param String $password - password for the user
 * @param String $host - master's hostname or IP
 * @param int $port - port, where mysql is running
 * @param array $pos - position of mysql replication, array should contain fields File and Position
 * @param boolean $stop - shall we stop slave?
 * @param boolean $start - shall we start slave?
 * @param mixed $link - mysql link
 *
 * @return output of CHANGE MASTER mysql command
 */
function PMA_replication_slave_change_master($user, $password, $host, $port, $pos, $stop = true, $start = true, $link = null)
{
    if ($stop) {
        PMA_replication_slave_control("STOP", null, $link);
    }
    $out = PMA_DBI_try_query('CHANGE MASTER TO ' . 'MASTER_HOST=\'' . $host . '\',' . 'MASTER_PORT=' . $port * 1 . ',' . 'MASTER_USER=\'' . $user . '\',' . 'MASTER_PASSWORD=\'' . $password . '\',' . 'MASTER_LOG_FILE=\'' . $pos["File"] . '\',' . 'MASTER_LOG_POS=' . $pos["Position"] . ';', $link);
    if ($start) {
        PMA_replication_slave_control("START", null, $link);
    }
    return $out;
}
Ejemplo n.º 2
0
     if ($GLOBALS['sr_slave_action'] == 'reset') {
         PMA_replication_slave_control("STOP");
         PMA_DBI_try_query("RESET SLAVE;");
         PMA_replication_slave_control("START");
     } else {
         PMA_replication_slave_control($GLOBALS['sr_slave_action'], $GLOBALS['sr_slave_control_parm']);
     }
     $refresh = true;
 } elseif (isset($GLOBALS['sr_slave_skip_error'])) {
     $count = 1;
     if (isset($GLOBALS['sr_skip_errors_count'])) {
         $count = $GLOBALS['sr_skip_errors_count'] * 1;
     }
     PMA_replication_slave_control("STOP");
     PMA_DBI_try_query("SET GLOBAL SQL_SLAVE_SKIP_COUNTER = " . $count . ";");
     PMA_replication_slave_control("START");
 } elseif (isset($GLOBALS['sl_sync'])) {
     // TODO username, host and port could be read from 'show slave status',
     // when asked for a password this might work in more situations then just after changing master (where the master password is stored in session)
     $src_link = PMA_replication_connect_to_master($_SESSION['replication']['m_username'], $_SESSION['replication']['m_password'], $_SESSION['replication']['m_hostname'], $_SESSION['replication']['m_port']);
     $trg_link = null;
     // using null to indicate the current PMA server
     //Todo
     //$data = PMA_DBI_fetch_result('SHOW MASTER STATUS', null, null, $src_link); // let's find out, which databases are replicated
     $do_db = array();
     $ignore_db = array();
     $dblist = array();
     if (!empty($data[0]['Binlog_Do_DB'])) {
         $do_db = explode(',', $data[0]['Binlog_Do_DB']);
     }
     if (!empty($data[0]['Binlog_Ignore_DB'])) {