我在我的Django网络应用程序中使用pgbouncer
。应用程序服务器和数据库服务器是两个独立的VM。 pgbouncer
安装在应用程序服务器上。在pgbouncer.ini
相关的设置是:解释django项目中的pgbouncer日志条目
[databases]
dbname = host=80.211.128.113 port=5432 dbname=dbname
pool_mode = transaction
max_client_conn = 250
default_pool_size = 100
一旦pgbouncer接手,我查pgbouncer.log
,发现许多条目如下:
2016-11-15 12:26:27.514 582 LOG S-0x1192740: dbname/[email protected]:5432 new connection to server
2016-11-15 12:26:27.517 582 LOG C-0x11afcb8: dbname/[email protected]:42262 login attempt: db=dbname user=myuser
2016-11-15 12:26:27.523 582 LOG S-0x1192a10: dbname/[email protected]:5432 new connection to server
2016-11-15 12:26:27.528 582 LOG C-0x11af880: dbname/[email protected]:42250 closing because: client close request (age=0)
2016-11-15 12:26:27.528 582 LOG S-0x1191a98: dbname/[email protected]:5432 closing because: unclean server (age=0)
2016-11-15 12:26:27.548 582 LOG C-0x11afb50: dbname/[email protected]:42258 closing because: client close request (age=0)
2016-11-15 12:26:27.556 582 LOG C-0x11aff88: dbname/[email protected]:42256 closing because: client close request (age=0)
2016-11-15 12:26:27.556 582 LOG S-0x1191c00: dbname/[email protected]:5432 closing because: unclean server (age=0)
2016-11-15 12:26:27.564 582 LOG C-0x11aff88: dbname/[email protected]:42264 login attempt: db=dbname user=myuser
2016-11-15 12:26:27.569 582 LOG C-0x11afb50: dbname/[email protected]:42265 login attempt: db=dbname user=myuser
2016-11-15 12:26:27.570 582 LOG S-0x1191c00: dbname/[email protected]:5432 new connection to server
2016-11-15 12:26:27.593 582 LOG C-0x11af448: dbname/[email protected]:42255 closing because: client close request (age=0)
2016-11-15 12:26:27.593 582 LOG C-0x11afcb8: dbname/[email protected]:42262 closing because: client close request (age=0)
2016-11-15 12:26:27.593 582 LOG S-0x1191c00: dbname/[email protected]:5432 closing because: unclean server (age=0)
2016-11-15 12:26:27.597 582 LOG C-0x11afb50: dbname/[email protected]:42265 closing because: client close request (age=0)
2016-11-15 12:26:27.603 582 LOG C-0x11afb50: dbname/[email protected]:42267 login attempt: db=dbname user=myuser
2016-11-15 12:26:27.604 582 LOG C-0x11afcb8: dbname/[email protected]:42268 login attempt: db=dbname user=myuser
如果仔细分析的closing because: unclean server
和closing because: client close request
许多实例中发现日志文件。任何人都可以解释这些是什么?也许我做错了什么。表面上看,我的应用程序似乎到目前为止运行正常。但我需要了解我在日志文件中看到的内容,因此我可以确定是什么。提前致谢。
感谢您的深度响应。我的日志条目中超过95%的客户端关闭请求的“age = 0”。你认为这是正常的吗? –
嗯,pgbouncer在任何地方记录日志都是完整的,如上所述,它会在每次登录尝试(一个连接到pgbouncer的客户端)之后出现。 –