首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >与pgBouncer搏斗

与pgBouncer搏斗
EN

Database Administration用户
提问于 2013-02-05 10:53:14
回答 2查看 8.1K关注 0票数 6

我有Postgres9.2和PgBouncer (与‘堆栈构建器’一起提供的版本)。我有一个.net应用程序通过win7机器上的Npgsql版本2.0.12连接。

我的应用程序可以很高兴地直接连接到postgres服务器,但总是无法通过pgb强连接。

我到npgsql的连接字符串(在进行了一些替换之后)

代码语言:javascript
运行
复制
Sslmode=Prefer;Timeout=40;Server={0};Port={3};User Id={4};Password={1};Database={2};Pooling=False;

(我还尝试使用PgBounce显式地连接Protocol=3,但这是行不通的。)

pgBounce ini中的数据库行是:

代码语言:javascript
运行
复制
[databases]
something = host=localhost port=5433 dbname=somethingelse user=someone password=aaa

在userlist.txt中,我有“某人”,"aaa“,根据需要。

当我的应用程序运行时,npgsql说“连接被迫关闭”,而pgbouncer错误日志上写着:

代码语言:javascript
运行
复制
2013-02-06 20:16:57.594 2444 LOG File descriptor limit: -1 (H:-1), max_client_conn: 1000, max fds possible: 1030
2013-02-06 20:16:57.649 2444 LOG listening on ::/6433
2013-02-06 20:16:57.657 2444 LOG listening on 0.0.0.0:6433
2013-02-06 20:16:57.659 2444 LOG process up: pgbouncer 1.5.2, libevent 2.0.19-stable (win32), adns: evdns2
2013-02-06 20:17:22.066 2444 LOG C-01819410: something/someone@fe80::997b:396e:eacc:dd2b:3013 login attempt: db=somethingelse user=someone
2013-02-06 20:17:22.130 2444 LOG S-01836648: something/someone@127.0.0.1:5433 new connection to server
2013-02-06 20:17:24.069 2444 LOG C-01819410: something/someone@fe80::997b:396e:eacc:dd2b:3013 closing because: client close request (age=2)
2013-02-06 20:17:26.319 2444 LOG C-01819410: (nodb)/(nouser)@fe80::997b:396e:eacc:dd2b:3023 closing because: bad packet header (age=0)
2013-02-06 20:17:26.322 2444 WARNING C-01819410: (nodb)/(nouser)@fe80::997b:396e:eacc:dd2b:3023 Pooler Error: bad packet header

npgsql异常如下:(从app中的日志文件来看,最顶层的异常遵循嵌套的异常):

代码语言:javascript
运行
复制
Exception message:  Unable to read data from the transport connection: An established connection was aborted by the software in your host machine.
Exception source:  Npgsql
Exception stacktrace:     at Npgsql.NpgsqlClosedState.Open(NpgsqlConnector context) in Z:\Projectdirectory\Npgsql2.0.12.0.src\src\Npgsql\NpgsqlClosedState.cs:line 232
at Npgsql.NpgsqlConnector.Open() in Z:\Projectdirectory\Npgsql2.0.12.0.src\src\Npgsql\NpgsqlConnector.cs:line 695
at Npgsql.NpgsqlConnectorPool.GetNonPooledConnector(NpgsqlConnection Connection) in Z:\Projectdirectory\Npgsql2.0.12.0.src\src\Npgsql\NpgsqlConnectorPool.cs:line 346
at Npgsql.NpgsqlConnectorPool.RequestConnector(NpgsqlConnection Connection) in Z:\Projectdirectory\Npgsql2.0.12.0.src\src\Npgsql\NpgsqlConnectorPool.cs:line 185
at Npgsql.NpgsqlConnection.Open() in Z:\Projectdirectory\Npgsql2.0.12.0.src\src\Npgsql\NpgsqlConnection.cs:line 543
at *snip* the thing in my code that goes and opens the connection *snip*
-----------------------------------------------------
Exception message:  Unable to read data from the transport connection: An established connection was aborted by the software in your host machine.
Exception source:  System
Exception stacktrace:     at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.Stream.ReadByte()
at Npgsql.NpgsqlClosedState.Open(NpgsqlConnector context) in Z:\Projectdirectory\Npgsql2.0.12.0.src\src\Npgsql\NpgsqlClosedState.cs:line 184
-----------------------------------------------------
Exception message:  An established connection was aborted by the software in your host machine
Exception source:  System
Exception stacktrace:     at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

此外,窗口防火墙关闭,反病毒我暂时关闭。

postgres的HBA conf文件有:

代码语言:javascript
运行
复制
host    all             all             127.0.0.1/32            md5
host    all             all           192.168.0.1/16            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
host    all             all         fe80::1/16                  md5

我在谷歌上搜索过没有找到解决方案。帮助!谢谢。

彼得。

EN

回答 2

Database Administration用户

回答已采纳

发布于 2013-02-06 09:45:21

阿!该死!我找到了答案。

我的连接字符串有SslMode=Prefer

我把这个拿走了,瞧!pgBouncer成功了!!我的连接字符串现在是:

代码语言:javascript
运行
复制
Timeout=40;Server={0};Port={3};User Id=someone;Password={1};Database={2};Pooling=False;Protocol=3;

感谢大家的时间和努力。

票数 5
EN

Database Administration用户

发布于 2013-02-05 13:26:12

userlist.txt文件包含用于从客户端连接到PgBouncer的帐户。[databases]部分包含从PgBouncer连接到后端PostgreSQL服务器的登录信息。你好像把这两个人混在一起了。

当您从客户端连接到PgBouncer时,需要从userlist.txt提供用户名和密码,在本例中需要提供something的数据库名称。

票数 9
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/34136

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档