Mysql

XtraBackup 因 my.cnf Percona 配置而失敗

  • February 17, 2022

使用 percona 優化的 .cnf 文件後,備份失敗

安裝 my.cnf

# service mysql stop
(Installed my.cnf)
# rm ib_logfile0
# rm ib_logfile1
# service mysql start

Mysql creates new log files on startup

我的.cnf

# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208

[client]

# CLIENT #
port = 3306
socket = /var/run/mysqld/mysqld.sock

[mysqld]

# GENERAL #
user = mysql
default_storage_engine = InnoDB
pid_file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
basedir = /usr/local/mysql
tmpdir = /tmp

# MyISAM #
key_buffer_size = 32M
myisam_recover = FORCE,BACKUP

# SAFETY #
max_allowed_packet = 16M
max_connect_errors = 1000000
skip_name_resolve
sql_mode = STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_ SUBSTITUTION
sysdate_is_now = 1
innodb = FORCE
innodb_strict_mode = 1
bind_address = 127.0.0.1

# DATA STORAGE #
datadir = /var/lib/mysql

# BINARY LOGGING #
log_bin = /var/lib/mysql/mysql-bin
expire_logs_days = 14
max_binlog_size = 100M
sync_binlog = 1

# CACHES AND LIMITS #
tmp_table_size = 32M
max_heap_table_size = 32M
query_cache_type = 0
query_cache_size = 0
max_connections = 500
thread_cache_size = 50
open_files_limit = 65535
table_definition_cache = 1024
table_open_cache = 2048

# INNODB #
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 2
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table = 1
innodb_buffer_pool_size = 6G

# LOGGING #
log_error = /var/lib/mysql/mysql-error.log
log_queries_not_using_indexes = 1
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/mysql-slow.log

錯誤日誌

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.

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

131210 11:53:50 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup' as 'root' (using password: YES).
131210 11:53:50 innobackupex: Connected to MySQL server
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".

innobackupex: Using mysql server version 5.6.14-log

innobackupex: Created backup directory /var/www/dyntest.dk

131210 11:53:50 innobackupex: Starting ibbackup with command: xtrabackup_56 --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/tmp --tmpdir=/tmp --stream=tar
innobackupex: Waiting for ibbackup (pid=6728) to suspend
innobackupex: Suspend file '/tmp/xtrabackup_suspended_2'

xtrabackup_56 version 2.1.5 for MySQL server 5.6.11 Linux (x86_64) (revision id: undefined)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:10M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 50331648
InnoDB: Error: log file ./ib_logfile0 is of different size 268435456 bytes
InnoDB: than specified in the .cnf file 50331648 bytes!
innobackupex: Error: The xtrabackup child process has died at /usr/bin/innobackupex line 2579. 

提示在最後的錯誤消息中,如下所示

xtrabackup: innodb_log_file_size = 50331648
InnoDB: Error: log file ./ib_logfile0 is of different size 268435456 bytes

xtrabackup 隱式引用的 my.cnf 具有 innodb_log_file_size = 48M(50331648 字節),但實際日誌文件大小為 256MB(如您的 my.cnf 所示)

我認為您應該像這樣明確指定 my.cnf

xtrabackup --defaults-file=/path/to/my.cnf

我遇到過同樣的問題。修復很簡單,只需將以下內容添加到 my.cnf 中

$$ mysqld $$節 innodb_log_file_size=48M (使用您需要的任何大小的日誌文件,對於小型 Db 來說 48M 就可以了)

然後按照說明使用新的日誌文件大小重新啟動 mysql。基礎是(但請閱讀手冊!) stop mysql remove the ib_logfile* files from /var/lib/mysql restart mysql

確保不要使用 innodb 快速關閉(閱讀手冊!)

引用自:https://dba.stackexchange.com/questions/55100