PostgreSQL - 致命:用户身份验证失败

时间:2018-04-29 09:47:30

标签: postgresql centos centos7 sqoop

我在postgres中创建了一个名为#include <iostream> #include <string> #include <vector> #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/bind.hpp> namespace client { namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::ascii; class ParserActions { public: void printivec (std::vector<int> const& ivec) { std::cout << "We see " << ivec.size() << " integers" << std::endl; } }; template <typename Iterator> bool parse_ivec(Iterator first, Iterator last) { using ascii::space; ParserActions actionContainer; auto two_ints = (qi::int_ >> qi::int_); bool r = qi::parse( first, /*< start iterator >*/ last, /*< end iterator >*/ two_ints[boost::bind(&ParserActions::printivec,&actionContainer,_1)] ); return first == last && r; } } int main() { std::string str = "12 13"; if (client::parse_ivec(str.begin(),str.end())) std::cout << "Parsing succeeded\n"; else std::cout << "Parsing failed!\n"; return 0; } 的简单表格employees

我想将此表导入hdfs。

mytestdb

但是,我一直收到错误:

  

警告:连接到127.0.0.1:5432时发生SQLException   org.postgresql.util.PSQLException:致命:Ident身份验证失败   对于用户“用户”来说   org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:473)

bin/sqoop import --connect 'jdbc:postgresql://127.0.0.1/mytestdb' --username user -P --table employees --target-dir /user/postgres 设置如下:

/var/lib/pgsql/data/pg_hba.conf

2 个答案:

答案 0 :(得分:5)

我从网络上的几种不同来源中找到了可行的解决方案。

编辑配置文件

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

用md5替换前两个 ident ,如下所示:

 #类型数据库用户地址方法

#“本地”仅适用于Unix域套接字连接
本地所有md5
#IPv4本地连接:
托管所有所有127.0.0.1/32 md5
#IPv6本地连接:
托管所有所有:: 1/128 md5
#允许具有以下权限的用户从localhost复制连接
#复制特权。
#local复制Postgres对等体
#host复制postgres 127.0.0.1/32 ident
#host复制Postgres :: 1/128 ident
 

保存文件。

然后,重新启动服务器

  sudo systemctl重新启动PostgreSQL
 

最后,将数据库testdb的所有特权授予hduser;

答案 1 :(得分:1)

检查日志文件(对于CentOS,可能在/var/lib/pgsql/data/pg_log中)以获取更多详细信息。

如果用户不存在,请创建它。使用psql,您可以create a user喜欢:

create role hduser with login, superuser;

或者来自command line

createuser -s -e hduser

如果未安装identd,请安装它:

yum install authd xinetd

然后修改/etc/xinet.d/auth并将disable = yes更改为disable = no

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

然后重新启动xinetd服务:

systemctl restart xinetd