【问题标题】:Validation error ...........: Value '<TestStream>' at 'streamName' failed to satisfy constraint验证错误............:“streamName”处的值“<TestStream>”未能满足约束
【发布时间】:2020-05-25 13:21:37
【问题描述】:

尝试将流数据从 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-rds amazon-kinesis


    【解决方案1】:

    这意味着名称 "&lt;TestStream&gt;" 是无效的 Kinesis 流名称。使用您在 AWS 中创建的 Kinesis 流名称。

    Kinesis 名称必须匹配正则表达式模式[a-zA-Z0-9_.-]+

    【讨论】:

    • 是的。我使用了我在 kinesis 中创建的相同 Stream name 。我交叉检查了。
    • 请创建一个名称与语法 [a-zA-Z0-9_.-]+ 匹配的流。左右箭头是问题
    • 我创建了另一个,但仍然显示相同的错误。你能告诉我这个语法的一个例子吗?
    • 您的新流名称是什么?一个有效的例子是TestStream
    • 我把mysql-KINESIS_Stream.20
    猜你喜欢
    • 2016-09-10
    • 2020-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-27
    • 1970-01-01
    • 2015-08-24
    • 1970-01-01
    相关资源
    最近更新 更多