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连接。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章