1 year ago

#315026

test-img

H-X-P

fatal error : ssl closed pg_hba.conf site, database tool can connect to postgre but in code throw exception

I use flink cdc 2.0.0 to connect to postgresql in vmware.

I can connect to mysql in VM and do the SELECT in my code. But I can't do the same to postgres. And it throw an exception 'FATAL: no pg_hba.conf entry for host "192.168.42.1", user "postgres", database "mydb", SSL off error'

Caused by: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "192.168.42.1", user "postgres", database "mydb", SSL off error
    at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:525)
    at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:146)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:197)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
    at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:217)
    at org.postgresql.Driver.makeConnection(Driver.java:458)
    at org.postgresql.Driver.connect(Driver.java:260)
    at io.debezium.jdbc.JdbcConnection.lambda$patternBasedFactory$1(JdbcConnection.java:231)
    at io.debezium.jdbc.JdbcConnection.connection(JdbcConnection.java:872)
    at io.debezium.jdbc.JdbcConnection.connection(JdbcConnection.java:867)
    at io.debezium.connector.postgresql.TypeRegistry.<init>(TypeRegistry.java:122)
    ... 8 more
    Suppressed: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "192.168.42.1", user "postgres", database "mydb", SSL off error
        at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:525)
        at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:146)
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:206)
        ... 16 more

I have modified the settings in pg_hba.conf and postgresql.conf:

host    all             all              all                    trust  # at the bottom of the file
listen_addresses = '*'

And it's weird that there's no problem using the database tool DBeaver, this can create and select...

Here's my code:

 DebeziumSourceFunction<String> source = PostgreSQLSource.<String>builder()
                .hostname("192.168.42.130")
                .port(5432)
                .username("postgres")
                .password("123456")
                .database("mydb")
                .schemaList("public")
                .tableList("big_data_public.public.user")
                .deserializer(new StringDebeziumDeserializationSchema())
                .build();

The ip '192.168.42.130' is the ip of my VM.

The ip '192.168.42.1' is the ip of VMware Network Adapter VMnet8.(I don't understand why the code throw an exception with this IP)

postgresql

apache-flink

vmware

cdc

0 Answers

Your Answer

Accepted video resources