XtraBackup備份時出現的socket報錯解決
今天為公司建立的uat資料庫使用XtraBackup備份時,出現了報錯,將解決方案整理、做一下備忘:
伺服器系統:
[root@uat-mysql-master tmp]# cat /etc/RedHat-release
CentOS Linux release 7.3.1611 (Core)
mysql版本號碼:
mysql>
select
version();
+
----------------+
| version() |
+
----------------+
| 5.5.47-cll-lve |
+
----------------+
1 row
in
set
(0.00 sec)
報錯如下:
[root@uat-mysql-master tmp]# innobackupex
--defaults-file=/etc/my.cnf --user=backup --password=****** --stream=tar /home/backup/ | gzip >/home/backup/`date +%F_%H-%M-%S`.tar.gz
171120 17:10:42 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!"
.
171120 17:10:42 version_check Connecting
to
MySQL server
with
DSN
'dbi:mysql:;mysql_read_default_group=xtrabackup'
as
'backup'
(using
password
: YES).
Failed
to
connect
to
MySQL server: DBI
connect
(
';mysql_read_default_group=xtrabackup'
,
'backup'
,...) failed: Can
't connect to local MySQL server through socket '
/var/lib/mysql/mysql.sock
' (2) at - line 1314.
171120 17:10:42 Connecting to MySQL server host: localhost, user: backup, password: set, port: not set, socket: not set
Failed to connect to MySQL server: Can'
t
connect
to
local
MySQL server through socket
'/var/lib/mysql/mysql.sock'
(2).
解決辦法:
在命令列中添加
--host=127.0.0.1
參數;
備忘:網上有的說,通過
# find / -name "mysql.sock"
查到socket參數,然後在設定檔中修改,但測試後,不一定能解決問題。
更多XtraBackup相關教程見以下內容:
使用Xtrabackup進行MySQL備份
Percona Xtrabackup 安裝
Percona XtraBackup 安裝介紹篇
使用XtraBackup 備份MySQL資料庫
使用Xtrabackup進行MySQL資料庫全備和全備還原
XtraBackup備份原理和實戰詳解
Percona XtraBackup 實現全備&增量備份與恢複
XtraBackup備份原理和實戰詳解