'develop','password' => 'develop' 捕捉到的" /> 'develop','password' => 'develop' 捕捉到的" />

PostgreSQL连接问题 | Net LO problem

PostgreSQL连接问题 | Net LO problem

中午开发人员说PHP连接不上了,他的连接方式:

'connectionString' =>"pgsql:host=172.25.*.*;port=5432;dbname=test",'username' => 'develop','password' => 'develop'

捕捉到的报错信息:

PDOException Object ( [message:protected] => SQLSTATE[08006] [7] timeout expired[string:private] => [code:protected] => 7 [file:protected] => /home/shnx/bid.test.com/index.php [line:protected] => 3 [trace:private] => Array ( [0] => Array ( [file] => /home/shnx/bid.test.com/index.php [line] => 3 [function] => __construct [class] => PDO [type] => -> [args] => Array ( [0] => pgsql:host=localhost;port=5432;dbname=test [1] => develop [2] => develop ) ) ) [errorInfo] => )

查看数据库日志信息,里面尽是些相同的错误信息:

LOG: could not receive data from client: Connection reset by peer
LOG: unexpected EOF on client connection
LOG: could not receive data from client: Connection reset by peer
LOG: unexpected EOF on client connection

先ping下服务器,是通的,再检查数据库是否有问题,使用psql本地登录

[postgres@greentea]$ psql -U develop -d testpsql (9.1.2)Type "help" for help.test=> 

数据库是可以连接的。看到他的连接信息多了一项host连接,遂也加了测试,发现问题来了,一直卡在这里,也很难掐掉,最终会报错:

[postgres@greentea ~]$ psql -h localhost -U develop -d testpsql: could not connect to server: 连接超时 Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

把localhost换成本地IP或者127.0.0.1结果都一样,hang在那里不动了。

此时测试了一下别的主机ping它,以及它ping别的主机都是正常的。但是 ping 127.0.0.1 或者 ping localhost 或者ping 自己的IP 却都是不通的,很奇怪。再检查一下主机名的设置,pg_hba和postgres.conf配置,都没问题。再检查一下IP设置,此时惊奇发现IP的回环LO没了。只有eth0和eth1的信息。难怪。

增加回环:

ifconfig lo 127.0.0.1

再测试,正常了。想起之前服务器有重启,但是网卡没起来,当时重启了下网卡(ifdown eth0 和ifup eth0),但是倒是第一次遇到ip回环丢失的情况。暂时还不清楚原因,有了解的麻烦留个信

免责声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕。
相关文章
返回顶部