単純なマスタ-スレーブ構成の場合。
マスタはreadonlyになります。
1.マスタをreadonlyにし、最新バイナリログのpositionを確認する
$ mysql -u root -p master> flush tables with read lock; master> show master logs; +------------------+-----------+ | Log_name | File_size | +------------------+-----------+ | mysql-bin.000016 | 72777285 | | mysql-bin.000017 | 220724 | | mysql-bin.000018 | 792503 | | mysql-bin.000019 | 149 | | mysql-bin.000020 | 4768160 | | mysql-bin.000021 | 106 |★ +------------------+-----------+
2.マスタからdumpし、スレーブにコピーする
$ mysqldump -uroot -pxxxxxxxxxxxx -hsssdb12 --master-data=2 --flush-logs --single-transaction --a ll-databases --default-character-set=sjis > dump-m_sssdb12_20110209.sql $ scp dump-m_sssdb12_20110209.sql sssdb13:/tmp
3.マスタをロックを解放する
master> unlock tables;
4.マスタのデータをスレーブにコピーする
5.スレーブ設定を再設定する MASTER_LOG_FILEおよびMASTER_LOG_POSは確認した最新positionを設定する$ mysql -uroot -pxxxxxxxxxxxx < dump-m_sssdb12_20110209.sql
6.スレーブのステータスを確認するslave> reset slave; slave> CHANGE MASTER TO MASTER_HOST='sssdb12', MASTER_USER='rep1user', MASTER_PASSWORD='rep1xxxxxxx', MASTER_LOG_FILE='mysql-bin.000021', MASTER_LOG_POS=106; slave> start slave;
slave> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: sssdb12 Master_User: rep1user Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000021 Read_Master_Log_Pos: 66865 Relay_Log_File: apsssdev01-relay-bin.000430 Relay_Log_Pos: 67010 Relay_Master_Log_File: mysql-bin.000021 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: 66865 Relay_Log_Space: 67170 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 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error:
0 件のコメント:
コメントを投稿