PostgreSQL-致命:用户身份验证失败
我在postgres中创建了一个简单的表,名为PostgreSQL-致命:用户身份验证失败,postgresql,centos,centos7,sqoop,Postgresql,Centos,Centos7,Sqoop,我在postgres中创建了一个简单的表,名为employees,位于数据库mytestdb 我想将此表导入hdfs bin/sqoop import --connect 'jdbc:postgresql://127.0.0.1/mytestdb' --username user -P --table employees --target-dir /user/postgres 但是,我一直收到一个错误: 警告:连接到127.0.0.1:5432时发生SQLException org.postg
employees
,位于数据库mytestdb
我想将此表导入hdfs
bin/sqoop import --connect 'jdbc:postgresql://127.0.0.1/mytestdb' --username user -P --table employees --target-dir /user/postgres
但是,我一直收到一个错误:
警告:连接到127.0.0.1:5432时发生SQLException
org.postgresql.util.PSQLException:致命:身份验证失败
对于用户“用户”,请访问
org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:473)
/var/lib/pgsql/data/pg_hba.conf
设置如下:
# 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 ident
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
有关更多详细信息,请查看中的日志文件(对于CentOS,可能位于/var/lib/pgsql/data/pgu log
)
如果用户不存在,请创建它。使用psql
,您可以:
或从:
如果未安装ident
,请安装:
yum install authd xinetd
然后编辑/etc/xinet.d/auth
并将disable=yes
更改为disable=no
:
service auth
{
disable = no
socket_type = stream
....
}
然后重新启动xinetd
服务:
systemctl restart xinetd
我从网上的几个不同来源中找到了一个可行的解决方案 编辑配置文件
nano /var/lib/pgsql/data/pg_hba.configuration
用md5替换前两个ident
,如下所示:
# 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 peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
保存文件
然后,重新启动服务器
sudo systemctl restart postgresql
最后,
将数据库testdb上的所有权限授予hduser代码>您的服务器是否在tcp端口113上运行?postgres日志怎么说(在centos上,可能是/var/lib/pgsql/data/logs)?我怎么知道ident正在运行?我没有/var/lib/pgsql/data/logs,但是有/var/lib/pgsql/data/pgu log,还有今天的日志:postgresql-Sun.log在这个目录中这是正确的日志,有什么有用的吗?检查identd是否正在使用诸如service identd status
,ps afx | grep identd
,telnet localhost 113
,netstat-a
之类的命令运行,我如何知道identd正在运行telnet localhost 113
#ftfyAh,谢谢。更新用户的更新:您可能需要sudo service postgresql-XX.service restart
(其中XX是您的Postgres版本,在我的例子中是11)而不是sudo systemctl restart postgresql
。在某些版本中,文件位于nano/var/lib/pgsql/data/pg_hba.conf
# 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 peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
sudo systemctl restart postgresql