查詢下載最新版本 kafka
http://kafka.apache.org/downloads.html
wget http://mirror.bit.edu.cn/apache/kafka/0.8.2.0/kafka-0.8.2.0-src.tgz
tar zxvf kafka-0.8.2.0-src.tgz
mv kafka-0.8.2.0-src /opt/local/kafka
cd /opt/local/kafka
./gradlew jar
------------------------------------------------------------------------------
提示:
錯誤: 找不到或無法載入主類 org.gradle.wrapper.GradleWrapperMain
需要先安裝 gradle
scala 下載地址
http://www.scala-lang.org/files/archive/scala-2.10.4.tgz
tar zxvf scala-2.10.4.tgz
mv scala-2.10.4 /usr/lib64/scala
設定環境變數
vi /etc/profile
export SACLA_HOME=/usr/lib64/scala/
export PATH=$SACLA_HOME/bin:$PATH
etc/profile
-------------------------------------------------------------------------------
執行 gradlew jar 會下載很多響應的東西
./gradlew jarAll
----------------------------------------------------------------------
jarAll 會報錯,java 版本不能為1.8 不然會報不相容的錯誤,請使用1.7版本
-----------------------------------------------------------------------
./gradlew jar --stacktrace --info --debug
建立日誌目錄
mkdir -p /opt/local/kafka/logs
下面 編輯配置檔案
vim config/server.properties
將裡面的:log.dirs=/tmp/kafka-logs
zookeeper.connect=localhost:2181
改為你自己的:log.dirs=/opt/local/kafka/logs
zookeeper.connect=172.24.0.100:2181
儲存退出
啟動:
nohup /opt/local/kafka/bin/zookeeper-server-start.sh /opt/local/kafka/config/zookeeper.properties &
nohup /opt/local/kafka/bin/kafka-server-start.sh /opt/local/kafka/config/server.properties &
建立主題:
/opt/local/kafka/bin/kafka-topics.sh --create --zookeeper 192.168.20.200:2181 --replication-factor 1 --partitions 1 --topic LJ200
檢視現有主題:
/opt/local/kafka/bin/kafka-topics.sh --list --zookeeper 192.168.20.200:2181
LJ200