验证错误.....: 在'streamName'处的值'<TestStream>'未能满足约束条件。

问题描述 投票:0回答:1

当我试图将流数据从MYSQL迁移到Kinesis时,出现了错误。请帮我解决这个问题。

botocore.exceptions.ClientError: 当调用PutRecord操作时发生了一个错误(ValidationException)。检测到1个验证错误。'streamName'处的值''未能满足约束条件。成员必须满足正则表达式模式。[a-zA-Z0-9_.-]+。

import json
import boto3
import pymysql
import socket,array
import pandas as pd
from datetime import datetime
from pymysqlreplication import BinLogStreamReader
from pymysqlreplication.row_event import (
    DeleteRowsEvent,
    UpdateRowsEvent,
    WriteRowsEvent,
)
class DateTimeEncoder(json.JSONEncoder):
    def default(self, o):
        if isinstance(o, datetime):
            return o.isoformat()

        return json.JSONEncoder.default(self, o)

connection = {
    "host": "127.0.0.1",
    "port": 3306,
    "user": "root",
    "passwd": "root"}

def main():
  kinesis = boto3.client("kinesis",region_name='ap-south-1')
  stream = BinLogStreamReader(
            connection_settings=connection,
            only_events=[DeleteRowsEvent, WriteRowsEvent, UpdateRowsEvent],
            server_id=100,
            blocking=True,
            log_file='mysql-bin.000003',
            resume_stream=True,
        )
  for binlogevent in stream:
    for row in binlogevent.rows:
      event = {"schema": binlogevent.schema,
      "table": binlogevent.table,
      "type": type(binlogevent).__name__,
      "row": row
      }       
      kinesis.put_record(StreamName="<MysqlKinesisStream>", Data=json.dumps(event,cls=DateTimeEncoder), 
PartitionKey="default",)
      print (json.dumps(event))
if __name__ == "__main__":
   main()
python amazon-web-services amazon-kinesis rds
1个回答
0
投票

这意味着名称 "<TestStream>" 是一个无效的 Kinesis 流名称。使用您在 AWS 中创建的 Kinesis 流名称。

Kinesis 名称必须符合 regex 模式。[a-zA-Z0-9_.-]+

© www.soinside.com 2019 - 2024. All rights reserved.