The Blog

Uncategorized

MySQL replication and IP address change

Posted on

In the recent past, for a variety of reasons, I occasionally had to change the IP address of a MySQL master in a replicated environment.

It was a major annoyance that it was not sufficient to just change the IP address in the MySQL configuration file for slaves and then restart the server. Instead, I basically had to start from scratch, setting up replication anew. There had to be an easier way.

Well, there is. What you basically need to do is ensure that the slave is fully caught up (to the point when it was disconnected from the master). Then, stop the slave, adjust slave parameters, and restart.

Which parameters, you ask? Well, the address of the master, the name of the master log file, and the position within the file. The latter two can be obtained by viewing the slave status:

mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
             Slave_IO_State: Reconnecting after a failed master event read
                Master_Host: 10.0.0.1
                Master_User: replicate
                Master_Port: 3306
              Connect_Retry: 60
            Master_Log_File: mysql-bin.000005
        Read_Master_Log_Pos: 11622542
             Relay_Log_File: mysqld-relay-bin.000074
              Relay_Log_Pos: 11622679
      Relay_Master_Log_File: mysql-bin.000005
           Slave_IO_Running: No
          Slave_SQL_Running: Yes
            Replicate_Do_DB:
        Replicate_Ignore_DB: mythconverg
         Replicate_Do_Table:
     Replicate_Ignore_Table:
    Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
                 Last_Errno: 0
                 Last_Error:
               Skip_Counter: 0
        Exec_Master_Log_Pos: 11622542
            Relay_Log_Space: 11622679
            Until_Condition: None
             Until_Log_File:
              Until_Log_Pos: 0
         Master_SSL_Allowed: No
         Master_SSL_CA_File:
         Master_SSL_CA_Path:
            Master_SSL_Cert:
          Master_SSL_Cipher:
             Master_SSL_Key:
      Seconds_Behind_Master: NULL
1 row in set (0.00 sec)

The next step is to stop the slave:

mysql> STOP SLAVE;

Next comes the aforementioned change of replication parameters, which can be accomplished by issuing the following command:

mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.1',
MASTER_LOG_FILE='mysql-bin.000005', MASTER_LOG_POS=11622542;

The value of MASTER_HOST is, of course, the new IP address of the master. The MASTER_LOG_FILE and MASTER_LOG_POS values come from the output SHOW SLAVE STATUS command above.

Finally, restart the slave:

mysql> START SLAVE;

That’s it. Do verify though that the slave is working properly by reissuing the SHOW SLAVE STATUS command a few times, watching as the slave catches up with the master.

Posted in Uncategorized Leave a comment

How to retrieve a saved ftp password from phpStorm?

Posted on

This method can only be used in the version of 2016.1 or before. For newer version (probably 2016.2), they changed the encode method. There is no clue for me to decode it.

Open C:\Users\.WebIde100\config\options\webServers.xml Find your FTP and get the encrypted password from the password attribute. Decrypt the password. I have written a PHP script to decrypt the string:


$pwd = "Your encrypted password here.";
$decrypted = '';

while (strlen($pwd) > 0) {
$decrypted .= chr(hexdec(substr($pwd, 0, 4)) ^ hexdec('dfaa'));
$pwd = substr($pwd, 4, strlen($pwd) - 1);
}
echo $decrypted;

Posted in Uncategorized Leave a comment
« Previous PageNext Page »