解决xtrabackup备份时出现的socket报错

今天为公司新建的uat数据库备份时,出现了报错,将解决方法整理、做一下备忘:

服务器系统:

[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参数,然后在配置文件中修改,但测试后,不一定能解决问题。

Nginx优化之php-fpm使用socket方式连接提高性能

在服务器压力不大的情况下,tcp和socket差别不大,但在压力比较满的时候,用套接字方式,效果确实比较好。

注意路径,由于每个人的环境配置不同路径也可能不同.

将TCP改成socket方式的配置方法:

第一步: 修改php-fpm.conf

;listen = 127.0.0.1:9000
listen = /dev/shm/php-cgi.sock

第二步:修改nginx配置文件server段的配置,将http的方式改为socket方式

location ~ [^/].php(/|$) {
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
}

第三步:重启php-fpm与nginx

service nginx restart
service php-fpm restart
ls -al /dev/shm

可以看到php-cgi.sock文件unix套接字类型。