REPLICATIONS MASTER-SLAVE MYSQL
Master Sever
untuk testing insert atau update table yang ada di master dan lihat table di slave
#/etc/init.d/mysqld stop (stopservice)
tambahkan pada
file my.cnf yang terletak pada /etc/mysql/
[mysqld]
server-id=1 (id server)
binlog-do-db=db(nama database)
log-bin=mysql-bin
innodb_flush_log_at_trx_commit=1
sync_binlog=1
#/etc/init.d/mysqld start (start service)
masuk ke sql konsole
mysql -u root -p
masukan rootpasswd sql
bikin user untuk login dari slave (slave_user)
grant replication slave on *.* to 'slave_user'@'%' identified by
'slave_user';
flush privileges;
use namadb;
flush tables with read lock;
show master status;
+---------------+----------+--------------+------------------+ | File | Position | Binlog_do_db | Binlog_ignore_db | +---------------+----------+--------------+------------------+ | mysql-bin.006 | 183 | namadb | | +---------------+----------+--------------+------------------+ 1 row in set (0.00 sec)
biar lebih gampang editnya bisa pake webmin
Slave Server
#/etc/init.d/mysqld stop (stopservice)
[mysqld]
server-id=2 (id server)
#/etc/init.d/mysqld start (start service)
masuk ke konsole sql
mysql -u root -p
masukan root passwd sql
Slave Stop;
Change Master To Master_Host='Ip-Host-Master',
Master_User='Slave_User',
Master_Password='Slave_User', Master_Log_File='Mysql-Bin.006',
Master_Log_Pos=138;
Start Slave;
Flush Privileges;
mysql>
show slave status \G;
*********1.
row *************
Slave_IO_State:
Waiting for master to send event
Master_Host:
172.26.11.102
Master_User:
slave_user
Master_Port:
3306
Connect_Retry:
60
Master_Log_File:
mysql-bin.000015
Read_Master_Log_Pos:
17793473
Relay_Log_File:
mysqld-relay-bin.000034
Relay_Log_Pos:17793619Relay_Master_Log_File:
mysql-bin.000015
Slave_IO_Running:
Yes
Slave_SQL_Running:
Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
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:
17793473
Relay_Log_Space:
17793819
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:
0
Master_SSL_Verify_Server_Cert:
No
Last_IO_Error:
Last_SQL_Errno:
0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
1
1
row in set (0.00 sec)
untuk testing insert atau update table yang ada di master dan lihat table di slave
Komentar
Posting Komentar