1. 程式人生 > >使用xtrabackup還原Failed to connect to MySQL server to detect version

使用xtrabackup還原Failed to connect to MySQL server to detect version

兩臺伺服器10.11和10.40
今天使用xtrabackup備份還原的時候遇到問題,在10.11備份,10.40還原報錯如下:
# innobackupex --apply-log --redo-only --user=backupuser --password='123456'--defaults-file=/etc/my_ttnet.cnf /root/bh/backup/full/

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Ireland Ltd 2009-2012.  All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

141125 09:43:44  innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'backupuser'  (using password: YES).
Failed to connect to MySQL server to detect version.
You must set xtrabackup version to use with --ibbackup option.
Possible values are xtrabackup_55 (for MySQL 5.5), xtrabackup_56 (for MySQL or Percona Server 5.6, or xtrabackup (for MySQL 5.1 with InnoDB plugin or Percona Server)
根據報錯提示,失敗查明mysql的版本,需要指明--ibbackup選項,因為我的mysql是5.5版本的,所以我使用--ibbackup xtrabackup_55,
之前的備份還原是不需要新增該引數的,很奇怪,檢查發現是備份的xtrbackup不是我經常使用的2.1.4,而是2.1.2,所以還原上面有些出入

解決:
# innobackupex --apply-log --redo-only --user=backupuser --password='123456'--defaults-file=/etc/my_ttnet.cnf /root/bh/backup/full --ibbackup xtrabackup_55
..........
xtrabackup: Error: cannot open ./xtrabackup_checkpoints
xtrabackup: error: xtrabackup_read_metadata()
...............
141125  9:59:20  InnoDB: Starting shutdown...
141125  9:59:21  InnoDB: Shutdown completed; log sequence number 2820572327720
141125 09:59:21  innobackupex: completed OK!
這裡有個ERROR,檢查發現在備份的時候就沒有生成保有binlog_pos和file資訊的檔案,我暈啊,於是改用2.1.4版本的xtrabackup重新進行備份。

在備份指令碼執行後,我們可以通過檢視該日誌判斷當前使用的xtrabackup版本

確定版本 
 # more xtrabackup_log_2014-11-25_10\:20\:23   //這是我們要使用的版本2.1.4-->percona-xtrabackup-2.1.4-656.rhel5.x86_64.rpm
xtrabackup_55 version 2.1.4 for Percona Server 5.5.31 Linux (x86_64) (revision id: 656)

# more xtrabackup_log_2014-11-24_16\:06\:55  、//摒棄該版本2.1.2
xtrabackup_55 version 2.1.2 for Percona Server 5.5.16 Linux (x86_64) (revision id: 611)