EnderUNIX Team.


EnderUNIX İpucu

Arkadaşıma gönder , Ana Sayfa

[ MySQL ]

"Mysql'da replication." - Halil Demirezen - (2006-04-14 14:56:09)   [3693]

Mysql replication master olarak seçilen databaseda bellirli bir
objeyi - database, tablo, vs - slave olarak seçilen databaselere
senkronize etmek için kullanilir.

örnek setup:

master : aaa.aaa.aaa.aaa
slave1 : bbb.bbb.bbb.bbb
slave2 : ccc.ccc.ccc.ccc

"master"de my.cnf dosyasina:

server-id = 1
log-bin

satırları eklenir. Değişikliklerin aktif olabilmesi için mysql restart edilir.



mysql> GRANT REPLICATION SLAVE ON *.* to slave_user@'bbb.bbb.bbb.bbb' identified by 'slave_password'
mysql> GRANT RELOAD ON *.* to slave_user@'bbb.bbb.bbb.bbb' identified by 'slave_password';
mysql> GRANT SUPER,REPLICATION CLIENT ON *.* to slave_user@'bbb.bbb.bbb.bbb' identified by 'slave_password';

mysql> GRANT REPLICATION SLAVE ON *.* to slave_user@'ccc.ccc.ccc.ccc' identified by 'slave_password'
mysql> GRANT RELOAD ON *.* to slave_user@'ccc.ccc.ccc.ccc' identified by 'slave_password';
mysql> GRANT SUPER,REPLICATION CLIENT ON *.* to slave_user@'ccc.ccc.ccc.ccc' identified by 'slave_password';

"slave1"de my.cnf dosyasinda, (replicate-do-table ile replicate yapilacak tablolar belirleniyor)

server-id = 2
master-host =aaa.aaa.aaa.aaa
master-user = slave_user
master-password=slave_password
master-port = 3306
replicate-do-table=db.TABLE1
replicate-do-table=db.TABLE2
replicate-do-table=db.TABLE3
replicate-do-table=db.TABLE4

"slave2"de my.cnf dosyasinda

server-id = 3
master-host =aaa.aaa.aaa.aaa
master-user = slave_user
master-password=slave_password
master-port = 3306
replicate-do-table=db.TABLE1
replicate-do-table=db.TABLE2
replicate-do-table=db.TABLE3
replicate-do-table=db.TABLE4

eklentileri yapilir ve herbir slave makinada mysqller tekrar başlatılır.

slave1 veya slave2 de

mysql> load data from master
mysql> slave start

edilir.

slavelerde,

mysql> show slave status\G; ile

************************** 1. row **************************
Slave_IO_State: Waiting for master to send event
Master_Host: aaa.aaa.aaa.aaa
Master_User: slave_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: bin-log.000001
Read_Master_Log_Pos: 160158
Relay_Log_File: smlcpurgw1-relay-bin.000001
Relay_Log_Pos: 59186
Relay_Master_Log_File: bin-log.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table: db.TABLE1,db.TABLE2,db.TABLE3,db.TABLE4
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 160158
Relay_Log_Space: 59186
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: 0
1 row in set (0.00 sec)

ERROR:
No query specified

elde edilir.

buradaki Read_Master_Log_Pos: 160158 ile

master makinadaki

mysql> show master status;
+-----------------------------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-----------------------------------+------------------+
| bin-log.000001 | 160158 | | |
+-----------------------------------+------------------+
1 row in set (0.00 sec)

daki position: 160158 degerinin aynı olduğu görülür.

masterin bin-log position ile slave lerdeki positionlar eşit olduğu sürece
master-slave sistemi senkronize demektir.


Arkadaşıma gönder , Ana Sayfa