postgresql远程连接中断的处理


在网络上连接远程服务器postgresql时,不活动时间稍长就会自动断开连接,不利于操作。
琢磨了一下,服务器上使用以下网络配置时,解决了这个问题。
 
#man 7 tcp
 
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl = 15
 
同时要注意postgresql.conf中以下几项设置:
#tcp_keepalives_idle = 0                # TCP_KEEPIDLE, in seconds; 0 selects the system default
#tcp_keepalives_interval = 0            # TCP_KEEPINTVL, in seconds;0 selects the system default
#tcp_keepalives_count = 0               # TCP_KEEPCNT;0 selects the system default
 
 
系统是debian7,默认的超时设置太长,而外网网络状况不佳,所以导致这种问题。
这个配置的思路是让pg更频繁地发出探测数据包来保持tcp连接。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM