brew install kafka

安装会依赖zookeeper。
看到如下结果,就可以说是安装成功了。

lidongdeMacBook-Pro:~ lidong$ brew install kafka
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core, pivotal/tap).
==> New Formulae
bluepill                   gobuster                   prest
buildifier                 grunt                      sha1dc
crowdin                    gtef                       shellshare
dhall-json                 libcds                     spigot
dmtx-utils                 librealsense               teleport
docker-credential-helper   libtensorflow              uniutils
dvd-vr                     monitoring-plugins         urh
gandi.cli                  mysql-utilities            woboq_codebrowser
go@1.7                     pqiv
==> Updated Formulae
kops                                     wakatime-cli
kotlin                                   wesnoth
kubernetes-cli                           winetricks
kubernetes-helm                          wireguard-tools
ldc                                      wireshark
leveldb                                  x265
lftp                                     xmake
libarchive                               xonsh
libav                                    yarn
libbluray                                yle-dl
libchamplain                             youtube-dl
libcouchbase                             zimg
libdvbpsi                                znc
libepoxy                                 zsh-history-substring-search
libfabric
==> Renamed Formulae
bash-completion2 -> bash-completion@2
bazel02 -> bazel@0.2
bigdata -> blazegraph
bison27 -> bison@2.7
boost-python159 -> boost-python@1.59
cassandra21 -> cassandra@2.1
cassandra22 -> cassandra@2.2
clang-format38 -> clang-format@3.8
docker111 -> docker@1.11
docker171 -> docker@1.71
erlang-r18 -> erlang@18
ffmpeg28 -> ffmpeg@2.8
freetds091 -> freetds@0.91
giflib5 -> giflib@5
glfw2 -> glfw@2
gnupg21 -> gnupg@2.1
gnuplot4 -> gnuplot@4
go14 -> go@1.4
go15 -> go@1.5
go16 -> go@1.6
gradle214 -> gradle@2.14
grails25 -> grails@2.5
gsl1 -> gsl@1
gst-ffmpeg010 -> gst-ffmpeg@0.10
gst-plugins-bad010 -> gst-plugins-bad@0.10
gst-plugins-base010 -> gst-plugins-base@0.10
gst-plugins-good010 -> gst-plugins-good@0.10
gst-plugins-ugly010 -> gst-plugins-ugly@0.10
gstreamer010 -> gstreamer@0.10
mariadb100 -> mariadb@10.0
postgresql94 -> postgresql@9.4
postgresql95 -> postgresql@9.5
rebar3 -> rebar@3
recipes -> gnome-recipes
redis26 -> redis@2.6
redis28 -> redis@2.8
ruby187 -> ruby@1.8
ruby193 -> ruby@1.9
ruby20 -> ruby@2.0
ruby21 -> ruby@2.1
ruby22 -> ruby@2.2
ruby23 -> ruby@2.3
==> Deleted Formulae
ctorrent            libgroove           s3sync              silc-client
ee                  node@5              scsh                xstow
==> Installing dependencies for kafka: zookeeper
==> Installing kafka dependency: zookeeper
==> Downloading https://homebrew.bintray.com/bottles/zookeeper-3.4.9.sierra.bott
######################################################################## 100.0%
==> Pouring zookeeper-3.4.9.sierra.bottle.tar.gz
==> Caveats
To have launchd start zookeeper now and restart at login:
  brew services start zookeeper
Or, if you don't want/need a background service you can just run:
  zkServer start
==> Summary
��  /usr/local/Cellar/zookeeper/3.4.9: 238 files, 18.2MB
==> Installing kafka 
==> Downloading https://homebrew.bintray.com/bottles/kafka-0.10.2.0.sierra.bottl
######################################################################## 100.0%
==> Pouring kafka-0.10.2.0.sierra.bottle.tar.gz
==> Caveats
To have launchd start kafka now and restart at login:
  brew services start kafka
Or, if you don't want/need a background service you can just run:
  zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties & kafka-server-start /usr/local/etc/kafka/server.properties
==> Summary
��  /usr/local/Cellar/kafka/0.10.2.0: 132 files, 37.2MB
lidongdeMacBook-Pro:~ lidong$ 

注意:安装目录:/usr/local/Cellar/kafka/0.10.2.0

2.安装的配置文件位置

/usr/local/etc/kafka/server.properties
/usr/local/etc/kafka/zookeeper.properties

3. 启动zookeeper

