• オンラインでのデータ領域のコピーによるバックアップ時は、ソケットファイル(mysql.sock)のcpが出来ない

  • Snapshotを用いたバックアップの流れ(InnoDBのみ)
  1. Snapshotを取得
※InnoDBにはリカバリ機能があるので、MySQLエラーログにバイナリログのポジション情報が表示される為

  • Snapshotを用いたバックアップの流れ(MyISAMを含む)
  1. FLUSH TABLES WITH READ LOCK
  2. ポジション情報取得(SHOW MASTER STATUS)
  3. Snapshot取得
  4. UNLOCK TABLES

    • Snapshotを用いたバックアップのリカバリ流れ(InnoDBのみ)
  • Snapshotからデータを戻す
  • MySQL起動
# /etc/init.d/mysql start
  • バイナリログのポジション確認(MySQL起動時のエラーログにポジション情報が出力されるので、以下のコマンドで抜き出す)
# cat /var/log/mysql/mysqld.err  | grep "Last MySQL binlog file"
InnoDB: Last MySQL binlog file position 0 8346, file name /var/lib/mysql/binlog/mysql-bin.000045
  • バイナリログの適用
# mysqlbinlog --no-defaults --disable-log-bin --start-position="8346" \
/var/lib/mysql/binlog/mysql-bin.000045 /var/lib/mysql/binlog/mysql-bin.000045 > roll_forward
# mysql -uroot -p < roll_forward


    • バイナリログの適用ポジション位置(スレーブでバックアップを取得している場合)
mysql> show slave status\G
*************************** 1. row ***************************
                Slave_IO_State: Waiting for master to send event
                  Master_Host: 172.22.100.99
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
*3            Master_Log_File: mysql-bin.000001
*4        Read_Master_Log_Pos: 796577522
               Relay_Log_File: mysql-relay.000108
                Relay_Log_Pos: 30105
*1      Relay_Master_Log_File: mysql-bin.000001
             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
*2        Exec_Master_Log_Pos: 796577522
              Relay_Log_Space: 30401
              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:
1 row in set (0.00 sec)

※マスターのリカバリが必要で、かつマスターのバイナリログを使う場合は、
スレーブサーバでバックアップ取得時のSHOW SLAVE STATUSの結果で
*1      Relay_Master_Log_File: mysql-bin.000001
*2        Exec_Master_Log_Pos: 796577522 
を元にマスターのバイナリログを適用する。
*3 Master_Log_File: I/Oスレッドが現在読み込んでいるマスタバイナリログファイルの名前
*4 Read_Master_Log_Pos: I/Oスレッドが読み込んだところまでのマスタバイナリログ内での位置。
*1 Relay_Master_Log_File: SQLスレッドによって実行された一番最近のイベントを含むマスタバイナリログファイルの名前。
*2 Exec_Master_Log_Pos: SQLスレッドによって実行された最後のイベントのマスタバイナリログでの位置
※マスタバイナリログ内の(Relay_Master_Log_FileとExec_Master_Log_Pos)はリレーログ内の(Relay_Log_FileとRelay_Log_Pos)に対応している

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2010年07月29日 17:42