Debezium同步PostgreSQL数据报:permission denied for database databaseName

问题描述:

配置启动Debezium任务同步PostgreSQL表数据时报:

org.apache.kafka.connect.errors.ConnectException: Unable to create to filtered publication slot_name_task1 for tableName1,tableName2,tableName3

....

io.debezium.connector.postgresql.connection.PostgresReplicationConnection.initPublication(PostgresReplicationConnection.java:164)

at io.debezium.connector.postgresql.connection.PostgresReplicationConncetion.createReplicationSlot(PostgresReplicationConnction.java:343) 

...

Caused by: org.postgresql.util.PSQLException: ERROR: permission denied for database databaseName 

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2532)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267) 

...

解决方法:

为抽取所用PostgreSQL用户赋予相应数据create权限,赋权命令参考:

grant create on database databaseName to username

其实我调试时是直接赋予了用户全部数据库权限:

grant all on database databaseName to username

另外使用的PostgreSQL用户还必须拥有表的Owner权限和replication角色,如果没有对应权限会报相应错误如:

must be owner of table tableName

如果报:

Caused by: org.posgresql.util.PSQLException: ERROR: must be owner of table databasechangelog 

at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExceptionImpl.java:2532)

at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2267)

at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:312)

...

可以通过把需要抽取的表名称配置在whitelist解决

你可能感兴趣的:(Spark,Java,日志,postgresql,数据库,database,debezium,大数据)