View a markdown version of this page

AWS CLI를 사용하여 복제기 생성 - Amazon Managed Streaming for Apache Kafka

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS CLI를 사용하여 복제기 생성

create-replicator 명령을 사용하여 MSK Replicator를 생성합니다. 시작하기 전에 MSK Replicator를 생성하는 데 필요한 IAM 권한 및를 완료했는지 확인합니다소스 및 대상 클러스터 준비.

참고

아래 예제는 두 MSK 클러스터 간의 복제를 보여줍니다. MSK Replicator는 자체 관리형 Apache Kafka 클러스터와 Express 브로커가 있는 MSK 프로비저닝된 클러스터 간의 복제도 지원합니다. 해당 시나리오를 다루는 API 예제는 섹션을 참조하세요자체 관리형 Kafka 클러스터에 대한 CreateReplicator API 예제.

aws kafka create-replicator \ --replicator-name "<replicator-name>" \ --service-execution-role-arn "arn:aws:iam::<account-id>:role/<role-name>" \ --kafka-clusters '[ { "AmazonMskCluster": {"MskClusterArn": "<source-cluster-arn>"}, "VpcConfig": { "SubnetIds": ["<subnet-1>", "<subnet-2>"], "SecurityGroupIds": ["<security-group-id>"] } }, { "AmazonMskCluster": {"MskClusterArn": "<target-cluster-arn>"}, "VpcConfig": { "SubnetIds": ["<subnet-1>", "<subnet-2>"], "SecurityGroupIds": ["<security-group-id>"] } } ]' \ --replication-info-list '[ { "SourceKafkaClusterArn": "<source-cluster-arn>", "TargetKafkaClusterArn": "<target-cluster-arn>", "TopicReplication": { "TopicsToReplicate": [".*"], "CopyTopicConfigurations": true, "CopyAccessControlListsForTopics": true, "DetectAndCopyNewTopics": true, "StartingPosition": {"Type": "LATEST"}, "TopicNameConfiguration": {"Type": "PREFIXED"} }, "ConsumerGroupReplication": { "ConsumerGroupsToReplicate": [".*"], "ConsumerGroupOffsetSyncMode": "LEGACY" }, "TargetCompressionType": "NONE" } ]'

복제기를 생성할 때 로그 전송을 활성화하려면 --log-delivery 파라미터를 포함합니다. 다음 예시에서는 Amazon CloudWatch Logs, Amazon S3 및 Amazon Data Firehose로 로그 전송을 활성화합니다.

aws kafka create-replicator \ --replicator-name "<replicator-name>" \ --service-execution-role-arn "arn:aws:iam::<account-id>:role/<role-name>" \ --kafka-clusters '[ { "AmazonMskCluster": {"MskClusterArn": "<source-cluster-arn>"}, "VpcConfig": { "SubnetIds": ["<subnet-1>", "<subnet-2>"], "SecurityGroupIds": ["<security-group-id>"] } }, { "AmazonMskCluster": {"MskClusterArn": "<target-cluster-arn>"}, "VpcConfig": { "SubnetIds": ["<subnet-1>", "<subnet-2>"], "SecurityGroupIds": ["<security-group-id>"] } } ]' \ --replication-info-list '[ { "SourceKafkaClusterArn": "<source-cluster-arn>", "TargetKafkaClusterArn": "<target-cluster-arn>", "TopicReplication": { "TopicsToReplicate": [".*"], "CopyTopicConfigurations": true, "CopyAccessControlListsForTopics": true, "DetectAndCopyNewTopics": true, "StartingPosition": {"Type": "LATEST"}, "TopicNameConfiguration": {"Type": "PREFIXED"} }, "ConsumerGroupReplication": { "ConsumerGroupsToReplicate": [".*"] }, "TargetCompressionType": "NONE" } ]' \ --log-delivery '{ "ReplicatorLogDelivery": { "CloudWatchLogs": { "Enabled": true, "LogGroup": "/mskr/logs/<log-group-name>" }, "S3": { "Enabled": true, "Bucket": "<s3-bucket-name>", "Prefix": "<optional-prefix>" }, "Firehose": { "Enabled": true, "DeliveryStream": "<delivery-stream-name>" } } }'

하나 이상의 로그 전송 대상을 활성화할 수 있습니다. Amazon CloudWatch Logs만 활성화하려면 S3Firehose 필드를 생략하거나 해당 Enabled 값을 로 설정합니다false. 로그 전송에 대한 자세한 내용은 섹션을 참조하세요MSK Replicator 로그.

참고

로그 전송이 활성화된 경우 IAM 역할에 구성된 로그 대상에 쓰는 데 필요한 추가 권한이 있어야 합니다. 필요한 권한은 AWS 서비스에서 로깅 활성화를 참조하세요.

전체 API 참조는 Amazon MSK API 참조의 CreateReplicator를 참조하세요.

선택적 주제 복제

topicsToReplicate 및에서 정규식 패턴을 사용하여 복제되는 주제를 topicsToExclude 제어합니다. 다음 예제에서는 로 시작하는 주제를 복제prod-하고 로 시작하는 주제를 제외합니다. test-

"topicReplication": { "topicsToReplicate": ["prod-.*"], "topicsToExclude": ["test-.*"], "detectAndCopyNewTopics": true }

Replicator 상태 확인

Replicator를 생성한 후 describe-replicator 명령을 사용하여 상태를 확인합니다.

aws kafka describe-replicator \ --replicator-arn arn:aws:kafka:us-east-1:123456789012:replicator/my-replicator/xxx

복제기는 CREATINGRUNNING 상태로 진행됩니다. 복제기가 RUNNING 상태에 도달할 때까지 약 30분 정도 기다립니다. 로 전환되는 경우 단원을 FAILED참조하십시오Amazon MSK Replicator 문제 해결.