postgresql-fatal:用户身份验证失败

yzuktlbb  于 2021-06-03  发布在  Sqoop
关注(0)|答案(2)|浏览(418)

我在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时发生sqlexception:5432 org.postgresql.util.psqlexception:致命:org.postgresql.core.v3.connectionfactoryimpl.doauthentication(connectionfactoryimpl)处的用户“user”的身份验证失败。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
sczxawaw

sczxawaw1#

我从网上几个不同的来源中找到了一个可行的解决方案。
编辑配置文件

nano /var/lib/pgsql/data/pg_hba.configuration

更换前两个 ident 与md5一起使用,如下所示:


# 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

最后, grant all privileges on database testdb to hduser;

vbopmzt1

vbopmzt12#

签入日志文件(对于centos,可能在 /var/lib/pgsql/data/pg_log )更多细节。
如果用户不存在,请创建它。与 psql ,您可以创建如下用户:

create role hduser with login, superuser;

或从命令行:

createuser -s -e hduser

如果 identd 未安装,请安装:

yum install authd xinetd

然后编辑 /etc/xinet.d/auth 和改变 disable = yesdisable = no :

service auth 
{ 
        disable = no 
        socket_type = stream 
        ....
}

然后重新启动 xinetd 服务:

systemctl restart xinetd

相关问题