简体   繁体   English

Embedded-Debezium spring boot postgreSQL DB 连接问题

[英]Embedded-Debezium spring boot postgreSQL DB connectivity issue

I tried connecting postgreSQL with spring boot and embedded debezium, the DB connection is getting established, after the table is locked i get access denied.我尝试将 postgreSQL 与 spring boot 和嵌入式 debezium 连接起来,数据库连接正在建立,表被锁定后,我的访问被拒绝。 I am logging in with replication access.我正在使用复制访问权限登录。 Kindly find the below logs.请找到以下日志。

2020-09-15 20:27:00.806  INFO 14784 --- [pool-3-thread-1] i.d.c.postgresql.PostgresConnectorTask   : user 'loginUser' connected to database 'pgDatabase' on PostgreSQL 12.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit with roles:
    role 'loginUser' [superuser: false, replication: true, inherit: true, create role: false, create db: false, can log in: true]
2020-09-15 20:27:00.813  INFO 14784 --- [pool-3-thread-1] i.d.c.p.connection.PostgresConnection    : Obtained valid replication slot ReplicationSlot [active=false, latestFlushedLsn=null, catalogXmin=null]
2020-09-15 20:27:00.813  INFO 14784 --- [pool-3-thread-1] i.d.c.postgresql.PostgresConnectorTask   : Found previous offset PostgresOffsetContext [sourceInfoSchema=Schema{io.debezium.connector.postgresql.Source:STRUCT}, sourceInfo=source_info[server='pgServer.com-pgDatabase'db='pgDatabase', lsn=LSN{2/61010900}, txId=14082, timestamp=2020-09-10T01:04:03.660Z, snapshot=FALSE], partition={server=pgServer.com-pgDatabase}, lastSnapshotRecord=true, lastCompletelyProcessedLsn=null, lastCommitLsn=null, transactionContext=TransactionContext [currentTransactionId=null, perTableEventCount={}, totalEventCount=0]]
2020-09-15 20:27:00.814  INFO 14784 --- [pool-3-thread-1] i.d.c.p.snapshot.InitialSnapshotter      : Previous snapshot has completed successfully, streaming logical changes from last known position
2020-09-15 20:27:00.871 DEBUG 14784 --- [           main] .m.m.a.ExceptionHandlerExceptionResolver : ControllerAdvice beans: 0 @ExceptionHandler, 1 ResponseBodyAdvice
2020-09-15 20:27:08.185  INFO 14784 --- [pool-3-thread-1] i.d.c.p.c.PostgresReplicationConnection  : Initializing PgOutput logical decoder publication
2020-09-15 20:27:08.243  INFO 14784 --- [pool-3-thread-1] i.d.c.p.c.PostgresReplicationConnection  : Creating new publication 'dbz_publication' for plugin 'PGOUTPUT'
2020-09-15 20:27:08.246  INFO 14784 --- [pool-3-thread-1] i.d.c.p.c.PostgresReplicationConnection  : Creating Publication with statement 'CREATE PUBLICATION dbz_publication FOR ALL TABLES;'
2020-09-15 20:27:08.765  INFO 14784 --- [pool-3-thread-1] o.a.k.c.storage.FileOffsetBackingStore   : Stopped FileOffsetBackingStore
2020-09-15 20:27:09.059 ERROR 14784 --- [pool-3-thread-1] io.debezium.embedded.EmbeddedEngine      : Unable to initialize and start connector's task class 'io.debezium.connector.postgresql.PostgresConnectorTask' with config: {connector.class=io.debezium.connector.postgresql.PostgresConnector, database.user=loginUser, database.dbname=pgDatabase, offset.storage=org.apache.kafka.connect.storage.FileOffsetBackingStore, database.server.name=pgServer.com-pgDatabase, database.port=5432, plugin.name=pgoutput, table.whitelist=schema.tableName, offset.flush.interval.ms=10000, offset.storage.file.filename=/Users/loginUser/student-offset.dat, database.hostname=pgServer.com, database.password=********, name=student-postgres-connector}

io.debezium.jdbc.JdbcConnectionException: ERROR: permission denied for database pgDatabase

Please check permissions of your role loginUser :请检查您的角色loginUser 权限

Setting up a PostgreSQL server to run a Debezium connector requires a database user who can perform replications.设置 PostgreSQL 服务器以运行 Debezium 连接器需要可以执行复制的数据库用户。 Replication can be performed only by a database user who has appropriate permissions and only for a configured number of hosts.复制只能由具有适当权限的数据库用户执行,并且只能用于配置数量的主机。

From my experience one needs (with pgoutput plugin starting from v10.x):根据我的经验,需要(从 v10.x 开始使用 pgoutput 插件):

  • Enable logical replication on DB instance;在数据库实例上启用逻辑复制;
  • User belonging to REPLICATION (or rds_replication for AWS RDS - server-less options seems to be broken for years) role;属于 REPLICATION(或 AWS RDS 的 rds_replication - 无服务器选项似乎已被破坏多年)角色的用户;
  • Be owner (the user connecting to DB) of all white-listed tables;是所有白名单表的所有者(连接到数据库的用户);
  • Have USE, SELECT on all white-listed tables and sequences;对所有列入白名单的表和序列进行 USE、SELECT;
  • Have access for USE, SELECT on "public" schema (meta data);有权访问“公共”模式(元数据)上的 USE、SELECT;
  • Have permissions to create objects on "public" schema.有权在“公共”模式上创建对象。

Note: the requirement to have rds_admin is not a requirement but simple way to get started if the list above is overhwhelming.注意:如果上面的列表太多,拥有 rds_admin 的要求不是一项要求,而是一种简单的入门方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM