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… —
-———— Server Alam Gaib (WHM) (SLAVE) : ————–
Buat database :
root@thunderbox:~$ mysql -u root -p Enter password: mysql>CREATE DATABASE cobadb mysql> QUIT
Selanjutnya kita kudu ngasih tau si SLAVE akan bertindak sebagai Replikasi dari Master
Edit file my.cnf
Login sebagai root
root@gaib [~]# vim /etc/my.cnf
Pastikan pada bagian :
[mysqld] server-id=2 master_host=125.232.2x.xxx master_user=crew master_password=rahasia123 master_connect_retry=60 replicate_do_db=cobadb [client] port = 3306 set-variable = connect_timeout=14400
save
:wq
Restart Service MySQL :
root@gaib [~]# /etc/init.d/mysql restart
Langkah terakhir adalah :
root@gaib [~]# mysql -u root -p Enter password: mysql>SLAVE STOP mysql> CHANGE MASTER TO MASTER_HOST='125.232.2x.xxx', MASTER_USER='usercoba', MASTER_PASSWORD='rahasia123', MASTER_LOG_FILE='mmysql-bin.000005', MASTER_LOG_POS=98
*) Buka catatan yang tadi disimpan pagi configurasi Master diatas.
mysql>START SLAVE mysql> LOAD DATA FROM MASTER mysql> QUIT
That’s it! Now whenever cobadb is updated on the master, all changes will be replicated to cobadb on the slave. Test it!
Beres Dech (itu juga kalo gak ada error)
silakan di coba dengan phpmyadmin (MASTER dan SLAVE)
—————–
Kalo Gagal bin Tidak Berhasil :
- Tutorial ini salah and yang nulisnya masih cupu
- Jangan tanya sama yang nulis tutorial ini
- Jawaban ada pada Google
- Lebih lengkapnya ada di http://dev.mysql.com/doc/refman/5.1/en/replication.html (perimbon mysql)
- Mungkin metode ini bisa di terapkan dalam aplikasi SMS Gateway (polling) (Hallo om arie|ajalah) dengan menggunakan halaman web sebagai reportnya.

Leave a Reply