posts - 88, comments - 3, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          日歷

          <2012年4月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          搜索

          •  

          innobackupex & FLUSH TABLES WITH READ LOCK

          Posted on 2012-04-10 17:19 Milo的海域 閱讀(677) 評論(0)  編輯  收藏 所屬分類: MySQL
          當innobackupex 做全備的時候(my version 1.6.5), 當備份到MyISAM數據時, innobackupex 會flush tables with read lock, 來禁止MyISAM的寫操作. (假設沒有--no-lock選項)

          sub backup {

              
          if (!$option_incremental && !$option_no_lock) {
                  
          # make a prep copy before locking tables, if using rsync
                  backup_files(1);

                  
          # flush tables with read lock
                  mysql_lockall();
              }

              
          if ($option_slave_info) {
                  write_slave_info();
              }

          }

          sub mysql_lockall {

              
          if (compare_versions($mysql_server_version, '4.0.22'== 0
                  
          || compare_versions($mysql_server_version, '4.1.7'== 0) {
                  
          # MySQL server version is 4.0.22 or 4.1.7
                  mysql_send "COMMIT;";
                  mysql_send 
          "FLUSH TABLES WITH READ LOCK;";
              } 
          else {
                  
          # MySQL server version is other than 4.0.22 or 4.1.7
                  mysql_send "FLUSH TABLES WITH READ LOCK;";
                  mysql_send 
          "COMMIT;";
              }
              write_binlog_info;


          }

          但是如果備份的時候還有很重的workload, "flush tables with read lock" 可能會比較耗時. 這里參考了:

          http://www.mysqlperformanceblog.com/2010/04/24/how-fast-is-flush-tables-with-read-lock/

          看了下--no-lock的選項說明:

              --no-lock
                  Use this option to disable table lock with 
          "FLUSH TABLES WITH READ
                  LOCK
          ". Use it only if ALL your tables are InnoDB and you DO NOT CARE
                  about the binary log position of the backup.

          如果我們能保證workload僅僅是innodb相關的,我們可以使用這個選項。

          記得在1.5版本的時候,使用--no-lock選項會導致xtrabackup_slave_info沒有保存備份時的logfile & pos. 這個問題在1.6.5被解決了

              if ($option_slave_info) {
                  write_slave_info();
              }

          xtrabackup_slave_info & xtrabackup_binlog_info文件在1.5版本是在mysql_lockall函數里更新的。但是新版本已經把write_slave_info提到mysql_lockall外面了。
          主站蜘蛛池模板: 拜泉县| 宜良县| 永安市| 延庆县| 习水县| 和顺县| 临高县| 丹东市| 东莞市| 化隆| 蒙城县| 商水县| 陇川县| 洛南县| 元阳县| 峨山| 贵阳市| 普宁市| 城口县| 罗山县| 缙云县| 建德市| 枣强县| 康马县| 栾城县| 商南县| 封开县| 潜山县| 花莲市| 仪陇县| 锡林郭勒盟| 舒城县| 乃东县| 沈阳市| 恩施市| 乌什县| 开鲁县| 安溪县| 永兴县| 凤山县| 台中市|