Lieur-Euy® Blog`s

MySQL Replication With Local and Hosting Server (WHM)

Basa basinya apa yah disini .. ??? mungkin sedikit catatan saja, apa yang sudah berhasil di oprek. intinya membuat replikasi database MySQL dari Server MySQL di Lokal (kantor) ke database MySQL Server Hosting di Alam Gaib sana.

[Informasi Saja]
Server Lokal (Kantor) = Master = 125.232.2x.xxx (Debian)
Server Hosting = Slave = 76.24.2x.xxx (Centos)
Database Name = cobadb
Database User = usercoba
Database Pass = rahasia123
MySQL Version Debian = mysql Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (i486) using readline 5.2
MySQL Version Centos = mysql Ver 14.12 Distrib 5.0.51a, for redhat-linux-gnu (i686) using readline 5.0
Login = root

Konfigurasi yang harus kita lakukan adalah :
————- Server Lokal (MASTER) : ————–

Edit file my.cnf :

root@thunderbox:~$ vim /etc/mysql/my.cnf

Pastikan pada bagian :

[mysqld]
...........
...........
# bind-address          = 127.0.0.1
...........
...........
[Dan Seterusnya]
#
# * Logging and Replication
#
...........
...........
[Dan Seterusnya]
server-id              = 1
log_bin                = /var/log/mysql/mysql-bin.log
binlog_do_db           = cobadb

Save :

:wq

Restart Service MySQL :

root@thunderbox:~$ /etc/init.d/mysql restart

Login ke MySQL Server dengan Login root :

root@thunderbox:~$ mysql -u root -p
Enter password:

Buat User dengan replication privileges:

mysql> GRANT REPLICATION SLAVE ON *.* TO 'usercoba'@'%' IDENTIFIED BY 'rahasia123';
mysql> FLUSH PRIVILEGES;
mysql> USE cobadb;
mysql> FLUSH TABLES WITH READ LOCK;
mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000005 |       98 | cobadb       |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)mysql> QUIT;

*) Simpan-Catat informasi diatas, karena akan digunakan untuk konfigurasi pada MySQL Slave Server Langkah terakhir adalah Unlock table cobadb yang sebelumnya kita lock

root@thunderbox:~$ mysql -u root -p
Enter password:
mysql> UNLOCK TABLES;
mysql> QUIT;

— Now the configuration on the master is finished. On to the slave… —


Read more…