lidongdeMacBook-Pro:0.10.2.0 lidong$ ./bin/zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties &
[1] 4436
lidongdeMacBook-Pro:0.10.2.0 lidong$ [2017-03-15 14:11:38,682] INFO Reading configuration from: /usr/local/etc/kafka/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2017-03-15 14:11:38,685] INFO autopurge.snapRetainCount set to 3 (org.apache.zookeeper.server.DatadirCleanupManager)
[2017-03-15 14:11:38,685] INFO autopurge.purgeInterval set to 0 (org.apache.zookeeper.server.DatadirCleanupManager)
[2017-03-15 14:11:38,685] INFO Purge task is not scheduled. (org.apache.zookeeper.server.DatadirCleanupManager)
[2017-03-15 14:11:38,685] WARN Either no config or no quorum defined in config, running  in standalone mode (org.apache.zookeeper.server.quorum.QuorumPeerMain)
[2017-03-15 14:11:38,708] INFO Reading configuration from: /usr/local/etc/kafka/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2017-03-15 14:11:38,708] INFO Starting server (org.apache.zookeeper.server.ZooKeeperServerMain)
[2017-03-15 14:11:38,728] INFO Server environment:zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,728] INFO Server environment:host.name=192.168.1.130 (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,728] INFO Server environment:java.version=1.8.0_92 (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,728] INFO Server environment:java.vendor=Oracle Corporation (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,728] INFO Server environment:java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,728] INFO Server environment:java.class.path=:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/aopalliance-repackaged-2.5.0-b05.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/argparse4j-0.7.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/connect-api-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/connect-file-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/connect-json-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/connect-runtime-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/connect-transforms-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/guava-18.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/hk2-api-2.5.0-b05.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/hk2-locator-2.5.0-b05.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/hk2-utils-2.5.0-b05.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-annotations-2.8.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-annotations-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-core-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-databind-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-jaxrs-base-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-jaxrs-json-provider-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-module-jaxb-annotations-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javassist-3.20.0-GA.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javax.annotation-api-1.2.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javax.inject-1.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javax.inject-2.5.0-b05.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javax.servlet-api-3.1.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javax.ws.rs-api-2.0.1.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-client-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-common-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-container-servlet-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-container-servlet-core-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-guava-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-media-jaxb-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-server-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-continuation-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-http-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-io-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-security-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-server-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-servlet-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-servlets-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-util-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jopt-simple-5.0.3.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka-clients-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka-log4j-appender-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka-streams-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka-streams-examples-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka-tools-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka_2.11-0.10.2.0-sources.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka_2.11-0.10.2.0-test-sources.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka_2.11-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/log4j-1.2.17.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/lz4-1.3.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/metrics-core-2.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/osgi-resource-locator-1.0.1.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/reflections-0.9.10.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/rocksdbjni-5.0.1.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/scala-library-2.11.8.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/scala-parser-combinators_2.11-1.0.4.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/slf4j-api-1.7.21.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/slf4j-log4j12-1.7.21.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/snappy-java-1.1.2.6.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/validation-api-1.1.0.Final.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/zkclient-0.10.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/zookeeper-3.4.9.jar (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,729] INFO Server environment:java.library.path=/Users/lidong/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,729] INFO Server environment:java.io.tmpdir=/var/folders/vl/zhy0vf8141vb8y5f6yx0dgrr0000gn/T/ (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,729] INFO Server environment:java.compiler=<NA> (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,729] INFO Server environment:os.name=Mac OS X (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,729] INFO Server environment:os.arch=x86_64 (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,729] INFO Server environment:os.version=10.12.3 (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,729] INFO Server environment:user.name=lidong (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,729] INFO Server environment:user.home=/Users/lidong (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,729] INFO Server environment:user.dir=/usr/local/Cellar/kafka/0.10.2.0 (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,743] INFO tickTime set to 3000 (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,743] INFO minSessionTimeout set to -1 (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,743] INFO maxSessionTimeout set to -1 (org.apache.zookeeper.server.ZooKeeperServer)
[2017-03-15 14:11:38,769] INFO binding to port 0.0.0.0/0.0.0.0:2181 (org.apache.zookeeper.server.NIOServerCnxnFactory)

4.启动 kafka 服务

