当前位置: 动力学知识库 > 问答 > 编程问答 >

postgresql - Can't connect to greenplum with error message : "no pg_hba.conf entry"

问题描述:

I'm using gp 4.3.7.2, and I followed the manual http://120.52.72.46/gpdb.docs.pivotal.io/c3pr90ntcsf0/gs/43/pdf/GPDB43xGettingStarted.pdf

I can connect to server with admin user, but when I try to use another user, I get the error message

psql: FATAL: no pg_hba.conf entry for host "[local]", user "gpuser", database "rdw", SSL off

I've already done some research on stackoverflow. I modified the pg_hba.conf, add an entry

host all all 0.0.0.0/0 md5

and then reload the config file with gpstop -u and SELECT pg_reload_conf();, even tried to restart the gp server. But I still get the same error.

I also tried other entries like

host all all 127.0.0.1/32 md5

this didn't work too.

Please tell me how to fix this.

edit:

I reinstalled the database in single node mode and followed exactly the manual mentioned before. I create two users : user1, user2 and grant role users to these two users.

What I executed:

In command line:

$ createuser -P user1

Enter password for new role:

Enter it again:

Shall the new role be a superuser? (y/n) n

Shall the new role be allowed to create databases? (y/n) y

Shall the new role be allowed to create more new roles? (y/n) n

In psql:

=# CREATE USER user2 WITH PASSWORD 'changeme' CREATEDB NOSUPERUSER;

=# CREATE ROLE users;

=# GRANT users TO user1, user2;

Here is my whole pg_hba.conf, which is located at /data/gp/server/master/gpsne-1/pg_hba.conf. I add the last 3 lines.

local all hadoop ident

host all hadoop 127.0.0.1/28 trust

host all hadoop 10.10.10.32/32 trust

host all hadoop ::1/128 trust

host all hadoop fe80::d6ae:52ff:feb9:87c2/128 trust

local replication hadoop ident

host replication hadoop samenet trust

local tutorial +users md5

local tutorial +users 127.0.0.1/28 md5

hostssl tutorial +users samenet md5

But I still get the same error.

psql: FATAL: no pg_hba.conf entry for host "[local]", user "user1", database "tutorial", SSL off

When I installed the database, I got a warning message, not sure if it is related.

20160302:10:44:51:023434 gpinitsystem:bobcat04:hadoop-[WARN]:-Host 127.0.0.1 is assigned as localhost in /etc/hosts

20160302:10:44:51:023434 gpinitsystem:bobcat04:hadoop-[WARN]:-This will cause segment->master communication failures

20160302:10:44:51:023434 gpinitsystem:bobcat04:hadoop-[WARN]:-Remove 127.0.0.1 from local host line in /etc/hosts

网友答案:

You have a mistake in the 2nd last line:

local tutorial +users 127.0.0.1/28 md5

There should not be an IP address listed for local connections.

Did you run gpstop -u to reload after making the changes? I suspect the reload failed due to the invalid line.

Remove the line and run gpstop -u again and try to connect again.

网友答案:
psql: FATAL:  no pg_hba.conf entry for host "[local]", user "gpuser", database "rdw", SSL off

This means you are trying to connect to Greenplum from the master host using psql and without specifying the hostname. If you just type this:

psql

The psql client will attempt to connect to the LOCAL instance of Greenplum. The pg_hba.conf entry you added was for HOST authentication, not LOCAL.

You can fix this by doing one of two things.

  1. When using psql and you want to authenticate with a HOST entry from the pg_hba.conf file, add the -h option. This tells the client to connect to Greenplum and authenticate with the host entry.

    psql -h mdw
    
  2. You can also add an entry to the bottom of the pg_hba.conf file like this:

    local all all md5
    

    or if you trust everyone locally

    local all all trust
    

More information on the pg_hba.conf file is here: http://www.postgresql.org/docs/8.2/static/auth-pg-hba-conf.html

分享给朋友:
您可能感兴趣的文章:
随机阅读: