use innobackupex for backup faild, code /usr/bin/innobackupex line 3003,1539,2987

Hi Masters

I’m a new guy just begin to study mysql, but recently i met a issue but do know how to fix it, appreciated if somebody could
help me about it, maybe a stupid mistake, but i can’t find out, pls see below

[root@nemrry ~]# innobackupex --user=root --password=mysql /root/backup/

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.

Get the latest version of Percona XtraBackup, documentation, and help resources:
[URL]Percona XtraBackup - MySQL Database Backup Software

150405 19:55:23 innobackupex: Connecting to MySQL server with DSN ‘dbi:mysql:;mysql_read_default_group=xtrabackup’ as ‘root’ (using password: YES).
innobackupex: got a fatal error with the following stacktrace: at /usr/bin/innobackupex line 3003.
main::mysql_connect(‘abort_on_error’, 1) called at /usr/bin/innobackupex line 1539
innobackupex: Error: Failed to connect to MySQL server: DBI connect(‘;mysql_read_default_group=xtrabackup’,‘ro ot’,…) failed: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2) at /usr/bin/innobackupex line 2987.
[root@nemrry ~]# rpm -qa |grep xtrabackup
percona-xtrabackup-2.2.10-1.el7.x86_64
percona-xtrabackup-debuginfo-2.2.10-1.el7.x86_64
[root@nemrry ~]# cat /etc/centos-release
CentOS Linux release 7.0.1406 (Core)

i have already install perl-DBD-MySQL-4.023-5.el7.x86_64, i have searched around, but still not find the solution,
pls help to give some advices

Thanks & best regards

newbie nemrry

may i think it’s version not compatible?

Try to use the --socket option with innobackupex or check your my.cnf file and add a socket=/path/to/mysql.sock under [client] or [mysql] option group.

Hi Jrivera

thanks for your advice, but i have tried before, it’s not work, pls ref the below
[root@nemrry ~]# cd /var/lib/mysql/
[root@nemrry mysql]# ll
total 0
lrwxrwxrwx 1 mysql mysql 15 Apr 5 21:42 mysql.sock → /tmp/mysql.sock
[root@nemrry mysql]# cd
[root@nemrry ~]# cat /etc/my.cnf

For advice on how to change settings please see

http://dev.mysql.com/doc/refman/5.6/…-defaults.html

*** DO NOT EDIT THIS FILE. It’s a template which will be copied to the

*** default location during install, and will be replaced if you

*** upgrade to a newer version of MySQL.

[mysqld]

Remove leading # and set to the amount of RAM for the most important data

cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

innodb_buffer_pool_size = 128M

Remove leading # to turn on a very important data integrity option: logging

changes to the binary log between backups.

log_bin=/usr/local/mysql/mysql_bin_log/mysqlbin.log
log_bin_index=/usr/local/mysql/mysql_bin_log/mysqlbin.index

These are commonly set, remove the # and set as required.

basedir = …

datadir = /data/mydata

port = …

server_id = …

socket =/tmp/mysql.sock

Remove leading # to set options mainly useful for reporting servers.

The server defaults are faster for transactions and fast SELECTs.

Adjust sizes as needed, experiment to find the optimal values.

join_buffer_size = 128M

sort_buffer_size = 2M

read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLE S

[root@nemrry ~]# innobackupex --user=root --password=mysql --socket=/tmp/mysql.sock /root/backup/

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.

Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p

150406 14:25:26 innobackupex: Connecting to MySQL server with DSN ‘dbi:mysql:;mysql_read_default_group=xtrabackup;my sql_socket=/tmp/mysql.sock’ as ‘root’ (using password: YES).
innobackupex: got a fatal error with the following stacktrace: at /usr/bin/innobackupex line 3003.
main::mysql_connect(‘abort_on_error’, 1) called at /usr/bin/innobackupex line 1539
innobackupex: Error: Failed to connect to MySQL server: DBI connect(‘;mysql_read_default_group=xtrabackup;mysq l_socket=/tmp/mysql.sock’,‘root’,…) failed: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) at /usr/bin/innobackupex line 2987.

[root@nemrry ~]# service mysqld status
SUCCESS! MySQL running (2822)
[root@nemrry ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.22-log Source distribution

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show variables like ‘socket’;
±--------------±----------------+
| Variable_name | Value |
±--------------±----------------+
| socket | /tmp/mysql.sock |
±--------------±----------------+
1 row in set (0.01 sec)

mysql>

this issue still exist, i don’t know why for innobackupex can’t connect to the MySQL server, but MySQL server is running normally,appreciated you could help me to find out the root cause, thanks!

Can some one help me to find out what’s wrong here? thanks!

Can you please add [client] section in my.cnf as below.
[client]
socket =/tmp/mysql.sock

If it still doesn’t work please provide @datadir output.
mysql> SHOW GLOBAL VARIABLES LIKE ‘%datadir%’;

Hi [CENTER],

Hope the issue got resolved for you.can you please provide the solution for this? [/CENTER]

we are facing the same error. this error?

So here is the issue…
You need to look for the files:
/usr/lib64/libmysqlclient_r.so.16.0.0
/usr/lib64/libmysqlclient.so.16.0.0

You also need to be sure that there are soft links there…
root@hostname# ls -al /usr/lib64/libmysqlclient16
lrwxrwxrwx. 1 root root 26 Feb 12 16:44 /usr/lib64/libmysqlclient_r.so.16 → libmysqlclient_r.so.16.0.0
-rwxr-xr-x. 1 root root 1509288 Jul 28 2014 /usr/lib64/libmysqlclient_r.so.16.0.0
lrwxrwxrwx. 1 root root 24 Feb 12 16:44 /usr/lib64/libmysqlclient.so.16 → libmysqlclient.so.16.0.0
-rwxr-xr-x. 1 root root 1499400 Jul 28 2014 /usr/lib64/libmysqlclient.so.16.0.0

Once you have these in place you run the following test:
–Show correct versions of dbd is installed for mysql to work
root@hostname# perl -MDBD::mysql -e ‘print $DBD::mysql::VERSION’
OUTPUT:
4.013

Now you should be able to make innobackupex script work as designed.

Here are my current percona RPMs and DBD rpms
root@hostname# rpm -qa | grep -i percona
Percona-Server-shared-compat-51-5.1.73-rel14.12.624.rhel6.x86_64
percona-xtrabackup-2.2.11-1.el6.x86_64
Percona-Server-shared-55-5.5.44-rel37.3.el6.x86_64
Percona-Server-server-55-5.5.44-rel37.3.el6.x86_64
percona-toolkit-2.2.14-1.noarch
Percona-Server-client-55-5.5.44-rel37.3.el6.x86_64
root@hostname# rpm -qa | grep -i dbd
perl-DBD-MySQL-4.013-3.el6.x86_64
perl-DBD-SQLite-1.27-3.el6.x86_64

This worked for me - good luck!