设为首页 加入收藏

TOP

MySQL数据库监控软件lepus使用问题以及解决办法(一)
2018-10-23 00:06:05 】 浏览:1053
Tags:MySQL 数据库 监控 软件 lepus 使用 问题 以及 解决 办法

在使用lepus3.7监控MySQL数据库的时候,碰到了以下几个问题,本博客给出了这些问题产生的原因,以及相应的解决办法。


1. 问题1:php页面无法连接数据库


直接使用php程序执行php文件,可以连接mysql,但是在httpd中同样的php页面无法连接mysql。


lepus的web程序(PHP代码)无法连接数据库时,web界面上什么操作也无法继续。


为此编写了最简单的PDO连接测试代码:


php代码如下:


[linuxidc@linuxidc lepus]$ cat mysql.php


<?php


  try{


 #$dsn="mysql:host=127.0.0.1;dbname=lepus;";


 $dsn="mysql:host=11.1.1.11;dbname=lepus;";


 $user="coe2coe";


 $pwd="XXXXXXXXXX";


 $sql="select now() as a";


 $dbh=new PDO($dsn,$user,$pwd);


 $stmt=$dbh->prepare($sql);


 $stmt->execute();


 $row=$stmt->fetch(PDO::FETCH_ASSOC);


 echo "result:".$row['a'];


  }


  catch(PDOException $e) {


  echo  "FAILED:".$e->getMessage();


  }


?>



php程序直接执行php文件:


[linuxidc@linuxidc lepus]$ php mysql.php


result:2018-09-27 00:03:44



通过浏览器访问这个页面:


FAILED:SQLSTATE[HY000] [2003] Can't connect to MySQL server on '11.1.1.11' (13)



lepus的web程序给出的错误提示信息更加模糊。



原因:


通过一番baidu之后,终于看到了一个比较靠谱的分析。



[linuxidc@linuxidc lepus]$ sudo getsebool -a |grep httpd


httpd_anon_write --> off


httpd_builtin_scripting --> on


httpd_can_check_spam --> off


httpd_can_connect_ftp --> off


httpd_can_connect_ldap --> off


httpd_can_connect_mythtv --> off


httpd_can_connect_zabbix --> off


httpd_can_network_connect --> off


httpd_can_network_connect_cobbler --> off


httpd_can_network_connect_db --> off


httpd_can_network_memcache --> off


httpd_can_network_relay --> off


httpd_can_sendmail --> off


httpd_dbus_avahi --> off


httpd_dbus_sssd --> off


httpd_dontaudit_search_dirs --> off


httpd_enable_cgi --> on


httpd_enable_ftp_server --> off


httpd_enable_homedirs --> off


httpd_execmem --> off


httpd_graceful_shutdown --> on


httpd_manage_ipa --> off


httpd_mod_auth_ntlm_winbind --> off


httpd_mod_auth_pam --> off


httpd_read_user_content --> off


httpd_run_ipa --> off


httpd_run_preupgrade --> off


httpd_run_stickshift --> off


httpd_serve_cobbler_files --> off


httpd_setrlimit --> off


httpd_ssi_exec --> off


httpd_sys_script_anon_write --> off


httpd_tmp_exec --> off


httpd_tty_comm --> off


httpd_unified --> off


httpd_use_cifs --> off


httpd_use_fusefs --> off


httpd_use_gpg --> off


httpd_use_nfs --> off


httpd_use_openstack --> off


httpd_use_sasl --> off


httpd_verify_dns --> off



解决办法:


临时办法:临时禁用SELINUX。


[linuxidc@linuxidc lepus]$ sudo setenforce 0



永久办法:修改selinux配置文件,禁用SELINUX。


[linuxidc@linuxidc lepus]$ cat /etc/selinux/config



# This file controls the state of SELinux on the system.


# SELINUX= can take one of these three values:


#    enforcing - SELinux security policy is enforced.


#    permissive - SELinux prints warnings instead of enforcing.


#    disabled - No SELinux policy is loaded.


#SELINUX=enforcing


SELINUX=disabled


# SELINUXTYPE= can take one of three two values:


#    targeted - Targeted processes are protected,


#    minimum - Modification of targeted policy. Only selected processes are protected.


#    mls - Multi Level Security protection.


SELINUXTYPE=targeted


 


验证:


再次在浏览器中访问这个php页面:


result:2018-09-27 00:09:26



2. 问题2:lepus日志中出现group by警告。


2018-09-27 01:12:41 [WARNIN

首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇MySQL递归查询_函数语法检查_GROU.. 下一篇Oracle带输入输出参数存储过程(包..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目