Nagios监控mysql从库报错: libmysqlclient.so.18: cannot open shared object file: No such

做mysql的slave监控的时候,需要check_mysql脚本,check的时候报错:
 error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

1,错误信息如下:
[root@slave ~]# /usr/local/nagios/libexec/check_mysql -uadmin -P3306 -S /data/mbdata/open/mysql.sock -H127.0.0.1 -pxxxxx -d openshop -w 300 -c 360
/usr/local/nagios/libexec/check_mysql: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[root@slave ~]#

2,执行check_mysql --help看下命令,发现也不行。
  1. [root@slave ~]# /usr/local/nagios/libexec/check_mysql --help  
  2. /usr/local/nagios/libexec/check_mysql: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory  
  3. [root@slave ~]#   

3,查看一下报错的libmysqlclient.so.18文件是否存在:
[root@db-m1-slave-1 ~]# find / -name libmysqlclient.so.18
/mysql-5.6.12/libmysql/libmysqlclient.so.18
/usr/local/mysql/lib/libmysqlclient.so.18
文件存在,但是无法识别。


4,可能是libmysqlclient的问题
搜索mysqlclient library linkage problem。
找到文章地址:http://stackoverflow.com/questions/2080679/mysqlclient-library-linkage-problem
发现有/etc/ld.so.conf.d/mysql-x86_64.conf这样一个配置文件,打开看看
cat /etc/ld.so.conf.d/mysql-x86_64.conf

[root@slave ~]# cat /etc/ld.so.conf.d/mysql-x86_64.conf
/usr/lib64/mysql

进入目录/usr/lib64/mysql查看下有什么文件:
[root@slave ~]# ll /usr/lib64/mysql
总用量 3108
lrwxrwxrwx. 1 root root      26 9月  29 2013 libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0
-rwxr-xr-x. 1 root root 1595176 12月  8 2012 libmysqlclient_r.so.16.0.0
lrwxrwxrwx. 1 root root      24 9月  29 2013 libmysqlclient.so.16 -> libmysqlclient.so.16.0.0
-rwxr-xr-x. 1 root root 1582952 12月  8 2012 libmysqlclient.so.16.0.0
有一些软连接,而且带了后缀表示so.16之类的,但是没有so.18之类,看来是没有连接到这里,
可能是需要做一个软连接把/usr/local/mysql/lib/libmysqlclient.so.18变成/usr/lib64/libmysqlclient.so.18,
马上去做软连接:ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18,然后再check下,check成功如下所示:


  1. [root@slave ~]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18  
  2. [root@slave ~]  
  3. [root@slave ~]  
  4. [root@slave ~]# /usr/local/nagios/libexec/check_mysql --help  
  5. check_mysql v2.0 (nagios-plugins 2.0)  
  6. Copyright (c) 1999-2014 Nagios Plugin Development Team  
  7.     <devel@nagios-plugins.org>  
  8. This program tests connections to a MySQL server  
  9. Usage:  
  10.  check_mysql [-d database] [-H host] [-P port] [-s socket]  
  11.        [-u user] [-p password] [-S] [-l] [-a cert] [-k key]  
  12.        [-C ca-cert] [-D ca-dir] [-L ciphers] [-f optfile] [-g group]  
  13.   
  14.   
  15. Options:  
  16.  -h, --help  
  17.     Print detailed help screen  
  18.  -V, --version  
  19.     Print version information  
  20.  --extra-opts=[section][@file]  
  21.     Read options from an ini file. See  
  22.     https://www.nagios-plugins.org/doc/extra-opts.html  
  23.     for usage and examples.  
  24. ..................................  
  25. -l, --ssl  
  26.     Use ssl encryptation  
  27.  -C, --ca-cert=STRING  
  28.     Path to CA signing the cert  
  29.  -a, --cert=STRING  
  30.     Path to SSL certificate  
  31.  -k, --key=STRING  
  32.     Path to private SSL key  
  33.  -D, --ca-dir=STRING  
  34.     Path to CA directory  
  35.  -L, --ciphers=STRING  
  36.     List of valid SSL ciphers  
  37. .................................................  
  38. Send email to help@nagios-plugins.org if you have questions regarding use  
  39. of this software. To submit patches or suggest improvements, send email to  
  40. devel@nagios-plugins.org  
  41.   
  42.   
  43. [root@slave ~]  

5,继续执行check_mysql来check一下
[root@slave ~]# /usr/local/nagios/libexec/check_mysql -unagios -P3306 -S -H127.0.0.1 --password='xxx@0512' /usr/local/mysql/mysql.sock -d test -w 60 -c 100
slave query error: Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation
[root@slave ~]# 
报账号错误,
check
slave query error: Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation
账号错误,进入mysql界面赋予nagios账号权限
mysql> GRANT PROCESS, SUPER, REPLICATION CLIENT ON *.* TO nagios@'%' identified by 'xxx@0512';

6,再check
[root@slave ~]# /usr/local/nagios/libexec/check_mysql -unagios -P3306 -S -Hlocalhost --password='xxx@0512' -s /usr/local/mysql/mysql.sock -d test -w 60 -c 100
Slave IO: Yes Slave SQL: No Seconds Behind Master: (null)

mysql slave 检测失败,有错误信息: Slave IO: Yes Slave SQL: No Seconds Behind Master: (null)

进mysql窗口去看详细信息

  1. [root@slave ~]# mysql  
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  3. Your MySQL connection id is 23  
  4. Server version: 5.6.12-log Source distribution  
  5.   
  6. Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.  
  7.   
  8. Oracle is a registered trademark of Oracle Corporation and/or its  
  9. affiliates. Other names may be trademarks of their respective  
  10. owners.  
  11.   
  12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  13.   
  14. mysql> show slave status\G  
  15. *************************** 1. row ***************************  
  16.                Slave_IO_State: Waiting for master to send event  
  17.                   Master_Host: 10.xx.3.xx  
  18.                   Master_User: repl  
  19.                   Master_Port: 3306  
  20.                 Connect_Retry: 60  
  21.               Master_Log_File: mysql-bin.010294  
  22.           Read_Master_Log_Pos: 21764  
  23.                Relay_Log_File: mysql-relay-bin.003125  
  24.                 Relay_Log_Pos: 91805  
  25.         Relay_Master_Log_File: mysql-bin.010275  
  26.              Slave_IO_Running: Yes  
  27.             Slave_SQL_Running: No  
  28.               Replicate_Do_DB: xx,xx_db,xxsystem  
  29.           Replicate_Ignore_DB:   
  30.            Replicate_Do_Table:   
  31.        Replicate_Ignore_Table:   
  32.       Replicate_Wild_Do_Table:   
  33.   Replicate_Wild_Ignore_Table:   
  34.                    Last_Errno: 1590  
  35.                    Last_Error: The incident LOST_EVENTS occured on the master. Message: error writing to the binary log  
  36.                  Skip_Counter: 0  
  37.           Exec_Master_Log_Pos: 91642  
  38.               Relay_Log_Space: 1780004  
  39.               Until_Condition: None  
  40.                Until_Log_File:   
  41.                 Until_Log_Pos: 0  
  42.            Master_SSL_Allowed: No  
  43.            Master_SSL_CA_File:   
  44.            Master_SSL_CA_Path:   
  45.               Master_SSL_Cert:   
  46.             Master_SSL_Cipher:   
  47.                Master_SSL_Key:   
  48.         Seconds_Behind_Master: NULL  
  49. Master_SSL_Verify_Server_Cert: No  
  50.                 Last_IO_Errno: 0  
  51.                 Last_IO_Error:   
  52.                Last_SQL_Errno: 1590  
  53.                Last_SQL_Error: The incident LOST_EVENTS occured on the master. Message: error writing to the binary log  
  54.   Replicate_Ignore_Server_Ids:   
  55.              Master_Server_Id: 71  
  56.                   Master_UUID: 9b0dcf62-29f4-11e3-9471-677b33903869  
  57.              Master_Info_File: mysql.slave_master_info  
  58.                     SQL_Delay: 0  
  59.           SQL_Remaining_Delay: NULL  
  60.       Slave_SQL_Running_State:   
  61.            Master_Retry_Count: 86400  
  62.                   Master_Bind:   
  63.       Last_IO_Error_Timestamp:   
  64.      Last_SQL_Error_Timestamp: 140512 11:29:54  
  65.                Master_SSL_Crl:   
  66.            Master_SSL_Crlpath:   
  67.            Retrieved_Gtid_Set:   
  68.             Executed_Gtid_Set:   
  69.                 Auto_Position: 0  
  70. 1 row in set (0.00 sec)  
  71. mysql>   

关于 Slave IO: Yes Slave SQL: No Seconds Behind Master: (null),参考blog:   http://blog.csdn.net/mchdba/article/details/25738991


7,slave重做之后,再check,slave状态是正常的。

# /usr/local/nagios/libexec/check_mysql -unagios -P3306 -S -s /usr/local/mysql/mysql.sock -Hlocalhost --password='xxx@0512' -d test -w 60 -c 100 

  1. [root@slave ~]# /usr/local/nagios/libexec/check_mysql -unagios -P3306 -S -s /usr/local/mysql/mysql.sock -Hlocalhost --password='xxx@0512' -d test -w 60 -c 100   
  2. Uptime: 18431321  Threads: 3  Questions: 1447646  Slow queries: 735  Opens: 18605  Flush tables: 1  Open tables: 214  Queries per second avg: 0.078 Slave IO: Yes Slave SQL: Yes Seconds Behind Master: 0|Connections=1380c;;; Open_files=32;;; Open_tables=214;;; Qcache_free_memory=66980240;;; Qcache_hits=778c;;; Qcache_inserts=5338c;;; Qcache_lowmem_prunes=0c;;; Qcache_not_cached=12516c;;; Qcache_queries_in_cache=34;;; Queries=1447647c;;; Questions=99727c;;; Table_locks_waited=0c;;; Threads_connected=1;;; Threads_running=1;;; Uptime=18431321c;;; 'seconds behind master'=0.000000s;60.000000;100.000000;  
  3. [root@db-m1-slave-1 ~]#   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值