tar -zxvf kafka_2.11-0.11.0.2.tgz -C /app/svr/
ln -s /app/svr/kafka_2.11-0.11.0.2/ /app/svr/kafka
cd /app/svr/kafka
vi config/server.properties
listeners=SASL_PLAINTEXT://0.0.0.0:9092
advertised.listeners=SASL_PLAINTEXT://cent1.steven:9092
log.dirs=/app/data/kafka-logs
auto.create.topics.enable=false
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.enabled.mechanisms=PLAIN
sasl.mechanism.inter.broker.protocol=PLAIN
authorizer.class.name = kafka.security.auth.SimpleAclAuthorizer
super.users=User:kafka
- vi config/zookeeper.properties
dataDir=/app/data/zookeeper
authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
maxClientCnxns=100
tickTime=2000
initLimit=10
syncLimit=5
- vi config/kafka_server_jaas.conf
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="kafka"
password="kafka-changeme"
user_kafka="kafka-changeme"
user_alice="alice-changeme"
user_bob="bob-changeme";
};
Client {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="kafka"
password="kafka-changeme;
};
- vi config/kafka_zoo_jaas.conf
Server {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="kafka"
password="kafka-changeme"
user_kafka="kafka-changeme";
};
- vi config/kafka_client_jaas.conf
KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="alice"
password="alice-changeme";
};
- vi config/producer.properties
security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN
- vi config/consumer.properties
security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN
- vi bin/kafka-server-start.sh export KAFKA_OPTS before exec command
export KAFKA_OPTS=" -Djava.security.auth.login.config=/app/svr/kafka/config/kafka_server_jaas.conf"
- vi bin/zookeeper-server-start.sh export KAFKA_OPTS before exec command
export KAFKA_OPTS=" -Djava.security.auth.login.config=/app/svr/kafka/config/kafka_zoo_jaas.conf"
- vi bin/kafka-console-consumer.sh & bin/kafka-console-producer.sh export KAFKA_OPTS before exec command
export KAFKA_OPTS=" -Djava.security.auth.login.config=/app/svr/kafka/config/kafka_client_jaas.conf"
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
bin/kafka-server-start.sh -daemon config/server.properties
=======================================================
- bin/kafka-topics.sh --create --topic test --zookeeper cent1.steven:2181 --partitions 3 --replication-factor 1
- bin/kafka-topics.sh --list --zookeeper cent1.steven:2181
- vi config/kafka_admin_jaas.conf
Client {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="kafka"
password="kafka-changeme";
};
- vi bin/kafka-acls.sh export KAFKA_OPTS before exec command
export KAFKA_OPTS=" -Djava.security.auth.login.config=/app/svr/kafka/config/kafka_admin_jaas.conf"
- bin/kafka-acls.sh --authorizer-properties zookeeper.connect=cent1.steven:2181 --add --allow-principal User:* --allow-host=* --operation All --topic test --group=*
- bin/kafka-acls.sh --authorizer-properties zookeeper.connect=cent1.steven:2181 --list --topic test
- bin/kafka-console-producer.sh --topic test --broker-list cent1.steven:9092 --producer.config config/producer.properties
- bin/kafka-console-consumer.sh --new-consumer --topic test --bootstrap-server cent1.steven:9092 --consumer.config config/consumer.properties