簡體   English   中英

Embedded-Debezium spring boot postgreSQL DB 連接問題

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

我嘗試將 postgreSQL 與 spring boot 和嵌入式 debezium 連接起來,數據庫連接正在建立,表被鎖定后,我的訪問被拒絕。 我正在使用復制訪問權限登錄。 請找到以下日志。

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

請檢查您的角色loginUser 權限

設置 PostgreSQL 服務器以運行 Debezium 連接器需要可以執行復制的數據庫用戶。 復制只能由具有適當權限的數據庫用戶執行,並且只能用於配置數量的主機。

根據我的經驗,需要(從 v10.x 開始使用 pgoutput 插件):

  • 在數據庫實例上啟用邏輯復制;
  • 屬於 REPLICATION(或 AWS RDS 的 rds_replication - 無服務器選項似乎已被破壞多年)角色的用戶;
  • 是所有白名單表的所有者(連接到數據庫的用戶);
  • 對所有列入白名單的表和序列進行 USE、SELECT;
  • 有權訪問“公共”模式(元數據)上的 USE、SELECT;
  • 有權在“公共”模式上創建對象。

注意:如果上面的列表太多,擁有 rds_admin 的要求不是一項要求,而是一種簡單的入門方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM