Xtrbackup 備份過程報錯 Error: option 'datadir' has different values:

mhabbyo發表於2016-06-24
在給一個新庫做備份的時候,遇到了問題,具體報錯如下:

160624 10:57:06 Connecting to MySQL server host: localhost, user: root, password: set, port: 0, socket: /var/lib/mysql/mysql.sock
Using server version 10.1.14-MariaDB
Error: option 'datadir' has different values:
  '.' in defaults file
  '/var/lib/mysql/' in SHOW VARIABLES



備份指令碼執行過程如下:

[root@o-db scripts]# sh -x  bak.sh
++ which innobackupex
+ innobackupex=/usr/bin/innobackupex
++ which xtrabackup
+ xtrabackup=/usr/bin/xtrabackup
+ cnf=/etc/my.cnf
+ user=root
+ password=admin
+ backdir=/u01/backup
++ date +%F
+ /usr/bin/innobackupex --defaults-file=/etc/my.cnf --socket=/var/lib/mysql/mysql.sock --ibbackup=/usr/bin/xtrabackup --user=root --password=admin --no-timestamp /u01/backup/all_2016-06-23
160624 10:57:06 innobackupex: Starting the backup operation

IMPORTANT: Please check that the backup run completes successfully.
           At the end of a successful backup run innobackupex
           prints "completed OK!".

160624 10:57:06  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/var/lib/mysql/mysql.sock' as 'root'  (using password: YES).
160624 10:57:06  version_check Connected to MySQL server
160624 10:57:06  version_check Executing a version check against the server...
160624 10:57:06  version_check Done.
160624 10:57:06 Connecting to MySQL server host: localhost, user: root, password: set, port: 0, socket: /var/lib/mysql/mysql.sock
Using server version 10.1.14-MariaDB
Error: option 'datadir' has different values:
  '.' in defaults file
  '/var/lib/mysql/' in SHOW VARIABLES
++ date --date '1 days ago ' +%Y-%m-%d
+ rm -rf /u01/backup/all_2016-06-23




分析師配置檔案中有錯誤,新增了datadir 選項,仍然會報錯,仔細檢查後發現是沒有新增【mysqld】標籤

[root@o-db all_2016-06-24]# cat  /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]


#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysqld]     ----------->  這裡是發生報錯的原因  沒有新增這個標籤 所以會爆出來有不同的值
datadir=/var/lib/mysql/


新增完成後,備份指令碼正常執行

xtrabackup: Stopping log copying thread.
.160624 11:09:00 >> log scanned up to (33566075)

160624 11:09:00 Executing UNLOCK TABLES
160624 11:09:00 All tables unlocked
160624 11:09:00 Backup created in directory '/u01/backup/all_2016-06-24'
160624 11:09:00 [00] Writing backup-my.cnf
160624 11:09:00 [00]        ...done
160624 11:09:00 [00] Writing xtrabackup_info
160624 11:09:00 [00]        ...done
xtrabackup: Transaction log of lsn (33566075) to (33566075) was copied.
160624 11:09:00 completed OK!
++ date --date '1 days ago ' +%Y-%m-%d
+ rm -rf /u01/backup/all_2016-06-23


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29291882/viewspace-2120930/,如需轉載,請註明出處,否則將追究法律責任。

相關文章