python–Postgresql数据库随机崩溃

python–Postgresql数据库随机崩溃,第1张

概述我真的不知道问题是什么.日志读取 FATAL: sorry, too many clients already 一遍又一遍地.起初我认为有时连接徘徊或没有正确关闭所以我通过连接到数据库并检查在任何给定时间有多少打开的连接测试,并且答案一直是1.我试图连接到使用数据库的网站,我设法瞥见2或3个打开的连接,这些连接在页面加载完成后立即关闭.我的另一个猜测是

我真的不知道问题是什么.

日志读取

FATAL: sorry,too many clIEnts already

一遍又一遍地.起初我认为有时连接徘徊或没有正确关闭所以我通过连接到数据库并检查在任何给定时间有多少打开的连接测试,并且答案一直是1.

我试图连接到使用数据库的网站,我设法瞥见2或3个打开的连接,这些连接在页面加载完成后立即关闭.

我的另一个猜测是,有时网站的并发连接会出现峰值,导致数据库停止接受新连接,并且不知何时不允许删除当前连接.

我没有写任何与数据库连接的代码,我使用的是一个非常香草的Django(1.7)后端来处理所有的连接.

在搜索谷歌时我找不到任何东西,有没有人遇到过任何问题?

编辑:

Database configuration is here(PasteBin)

重要组成部分:

@H_403_30@port = 26445                # (change requires restart)max_connections = 500           # (change requires restart)unix_socket_directory = '/home/clearintent/webapps/norr2_db/run'        # (change requires restart)shared_buffers = 32MB           # min 128kB                    # (change requires restart)log_destination = 'stderr'      # ValID values are combinations oflogging_collector = on          # Enable capturing of stderr and csvloglog_directory = 'pg_log'        # directory where log files are written,log_filename = 'postgresql-%a.log'  # log file name pattern,log_truncate_on_rotation = on       # If on,an existing log file with thelog_rotation_age = 1d           # automatic rotation of logfiles willlog_rotation_size = 0           # automatic rotation of logfiles willdatestyle = 'iso,mdy'lc_messages = 'C'           # locale for system error messagelc_monetary = 'C'           # locale for monetary formattinglc_numeric = 'C'            # locale for number formattinglc_time = 'C'               # locale for time formattingdefault_text_search_config = 'pg_catalog.english'
最佳答案听起来有些东西正在抨击你的Postgresql,但仅此错误并不会导致数据库崩溃.
它只是意味着最新的连接尝试超过了允许的与DB的并行连接数量,并且被拒绝.

但是,如果要每分钟转储连接数量,可以使用此脚本

@H_403_30@#!/bin/bashfunction spew_connections() {# Run psql on local if trust or auth is set.# Change dbadmin and dbname accordingly./usr/bin/psql -d dbname -U dbadmin -w -t -c "SELECT localtimestamp(2),count(*) FROM pg_stat_activity;"}echo -n `spew_connections` >> /tmp/connectionsecho >> /tmp/connections

然后,每分钟使用crontab执行它

@H_403_30@crontab -e*/1 * * * * /path/to/executable/script
总结

以上是内存溢出为你收集整理的python – Postgresql数据库随机崩溃全部内容,希望文章能够帮你解决python – Postgresql数据库随机崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1206457.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-04
下一篇2022-06-04

发表评论

登录后才能评论

评论列表(0条)

    保存