错误信息:
org.apache.kafka.connect.errors.ConnectException: An exception occurred in the change event producer. This connector will be stopped.\n\tat io.debezium.pipeline.ErrorHandler.setProducerThrowable(ErrorHandler.java:50)\n\tat io.debezium.connector.mongodb.MongoDbStreamingChangeEventSource.streamChangesForReplicaSet(MongoDbStreamingChangeEventSource.java:134)\n\tat io.debezium.connector.mongodb.MongoDbStreamingChangeEventSource.execute(MongoDbStreamingChangeEventSource.java:103)\n\tat io.debezium.connector.mongodb.MongoDbStreamingChangeEventSource.execute(MongoDbStreamingChangeEventSource.java:59)\n\tat io.debezium.pipeline.ChangeEventSourceCoordinator.streamEvents(ChangeEventSourceCoordinator.java:174)\n\tat io.debezium.pipeline.ChangeEventSourceCoordinator.executeChangeEventSources(ChangeEventSourceCoordinator.java:141)\n\tat io.debezium.pipeline.ChangeEventSourceCoordinator.lambda$startKaTeX parse error: Undefined control sequence: \n at position 41: …nator.java:109)\̲n̲\tat java.base/…RunnableAdapter.call(Executors.java:515)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutorKaTeX parse error: Undefined control sequence: \n at position 40: …cutor.java:628)\̲n̲\tat java.base/…establishConnectionToPrimaryKaTeX parse error: Undefined control sequence: \n at position 46: …ource.java:182)\̲n̲\tat io.debeziu…MongoPrimary.execute(ConnectionContext.java:292)\n\tat io.debezium.connector.mongodb.MongoDbStreamingChangeEventSource.streamChangesForReplicaSet(MongoDbStreamingChangeEventSource.java:122)\n\t… 10 more\nCaused by: com.mongodb.MongoCommandException: Command failed with error 40415 (Location40415): 'BSON field 'KaTeX parse error: Expected group as argument to '\"' at end of input: …tionTime\": {\"timestamp": {“t”: 1710223008, “i”: 1}}, “ok”: 0.0, “errmsg”: “BSON field 'KaTeX parse error: Expected group as argument to '\"' at end of input: …tion40415\", \"clusterTime”: {“clusterTime”: {“KaTeX parse error: Expected 'EOF', got '}' at position 43: …3008, \"i\": 1}}̲, \"signature\"…binary”: {“base64”: “Ko2QoaLTjGgHa5R1h7y707NeQdk=”, “subType”: “00”}}, “keyId”: 7330901964680593409}}}\n\tat com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:195)\n\tat com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:400)\n\tat com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:324)\n\tat com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:114)\n\tat com.mongodb.internal.connection.DefaultConnectionPoolKaTeX parse error: Undefined control sequence: \n at position 64: …nPool.java:603)\̲n̲\tat com.mongod…DefaultServerProtocolExecutor.execute(DefaultServer.java:252)\n\tat com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:214)\n\tat com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:123)\n\tat com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:113)\n\tat com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:328)\n\tat com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:318)\n\tat com.mongodb.internal.operation.CommandOperationHelper.executeCommandWithConnection(CommandOperationHelper.java:201)\n\tat com.mongodb.internal.operation.CommandOperationHelper.lambda$executeCommand$4(CommandOperationHelper.java:189)\n\tat com.mongodb.internal.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:583)\n\tat com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:189)\n\tat com.mongodb.internal.operation.AggregateOperationImpl.execute(AggregateOperationImpl.java:195)\n\tat com.mongodb.internal.operation.ChangeStreamOperation$1.call(ChangeStreamOperation.java:323)\n\tat com.mongodb.internal.operation.ChangeStreamOperationKaTeX parse error: Undefined control sequence: \n at position 39: …ation.java:319)\̲n̲\tat com.mongod…DelegateOperationExecutor.execute(MongoClientDelegate.java:184)\n\tat com.mongodb.client.internal.ChangeStreamIterableImpl.execute(ChangeStreamIterableImpl.java:204)\n\tat com.mongodb.client.internal.ChangeStreamIterableImpl.cursor(ChangeStreamIterableImpl.java:158)\n\tat com.mongodb.client.internal.ChangeStreamIterableImpl.iterator(ChangeStreamIterableImpl.java:153)\n\tat io.debezium.connector.mongodb.MongoDbStreamingChangeEventSource.readChangeStream(MongoDbStreamingChangeEventSource.java:332)\n\tat io.debezium.connector.mongodb.MongoDbStreamingChangeEventSource.lambda$streamChangesForReplicaSetKaTeX parse error: Undefined control sequence: \n at position 46: …ource.java:124)\̲n̲\tat io.debeziu…MongoPrimary.execute(ConnectionContext.java:288)\n\t… 11 more\n
原source connector的配置:
{
"name": "source_mongo363_1406",
"config": {
"connector.class": "io.debezium.connector.mongodb.MongoDbConnector",
"mongodb.hosts": "192.168.0.195:27017,192.168.0.197:27017",
"topic.prefix": "source_mongo363_1406",
"mongodb.user": "root",
"mongodb.password": "xxx",
"mongodb.authsource": "admin",
"mongodb.name": "source_mongo363_1406",
"database.include.list": "test"
}
}
解决办法:
向source connector增加capture.mode:oplog
参数即可解决问题