doc:appunti:linux:sa:mysql_replica_master_master
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:appunti:linux:sa:mysql_replica_master_master [2011/09/08 12:51] – [MySQL replica master-master] niccolo | doc:appunti:linux:sa:mysql_replica_master_master [2025/03/12 15:03] (current) – [Verifica dello stato SLAVE] niccolo | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| * **[[http:// | * **[[http:// | ||
| - | ===== Configurare la replica master-master | + | ===== Configurare la replica master-master ===== |
| + | |||
| + | Con questa configurazione si tiene replicato **un solo database**. | ||
| < | < | ||
| Line 47: | Line 49: | ||
| / | / | ||
| </ | </ | ||
| + | |||
| + | Per vedere se si sono assegnati i permessi di replica: | ||
| + | |||
| + | < | ||
| + | SHOW GRANTS FOR ' | ||
| + | </ | ||
| + | |||
| + | Ovviamente è opportuno concedere i grant non dall' | ||
| + | ===== Sincronizzare il db ===== | ||
| + | |||
| + | < | ||
| + | -- Su server1 | ||
| + | USE exampledb; | ||
| + | FLUSH TABLES WITH READ LOCK; | ||
| + | SHOW MASTER STATUS; | ||
| + | -- Prendere nota dello status. | ||
| + | -- Fare un dump e copiarlo sull' | ||
| + | UNLOCK TABLES; | ||
| + | |||
| + | -- Su server2 | ||
| + | -- mysqladmin --user=root --password stop-slave | ||
| + | CREATE DATABASE exampledb; | ||
| + | -- mysql -u root -p exampledb < exampledb.sql | ||
| + | USE exampledb; | ||
| + | FLUSH TABLES WITH READ LOCK; | ||
| + | SHOW MASTER STATUS; | ||
| + | -- Prendere nota dello status. | ||
| + | UNLOCK TABLES; | ||
| + | CHANGE MASTER TO MASTER_HOST=' | ||
| + | MASTER_PASSWORD=' | ||
| + | MASTER_LOG_POS=106; | ||
| + | START SLAVE; | ||
| + | SHOW SLAVE STATUS; | ||
| + | |||
| + | -- Su server1 | ||
| + | STOP SLAVE; | ||
| + | CHANGE MASTER TO MASTER_HOST=' | ||
| + | MASTER_PASSWORD=' | ||
| + | MASTER_LOG_POS=2359; | ||
| + | START SLAVE; | ||
| + | SHOW SLAVE STATUS; | ||
| + | </ | ||
| + | ===== Verifica dello stato SLAVE ===== | ||
| + | |||
| + | Come utente Unix root ci si collega al database MASTER/ | ||
| + | |||
| + | < | ||
| + | mysql dbname | ||
| + | </ | ||
| + | |||
| + | Per vedere lo stato di slave: | ||
| + | |||
| + | <code sql> | ||
| + | SHOW STATUS LIKE ' | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | +---------------+-------+ | ||
| + | | Variable_name | Value | | ||
| + | +---------------+-------+ | ||
| + | | Slave_running | ON | | ||
| + | +---------------+-------+ | ||
| + | </ | ||
| + | |||
| + | Per verificare lo stato di slave e in particolare il numero di log in corso di replica (**Relay_Master_Log_File**): | ||
| + | |||
| + | <code sql> | ||
| + | SHOW SLAVE STATUS\G; | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | MariaDB [dbname]> | ||
| + | *************************** 1. row *************************** | ||
| + | | ||
| + | Master_Host: | ||
| + | Master_User: | ||
| + | Master_Port: | ||
| + | Connect_Retry: | ||
| + | Master_Log_File: | ||
| + | Read_Master_Log_Pos: | ||
| + | | ||
| + | Relay_Log_Pos: | ||
| + | Relay_Master_Log_File: | ||
| + | | ||
| + | Slave_SQL_Running: | ||
| + | Replicate_Do_DB: | ||
| + | Replicate_Ignore_DB: | ||
| + | | ||
| + | | ||
| + | Replicate_Wild_Do_Table: | ||
| + | Replicate_Wild_Ignore_Table: | ||
| + | | ||
| + | | ||
| + | | ||
| + | Exec_Master_Log_Pos: | ||
| + | Relay_Log_Space: | ||
| + | Until_Condition: | ||
| + | | ||
| + | Until_Log_Pos: | ||
| + | | ||
| + | | ||
| + | | ||
| + | Master_SSL_Cert: | ||
| + | Master_SSL_Cipher: | ||
| + | | ||
| + | Seconds_Behind_Master: | ||
| + | Master_SSL_Verify_Server_Cert: | ||
| + | Last_IO_Errno: | ||
| + | Last_IO_Error: | ||
| + | | ||
| + | | ||
| + | Replicate_Ignore_Server_Ids: | ||
| + | | ||
| + | </ | ||
| + | |||
| + | Se **durante la sincronizzazione uno statement fallisce** si vede l' | ||
| + | |||
| + | <code sql> | ||
| + | STOP SLAVE; | ||
| + | SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; | ||
| + | START SLAVE; | ||
| + | </ | ||
| + | |||
| ===== Crash test ===== | ===== Crash test ===== | ||
doc/appunti/linux/sa/mysql_replica_master_master.1315479105.txt.gz · Last modified: by niccolo
