diff --git a/kafka/Kafka.sh b/kafka/Kafka.sh index 3e2a63f..d290259 100644 --- a/kafka/Kafka.sh +++ b/kafka/Kafka.sh @@ -4,6 +4,7 @@ ##email: ppabc@qq.com ##robert yu ##centos 6 +##kafka 单独ZooKeeper 搭建 yum install -y curl openssh-server openssh-clients postfix cronie git nmap unzip wget lsof xz gcc make vim curl gcc-c++ libtool @@ -40,7 +41,7 @@ zookeeper.connect=master.storm.com:2181/kafka zookeeper.connection.timeout.ms=6000 EOF -cat >>/opt/zk/conf/zoo.cfg</opt/zk/conf/zoo.cfg<>/etc/hosts<>/etc/profile</opt/kafka_2.10-0.9.0.1/config/server.properties</opt/kafka_2.10-0.9.0.1/config/zookeeper.properties</opt/confluent-2.0.1/etc/schema-registry/schema-registry.properties</opt/confluent-2.0.1/etc/kafka-rest/kafka-rest.properties</dev/null 2>&1 & + +/opt/kafka_2.10-0.9.0.1/bin/kafka-server-start.sh /opt/kafka_2.10-0.9.0.1/config/server.properties >/dev/null 2>&1 & + +##bin/zookeeper-server-start.sh config/zookeeper.properties >/dev/null 2>&1 & +##bin/kafka-server-start.sh config/server.properties >/dev/null 2>&1 & + +##停止命令 +##ps ax | grep -i 'kafka.Kafka' | grep -v grep | awk '{print $1}' | xargs kill + +##查看创建的Topic,执行如下命令: +bin/kafka-topics.sh --create --zookeeper 192.168.142.136:2181 --replication-factor 1 --partitions 1 --topic mykafka +##bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test + +##列出所有主题 +bin/kafka-topics.sh --list --zookeeper 192.168.142.136:2181 + +##在一个终端,启动Producer,执行如下命令: +bin/kafka-console-producer.sh --broker-list 192.168.142.136:9092 --topic mykafka +##bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test + +##在另一个终端,启动Consumer,执行如下命令: +bin/kafka-console-consumer.sh --zookeeper 192.168.142.136:2181 --topic mykafka --from-beginning +##bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning + +#######confluent启动 +cd /opt/confluent-2.0.1/ +bin/schema-registry-start etc/schema-registry/schema-registry.properties >/dev/null 2>&1 & +##停止命令 +##ps ax | grep -i 'schema-registry' | grep -v grep | awk '{print $1}' | xargs kill + +cd /opt/confluent-2.0.1/ +bin/kafka-rest-start etc/kafka-rest/kafka-rest.properties >/dev/null 2>&1 & +##停止命令 +##ps ax | grep -i 'kafka-rest' | grep -v grep | awk '{print $1}' | xargs kill +