#Get clustersawskafkalist-clustersawskafkalist-clusters-v2# Check the supported authenticationawskafkalist-clusters|jq-r".ClusterInfoList[].ClientAuthentication"# Get Zookeeper endpointsaws kafka list-clusters | jq -r ".ClusterInfoList[].ZookeeperConnectString, .ClusterInfoList[].ZookeeperConnectStringTls"
# Get nodes and node enspointsawskafkakafkalist-nodes--cluster-arn<cluster-arn>aws kafka kafka list-nodes --cluster-arn <cluster-arn> | jq -r ".NodeInfoList[].BrokerNodeInfo.Endpoints" # Get endpoints
# Get used kafka configsawskafkalist-configurations#Get Kafka config fileawskafkadescribe-configuration--arn<config-arn># Get version of configawskafkadescribe-configuration-revision--arn<config-arn>--revision<version># Get content of config version# If using SCRAN authentication, get used AWS secret name (not secret value)awskafkalist-scram-secrets--cluster-arn<cluster-arn>
Kafka IAM 访问(在无服务器中)
# Guide from https://docs.aws.amazon.com/msk/latest/developerguide/create-serverless-cluster.html# Download Kafkawgethttps://archive.apache.org/dist/kafka/2.8.1/kafka_2.12-2.8.1.tgztar-xzfkafka_2.12-2.8.1.tgz# In kafka_2.12-2.8.1/libs download the MSK IAM JAR file.cdkafka_2.12-2.8.1/libswgethttps://github.com/aws/aws-msk-iam-auth/releases/download/v1.1.1/aws-msk-iam-auth-1.1.1-all.jar# Create file client.properties in kafka_2.12-2.8.1/binsecurity.protocol=SASL_SSLsasl.mechanism=AWS_MSK_IAMsasl.jaas.config=software.amazon.msk.auth.iam.IAMLoginModulerequired;sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandler# Export endpoints addressexport BS=boot-ok2ngypz.c2.kafka-serverless.us-east-1.amazonaws.com:9098## Make sure you will be able to access the port 9098 from the EC2 instance (check VPS, subnets and SG)# Create a topic called msk-serverless-tutorialkafka_2.12-2.8.1/bin/kafka-topics.sh --bootstrap-server $BS --command-config client.properties --create --topic msk-serverless-tutorial --partitions 6
# Send message of every new linekafka_2.12-2.8.1/bin/kafka-console-producer.sh --broker-list $BS --producer.config client.properties --topic msk-serverless-tutorial
# Read messageskafka_2.12-2.8.1/bin/kafka-console-consumer.sh --bootstrap-server $BS --consumer.config client.properties --topic msk-serverless-tutorial --from-beginning