Replicazione

6.2.1/1

Come creare una replicazione su mySql

  1. Creare utente repl su i server MASTER e SLAVE
    Es.
    GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO repl@'192.168.1.%' IDENTIFIED BY 'mireplico';
  2. Inserire nel file di configurazione my.cnf (o my.ini) del SERVER questo
    log_bin =mysql-bin
    binlog-do-db=mymb
    binlog-ignore-db=mymedixal
    server_id = 10
  3. Riavviare mySql
    Nota: In replication status appare il log binario oppure digitare
    SHOW MASTER STATUS;
  4. Inserire nel file my.cnf (o my.ini) dello SLAVE questo:
    log_bin = mysql-bin
    server_id = 2
    relay_log = mysql-relay-bin
    log_slave_updates = 1
    #read_only = 0
    #replicate_wild_ignore_table=mysql.%
    #replicate_wild_ignore_db=%
    replicate_do_db=mymb
    replicate_ignore_db=mymedixal
    replicate_ignore_db=myad301
    replicate_ignore_db=myadoptfood
    replicate_wild_do_table=mymb.%


- server_id deve essere diverso da uno e univoco



  1. Avvio la replica sullo SLAVE
    Bisognerebbe farlo nel my.cnf ma cosi fa tutto da solo senza fermare il SERVER

CHANGE MASTER TO MASTER_HOST='webserver2',MASTER_USER='repl',MASTER_PASSWORD='mireplico',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=0;

  1. Avvio la replica sullo SLAVE

START SLAVE;

Per controllare se tutto va bene:

Su server SLAVE digitare:

SHOW SLAVE STATUS\G;

*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: <server master>
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 164
Relay_Log_File: mysql-relay-bin.000001
Relay_Log_Pos: 164
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
...omitted...
Seconds_Behind_Master: 0

Le parti in grassetto devono essere in questo modo:

SHOW PROCESSLIST\G;

*************************** 3. row ***************************
Id: 6
User: system user
Host:
db: NULL
Command: Connect
Time: 1146
State: Waiting for master to send event
Info: NULL
*************************** 4. row ***************************
Id: 7
User: system user
Host:
db: NULL
Command: Connect
Time: 491
State: Has read all relay log; waiting for the slave I/O thread to update it
Info: NULL

Devono esistere due righe dei due processi che si occupano della replicazione.

Sul MASTER invece digitare

SHOW PROCESSLIST\G;
*************************** 17. row ***************************
Id: 354
User: repl
Host: 89-96-132-12 begin_of_the_skype_highlighting              89-96-132-12      end_of_the_skype_highlighting.ip12.fastwebnet.it:3056
db: NULL
Command: Binlog Dump
Time: 588
State: Has sent all binlog to slave; waiting for binlog to be updated
Info: NULL

Deve esistere il processo che spedisce il log con l'host che ne fa richiesta.
Easyhand C/C++: Replicazione | Last modified: 17/02/2011 11.14.59 Europe/Rome | #1.861
P.. 1069
Easyhand C/C++
Una mano alle tue idee.
Privacy Policy