我在本地用如下的配置启动了 kafka
listeners=SASL_PLAINTEXT://localhost:9092
# Listener name, hostname and port the broker will advertise to clients.
# If not set, it uses the value for "listeners".
advertised.listeners=SASL_PLAINTEXT://localhost:9092
# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
listener.security.protocol.map=SASL_PLAINTEXT:SASL_PLAINTEXT
inter.broker.listener.name=SASL_PLAINTEXT
sasl.mechanism.inter.broker.protocol=SCRAM-SHA-256
sasl.enabled.mechanisms=SCRAM-SHA-256
# SASL 认证机制指定为 SCRAM-SHA-256
sasl.mechanism=SCRAM-SHA-256
listener.name.sasl_plaintext.scram-sha-256.sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="dongmen" password="123456";
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="dongmen" password="123456";
然后创建了对应的用户
/bin/kafka-configs.sh --zookeeper localhost:2181 --alter --add-config 'SCRAM-SHA-256=[password=123456]' --entity-type users --entity-name dongmen
最后创建 changefeed ,是没问题的
./cdc cli changefeed create --changefeed-id="simple" --sink-uri="kafka://localhost:9092/test?protocol=canal-json&max-message-bytes=1024000&sasl-user=dongmen&sasl-password=123456&sasl-mechanism=SCRAM-SHA-256"
Create changefeed successfully!
ID: simple
Info: {"upstream_id":7539819806387426539,"namespace":"default","id":"simple","sink_uri":"kafka://localhost:9092/test?max-message-bytes=1024000\u0026protocol=canal-json\u0026sasl-mechanism=SCRAM-SHA-256\u0026sasl-password=xxxxx\u0026sasl-user=dongmen","create_time":"2025-08-18T16:33:39.963647+08:00","start_ts":460195370028761089,"config":{"memory_quota":1073741824,"case_sensitive":false,"force_replicate":false,"ignore_ineligible_table":false,"check_gc_safe_point":true,"enable_sync_point":false,"enable_table_monitor":false,"bdr_mode":false,"sync_point_interval":600000000000,"sync_point_retention":86400000000000,"filter":{"rules":["*.*"]},"mounter":{"worker_num":16},"sink":{"protocol":"canal-json","csv":{"delimiter":",","quote":"\"","null":"\\N","include_commit_ts":false,"binary_encoding_method":"base64","output_old_value":false,"output_handle_key":false,"output_field_header":false},"encoder_concurrency":32,"terminator":"\r\n","date_separator":"day","enable_partition_separator":true,"enable_kafka_sink_v2":false,"only_output_updated_columns":false,"delete_only_output_handle_key_columns":false,"content_compatible":false,"advance_timeout":150,"send_bootstrap_interval_in_sec":120,"send_bootstrap_in_msg_count":10000,"send_bootstrap_to_all_partition":true,"send-all-bootstrap-at-start":false,"debezium_disable_schema":false,"debezium":{"output_old_value":true},"open":{"output_old_value":true}},"consistent":{"level":"none","max_log_size":64,"flush_interval":2000,"meta_flush_interval":200,"encoding_worker_num":16,"flush_worker_num":8,"use_file_backend":false,"memory_usage":{"memory_quota_percentage":50}},"scheduler":{"enable_table_across_nodes":false,"region_threshold":100000,"write_key_threshold":0},"integrity":{"integrity_check_level":"none","corruption_handle_level":"warn"},"changefeed_error_stuck_duration":1800000000000,"synced_status":{"synced_check_interval":300,"checkpoint_interval":15}},"state":"normal","creator_version":"v9.0.0-beta.2.pre-17-g78b4f3b54","resolved_ts":460195370028761089,"checkpoint_ts":460195370028761089,"checkpoint_time":"2025-08-18 16:33:39.702"}