lidongdeMacBook-Pro:~ lidong$ cd /usr/local/Cellar/kafka/0.10.2.0
lidongdeMacBook-Pro:0.10.2.0 lidong$ ./bin/kafka-server-start /usr/local/etc/kafka/server.properties &
[1] 4751
lidongdeMacBook-Pro:0.10.2.0 lidong$ [2017-03-15 14:13:36,327] INFO KafkaConfig values: 
    advertised.host.name = null
    advertised.listeners = null
    advertised.port = null
    authorizer.class.name = 
    auto.create.topics.enable = true
    auto.leader.rebalance.enable = true
    background.threads = 10
    broker.id = 0
    broker.id.generation.enable = true
    broker.rack = null
    compression.type = producer
    connections.max.idle.ms = 600000
    controlled.shutdown.enable = true
    controlled.shutdown.max.retries = 3
    controlled.shutdown.retry.backoff.ms = 5000
    controller.socket.timeout.ms = 30000
    create.topic.policy.class.name = null
    default.replication.factor = 1
    delete.topic.enable = false
    fetch.purgatory.purge.interval.requests = 1000
    group.max.session.timeout.ms = 300000
    group.min.session.timeout.ms = 6000
    host.name = 
    inter.broker.listener.name = null
    inter.broker.protocol.version = 0.10.2-IV0
    leader.imbalance.check.interval.seconds = 300
    leader.imbalance.per.broker.percentage = 10
    listener.security.protocol.map = SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,TRACE:TRACE,SASL_SSL:SASL_SSL,PLAINTEXT:PLAINTEXT
    listeners = null
    log.cleaner.backoff.ms = 15000
    log.cleaner.dedupe.buffer.size = 134217728
    log.cleaner.delete.retention.ms = 86400000
    log.cleaner.enable = true
    log.cleaner.io.buffer.load.factor = 0.9
    log.cleaner.io.buffer.size = 524288
    log.cleaner.io.max.bytes.per.second = 1.7976931348623157E308
    log.cleaner.min.cleanable.ratio = 0.5
    log.cleaner.min.compaction.lag.ms = 0
    log.cleaner.threads = 1
    log.cleanup.policy = [delete]
    log.dir = /tmp/kafka-logs
    log.dirs = /usr/local/var/lib/kafka-logs
    log.flush.interval.messages = 9223372036854775807
    log.flush.interval.ms = null
    log.flush.offset.checkpoint.interval.ms = 60000
    log.flush.scheduler.interval.ms = 9223372036854775807
    log.index.interval.bytes = 4096
    log.index.size.max.bytes = 10485760
    log.message.format.version = 0.10.2-IV0
    log.message.timestamp.difference.max.ms = 9223372036854775807
    log.message.timestamp.type = CreateTime
    log.preallocate = false
    log.retention.bytes = -1
    log.retention.check.interval.ms = 300000
    log.retention.hours = 168
    log.retention.minutes = null
    log.retention.ms = null
    log.roll.hours = 168
    log.roll.jitter.hours = 0
    log.roll.jitter.ms = null
    log.roll.ms = null
    log.segment.bytes = 1073741824
    log.segment.delete.delay.ms = 60000
    max.connections.per.ip = 2147483647
    max.connections.per.ip.overrides = 
    message.max.bytes = 1000012
    metric.reporters = []
    metrics.num.samples = 2
    metrics.recording.level = INFO
    metrics.sample.window.ms = 30000
    min.insync.replicas = 1
    num.io.threads = 8
    num.network.threads = 3
    num.partitions = 1
    num.recovery.threads.per.data.dir = 1
    num.replica.fetchers = 1
    offset.metadata.max.bytes = 4096
    offsets.commit.required.acks = -1
    offsets.commit.timeout.ms = 5000
    offsets.load.buffer.size = 5242880
    offsets.retention.check.interval.ms = 600000
    offsets.retention.minutes = 1440
    offsets.topic.compression.codec = 0
    offsets.topic.num.partitions = 50
    offsets.topic.replication.factor = 3
    offsets.topic.segment.bytes = 104857600
    port = 9092
    principal.builder.class = class org.apache.kafka.common.security.auth.DefaultPrincipalBuilder
    producer.purgatory.purge.interval.requests = 1000
    queued.max.requests = 500
    quota.consumer.default = 9223372036854775807
    quota.producer.default = 9223372036854775807
    quota.window.num = 11
    quota.window.size.seconds = 1
    replica.fetch.backoff.ms = 1000
    replica.fetch.max.bytes = 1048576
    replica.fetch.min.bytes = 1
    replica.fetch.response.max.bytes = 10485760
    replica.fetch.wait.max.ms = 500
    replica.high.watermark.checkpoint.interval.ms = 5000
    replica.lag.time.max.ms = 10000
    replica.socket.receive.buffer.bytes = 65536
    replica.socket.timeout.ms = 30000
    replication.quota.window.num = 11
    replication.quota.window.size.seconds = 1
    request.timeout.ms = 30000
    reserved.broker.max.id = 1000
    sasl.enabled.mechanisms = [GSSAPI]
    sasl.kerberos.kinit.cmd = /usr/bin/kinit
    sasl.kerberos.min.time.before.relogin = 60000
    sasl.kerberos.principal.to.local.rules = [DEFAULT]
    sasl.kerberos.service.name = null
    sasl.kerberos.ticket.renew.jitter = 0.05
    sasl.kerberos.ticket.renew.window.factor = 0.8
    sasl.mechanism.inter.broker.protocol = GSSAPI
    security.inter.broker.protocol = PLAINTEXT
    socket.receive.buffer.bytes = 102400
    socket.request.max.bytes = 104857600
    socket.send.buffer.bytes = 102400
    ssl.cipher.suites = null
    ssl.client.auth = none
    ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
    ssl.endpoint.identification.algorithm = null
    ssl.key.password = null
    ssl.keymanager.algorithm = SunX509
    ssl.keystore.location = null
    ssl.keystore.password = null
    ssl.keystore.type = JKS
    ssl.protocol = TLS
    ssl.provider = null
    ssl.secure.random.implementation = null
    ssl.trustmanager.algorithm = PKIX
    ssl.truststore.location = null
    ssl.truststore.password = null
    ssl.truststore.type = JKS
    unclean.leader.election.enable = true
    zookeeper.connect = localhost:2181
    zookeeper.connection.timeout.ms = 6000
    zookeeper.session.timeout.ms = 6000
    zookeeper.set.acl = false
    zookeeper.sync.time.ms = 2000
 (kafka.server.KafkaConfig)
