博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PostgreSQL连接问题(Net LO problem)
阅读量:7211 次
发布时间:2019-06-29

本文共 1638 字,大约阅读时间需要 5 分钟。

  hot3.png

中午开发人员说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回环丢失的情况。暂时还不清楚原因,有了解的麻烦留个信

转载于:https://my.oschina.net/Kenyon/blog/52750

你可能感兴趣的文章
table 中,如何使得单元格的内容不换行,单元格不被撑开
查看>>
Hibernate中session.get()和session.load()的区别
查看>>
泊松分布(Poisson distribution)的简单认识
查看>>
Android之使用传感器获取相应数据
查看>>
Jquery中html()方法 and "click"绑定后代元素
查看>>
HashMap和Hashtable的详细区别
查看>>
virutalbox虚拟机硬盘扩容
查看>>
自学计划
查看>>
dp-01背包问题 (升级)
查看>>
MySQL数据库唯一性设置(unique index)
查看>>
Windows性能计数器(命令行方式)
查看>>
Perl information,doc,module document and FAQ.
查看>>
sql 查询目标数据库中所有的表以其关键信息
查看>>
linux 下安装tomcat
查看>>
集成xadmin源码到项目的正式姿势
查看>>
自定义ViewPager,避免左右滑动时与水平滑动控件冲突
查看>>
javaScript-进阶篇(一)
查看>>
截取地址栏参数
查看>>
Redis介绍及Jedis基础操作
查看>>
20061218: 多个任务管理器
查看>>