3

我正在使用pgAdmin3并使用pkg安装postgreSQL和第 我试图通过tomcat连接到postgreSQL当我做./startup。从我的tomcat/bin目录中的日志文件SH显示了这个错误:错误检测数据库类型:无法创建PoolableConnectionFactory(致命:没有pg_hba.conf

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metaModelDAO' defined in class path resource [applicationContext-coreDataServices.xml]: Invocation of init method failed; nested exception is org.apache.cayenne.CayenneRuntimeException: [v.3.0.1.LB Nov 16 2011 05:24:11] Error detecting database type: Cannot create PoolableConnectionFactory (FATAL: no pg_hba.conf entry for host "10.0.0.197", user "abc_writer", database "abc", SSL off)

以下是我在我的context.xml:

<Context> 
    <Resource username="abc_writer" password="levelsbeyond" 
       url="jdbc:postgresql://localhost:5432/abc" 
      type="javax.sql.DataSource" name="jdbc/abc-workflow" 
      maxWait="10000" maxIdle="20" maxActive="50" 
      driverClassName="org.postgresql.Driver" auth="Container" /> 
</Context> 

这里是我的pg_hba.config的样子:

# TYPE DATABASE  USER   ADDRESS     METHOD 
# "local" is for Unix domain socket connections only 
local all    all          md5 
# IPv4 local connections: 
host all    all    127.0.0.1/32   md5 
# IPv6 local connections: 
host all    all    ::1/128     md5 
# Allow replication connections from localhost, by a user with the 
# replication privilege. 
#local replication  postgres        md5 
#host replication  postgres  127.0.0.1/32   md5 
#host replication  postgres  ::1/128     md5 
host  abc  abc_writer  10.0.0.197  md5 

当我从PostgreSQL的/ bin中开拓邮政局长它读取此:

localhost:~ bryanraymond$ /Library/PostgreSQL/9.3/bin/postgres ; exit; 
postgres cannot access the server configuration file  
"/Library/PostgreSQL/9.3/data/postgresql.conf": Permission denied 
logout 

但愿它说我有pg_hba.conf中的条目是因为我没有权限,如果这样怎么做的原因我获得许可?如果这不是问题,我是否有设置错误?

---谢谢你,布莱恩

+0

当你运行'psql -h localhost -U abc_writer -d abc'时会发生什么? –

+0

我得到这个:localhost:〜bryanraymond $ psql -h localhost -U abc_writer -d abc psql(9.1.9,server 9.3.0) 警告:psql版本9.1,服务器版本9.3。 某些psql功能可能无法正常工作。 输入“help”寻求帮助。 abc =# – user2864917

回答

2

您的pg_hba.conf中的错误路线。它应该阅读

host abc abc_writer 10.0.0.197/32 md5

注意 “/ 32”。做出这个改变后,你需要重新载入你的Postgresql配置(例如“pg_ctl reload”)。但我不确定“拒绝的权限”是什么。

+0

更改pg_hba.conf文件后,我尝试了pg_ctl restart并且出现此错误。 localhost:〜bryanraymond $ pg_ctl restart pg_ctl:无法打开PID文件“/Library/PostgreSQL/9.3/data/postmaster.pid”:权限被拒绝。当我这样做时出现这个错误:localhost:〜bryanraymond $ sudo pg_ctl restart 密码: pg_ctl:无法以root身份运行当我尝试运行postgres用户时,我得到这个localhost:〜bryanraymond $ su postgres pg_ctl restart 密码: /usr/local/bin/pg_ctl:/ usr/local/bin/pg_ctl:无法执行二进制文件 – user2864917

+0

postgresql.conf和pg_hba.conf文件应由postgres用户拥有(或任何操作系统用户拥有postgres $ PGDATA数据文件)。 – bma

相关问题