[2017-03-15 14:13:36,390] INFO starting (kafka.server.KafkaServer)
[2017-03-15 14:13:36,393] INFO Connecting to zookeeper on localhost:2181 (kafka.server.KafkaServer)
[2017-03-15 14:13:36,409] INFO Starting ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2017-03-15 14:13:36,417] INFO Client environment:zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:host.name=192.168.1.130 (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:java.version=1.8.0_92 (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:java.vendor=Oracle Corporation (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:java.class.path=:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/aopalliance-repackaged-2.5.0-b05.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/argparse4j-0.7.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/connect-api-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/connect-file-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/connect-json-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/connect-runtime-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/connect-transforms-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/guava-18.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/hk2-api-2.5.0-b05.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/hk2-locator-2.5.0-b05.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/hk2-utils-2.5.0-b05.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-annotations-2.8.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-annotations-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-core-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-databind-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-jaxrs-base-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-jaxrs-json-provider-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jackson-module-jaxb-annotations-2.8.5.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javassist-3.20.0-GA.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javax.annotation-api-1.2.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javax.inject-1.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javax.inject-2.5.0-b05.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javax.servlet-api-3.1.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/javax.ws.rs-api-2.0.1.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-client-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-common-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-container-servlet-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-container-servlet-core-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-guava-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-media-jaxb-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jersey-server-2.24.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-continuation-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-http-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-io-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-security-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-server-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-servlet-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-servlets-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jetty-util-9.2.15.v20160210.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/jopt-simple-5.0.3.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka-clients-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka-log4j-appender-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka-streams-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka-streams-examples-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka-tools-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka_2.11-0.10.2.0-sources.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka_2.11-0.10.2.0-test-sources.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/kafka_2.11-0.10.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/log4j-1.2.17.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/lz4-1.3.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/metrics-core-2.2.0.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/osgi-resource-locator-1.0.1.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/reflections-0.9.10.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/rocksdbjni-5.0.1.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/scala-library-2.11.8.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/scala-parser-combinators_2.11-1.0.4.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/slf4j-api-1.7.21.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/slf4j-log4j12-1.7.21.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/snappy-java-1.1.2.6.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/validation-api-1.1.0.Final.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/zkclient-0.10.jar:/usr/local/Cellar/kafka/0.10.2.0/libexec/bin/../libs/zookeeper-3.4.9.jar (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:java.library.path=/Users/lidong/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:java.io.tmpdir=/var/folders/vl/zhy0vf8141vb8y5f6yx0dgrr0000gn/T/ (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:os.name=Mac OS X (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:os.arch=x86_64 (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:os.version=10.12.3 (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:user.name=lidong (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:user.home=/Users/lidong (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,418] INFO Client environment:user.dir=/usr/local/Cellar/kafka/0.10.2.0 (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,419] INFO Initiating client connection, connectString=localhost:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@1139b2f3 (org.apache.zookeeper.ZooKeeper)
[2017-03-15 14:13:36,437] INFO Waiting for keeper state SyncConnected (org.I0Itec.zkclient.ZkClient)
[2017-03-15 14:13:36,441] INFO Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2017-03-15 14:13:36,506] INFO Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2017-03-15 14:13:36,593] INFO Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x15ad097e0a90000, negotiated timeout = 6000 (org.apache.zookeeper.ClientCnxn)
[2017-03-15 14:13:36,595] INFO zookeeper state changed (SyncConnected) (org.I0Itec.zkclient.ZkClient)
[2017-03-15 14:13:36,702] INFO Cluster ID = hgqzqaTdSI-KIydvLD0TQw (kafka.server.KafkaServer)
[2017-03-15 14:13:36,705] WARN No meta.properties file under dir /usr/local/var/lib/kafka-logs/meta.properties (kafka.server.BrokerMetadataCheckpoint)
[2017-03-15 14:13:36,747] INFO [ThrottledRequestReaper-Fetch], Starting  (kafka.server.ClientQuotaManager$ThrottledRequestReaper)
[2017-03-15 14:13:36,748] INFO [ThrottledRequestReaper-Produce], Starting  (kafka.server.ClientQuotaManager$ThrottledRequestReaper)
[2017-03-15 14:13:36,781] INFO Log directory '/usr/local/var/lib/kafka-logs' not found, creating it. (kafka.log.LogManager)
[2017-03-15 14:13:36,796] INFO Loading logs. (kafka.log.LogManager)
[2017-03-15 14:13:36,802] INFO Logs loading complete in 6 ms. (kafka.log.LogManager)
[2017-03-15 14:13:36,915] INFO Starting log cleanup with a period of 300000 ms. (kafka.log.LogManager)
[2017-03-15 14:13:36,917] INFO Starting log flusher with a default period of 9223372036854775807 ms. (kafka.log.LogManager)
[2017-03-15 14:13:36,965] INFO Awaiting socket connections on 0.0.0.0:9092. (kafka.network.Acceptor)
[2017-03-15 14:13:36,968] INFO [Socket Server on Broker 0], Started 1 acceptor threads (kafka.network.SocketServer)
[2017-03-15 14:13:36,990] INFO [ExpirationReaper-0], Starting  (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-03-15 14:13:36,991] INFO [ExpirationReaper-0], Starting  (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-03-15 14:13:37,034] INFO Creating /controller (is it secure? false) (kafka.utils.ZKCheckedEphemeral)
[2017-03-15 14:13:37,040] INFO Result of znode creation is: OK (kafka.utils.ZKCheckedEphemeral)
[2017-03-15 14:13:37,040] INFO 0 successfully elected as leader (kafka.server.ZookeeperLeaderElector)
[2017-03-15 14:13:37,139] INFO [ExpirationReaper-0], Starting  (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-03-15 14:13:37,143] INFO [ExpirationReaper-0], Starting  (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-03-15 14:13:37,145] INFO [ExpirationReaper-0], Starting  (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2017-03-15 14:13:37,158] INFO [GroupCoordinator 0]: Starting up. (kafka.coordinator.GroupCoordinator)
[2017-03-15 14:13:37,159] INFO [GroupCoordinator 0]: Startup complete. (kafka.coordinator.GroupCoordinator)
[2017-03-15 14:13:37,161] INFO [Group Metadata Manager on Broker 0]: Removed 0 expired offsets in 2 milliseconds. (kafka.coordinator.GroupMetadataManager)
[2017-03-15 14:13:37,187] INFO Will not load MX4J, mx4j-tools.jar is not in the classpath (kafka.utils.Mx4jLoader$)
[2017-03-15 14:13:37,218] INFO Creating /brokers/ids/0 (is it secure? false) (kafka.utils.ZKCheckedEphemeral)
[2017-03-15 14:13:37,225] INFO Result of znode creation is: OK (kafka.utils.ZKCheckedEphemeral)
[2017-03-15 14:13:37,227] INFO Registered broker 0 at path /brokers/ids/0 with addresses: EndPoint(192.168.1.130,9092,ListenerName(PLAINTEXT),PLAINTEXT) (kafka.utils.ZkUtils)
[2017-03-15 14:13:37,229] WARN No meta.properties file under dir /usr/local/var/lib/kafka-logs/meta.properties (kafka.server.BrokerMetadataCheckpoint)
[2017-03-15 14:13:37,236] INFO New leader is 0 (kafka.server.ZookeeperLeaderElector$LeaderChangeListener)
[2017-03-15 14:13:37,259] INFO Kafka version : 0.10.2.0 (org.apache.kafka.common.utils.AppInfoParser)
[2017-03-15 14:13:37,259] INFO Kafka commitId : 576d93a8dc0cf421 (org.apache.kafka.common.utils.AppInfoParser)
[2017-03-15 14:13:37,260] INFO [Kafka Server 0], started (kafka.server.KafkaServer)

5.创建topic

让我们使用单个分区和只有一个副本创建一个名为“test”的主题

./bin/kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
Created topic "test".

6.查看创建的topic

我们现在可以看到该主题,如果我们运行list topic命令:

./bin/kafka-topics --list --zookeeper localhost:2181

7.发送一些消息

Kafka提供了一个命令行客户端,它将从文件或标准输入接收输入,并将其作为消息发送到Kafka集群。默认情况下,每行都将作为单独的消息发送。

运行生产者,然后在控制台中键入一些消息发送到服务器。

> bin / kafka-console-producer.sh --broker-list localhost:9092 --topic test 
第一条消息
第二条消息

8.消费消息

Kafka还有一个命令行消费者,将消息转储到标准输出。

./bin/kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginning
第一条消息
第二条消息

如果你有上面的每个命令运行在不同的终端,那么你现在应该能够输入消息到生产者终端,看到他们出现在消费者终端。

所有命令行工具都有其他选项; 运行没有参数的命令将显示详细记录它们的使用信息。

kafka安装brew install kafka安装会依赖zookeeper。 看到如下结果,就可以说是安装成功了。lidongdeMacBook-Pro:~ lidong$ brew install kafkaUpdating Homebrew...==> Auto-updated Homebrew!Updated 2 taps (homebrew/core, pivotal/tap). $KAFKA_HOME/config/server.properties文件中的配置 zookeeper.connect 该参数用于配置Kafka要连接的Zookeeper/集群的地址。 它的值是一个字符串,使用逗号分隔Zookeeper的多个地址。Zookeeper的单个地址是 host:port 形式的,可以在最后添加Kafka在Zookeeper中的根节点路径 zookeeper.connect=node2:2181,node3:2181,node4:2181/myKafka read-only:需要重新启动broker进行更新。 per-broker:可以为每个broker动态更新。 cluster-wide:可以作为集群范围的默认值动态更新,也可以为测试更新为每个broker的值。 下面分别看下服务器节点的配置: 1.zookeeper.co... Last login: Fri Aug 11 08:57:04 on console helendeMacBook-Pro:~ helen$ brew install kafka Updating Homebrew... C==> Installing dependencies for kafka: zookeeper ==> Installing kafka depe
场景说明:当客户端与服务端在不同区域(跨防火墙,地址均做了映射)时,客户端访问kafka时会出现获取不到broker的问题,但是网络之间是互通的。但在跨防火墙下,client请求zookeeper的时候,zookeeper返回给client的broker IP是kafka的实际地址,而不是映射地址,因此client会访问失败。 解决方式一、1、配置文件:listeners=PLAINTEXT://...
打算做kafka的SASL_SSL权限 listeners=SASL_SSL://localhost:9093,PLAINTEXT://localhost:9092 advertised.listeners=SASL_SSL://localhost:9093,PLAINTEXT://localhost:9092 sasl.enabled.mechanisms=PLAIN sasl.mechanism.inter.broker.protocol=PLAIN security.inter.broke 2.1 在mac电脑上可以直接使用 brew install kafka来进行安装 如果安装出现Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!错误,那么使用下面解决方法: 打开Finder-> 打开应用程序->打开实用工具 找到终端.app,显示简介,把使用 Rosetta打开勾选上,然后重启终端,再运行brew install . sharding-sphere整合seata AT模式方案,本意是解决sharding分库带来的事务问题,而不是用在跨微服务的事务问题上面。 对于跨微服务的分布式事务,我的实践方案是sharding分表的事务也由seata管理。在用到sharding的微服务,配置ShardingDataSource不被seata代理即可,seata只代理个分库的物理数据源 excludes-for-auto-proxying: org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingDataSource mysql设置update时间字段自动更新 weixin_47491231: twsxxn CentOS7.4 上安装 zookeeper-3.4.14 服务 weixin_57234234: 3.5.5以上需下载 "apache-zookeeper-3.x.x-bin.tar.gz"的版本。