免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

Centos6.5下kafka如何部署安裝

小編給大家分享一下Centos6.5下kafka如何部署安裝,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

成都網(wǎng)絡(luò)公司-成都網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)十多年經(jīng)驗(yàn)成就非凡,專業(yè)從事成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站,成都網(wǎng)頁(yè)設(shè)計(jì),成都網(wǎng)頁(yè)制作,軟文發(fā)稿廣告投放平臺(tái)等。十多年來(lái)已成功提供全面的成都網(wǎng)站建設(shè)方案,打造行業(yè)特色的成都網(wǎng)站建設(shè)案例,建站熱線:13518219792,我們期待您的來(lái)電!

一)安裝JDK

步驟1:新建路徑/usr/Java, 并在其下解壓 jdk-7u71-linux-x64.tar.gz

# mkdir -p /usr/java

# tar -zxvf jdk-7u71-linux-x64.tar.gz

步驟2:添加JDK到系統(tǒng)環(huán)境變量

# vi /etc/profile

新增以下內(nèi)容:

export JAVA_HOME=/usr/java/jdk1.7.0_71

export PATH=$JAVA_HOME/bin:$PATH

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

步驟3:使配置生效

source /etc/profile #使配置文件立即生效

# java -version       //JDK版本java version "1.7.0_79" 也可以,目前JDK1.8版本不支持;

Java version "1.7.0_71"

Java(TM) SE Runtime Environment (build 1.7.0_71-b14)

Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

二)安裝zookeeper

步驟1:解壓zookeeper安裝包(路徑無(wú)關(guān),安裝路徑可以自定義)

# tar -zxvf zookeeper-3.3.6.tar.gz

步驟2:配置環(huán)境變量

# vim /etc/profile 

export zookeeper_home=/home/laoyang/zookeeper

#source /etc/profile

# sh $zookeeper_home/bin/zkServer.sh start

JMX enabled by default

Using config: /home/laoyang/zookeeper/bin/../conf/zoo.cfg

grep: /home/laoyang/zookeeper/bin/../conf/zoo.cfg: No such file or directory

Starting zookeeper ... STARTED

三)安裝kafka

步驟1:解壓&移動(dòng)到/usr/local

# tar -xzvf kafka_2.11-0.9.0.1.tgz

# mv kafka_2.11-0.9.0.1 /usr/local/kafka

步驟2:配置kafka,修改server.properties

# mkdir /usr/local/kafka/log/kafka #創(chuàng)建kafka日志目錄

# cd /usr/local/kafka/config #進(jìn)入配置目錄

# vim server.properties #編輯修改相應(yīng)的參數(shù)

  1. broker.id=0

  2. port=9092 #端口號(hào)

  3. host.name=10.8.5.101  #服務(wù)器IP地址,修改為自己的服務(wù)器IP

  4. log.dirs=/usr/local/kafka/log/kafka  #日志存放路徑,上面創(chuàng)建的目錄

  5. zookeeper.connect=localhost:2181  #zookeeper地址和端口,單機(jī)配置部署,localhost:2181

步驟3、配置kafka下的zookeeper

# mkdir /usr/local/kafka/zookeeper #創(chuàng)建zookeeper目錄

# mkdir /usr/local/kafka/log/zookeeper #創(chuàng)建zookeeper日志目錄

# cd /usr/local/kafka/config #進(jìn)入配置目錄

# vim zookeeper.properties #編輯修改相應(yīng)的參數(shù)

  1. dataDir=/usr/local/kafka/zookeeper #zookeeper數(shù)據(jù)目錄

  2. dataLogDir=/usr/local/kafka/log/zookeeper #zookeeper日志目錄

  3. clientPort=2181

  4. maxClientCnxns=100

  5. tickTime=2000

  6. initLimit=10

  7. syncLimit=5

步驟4:創(chuàng)建啟動(dòng)、關(guān)閉kafka腳本

1)創(chuàng)建啟動(dòng)kafka腳本

#cd  /usr/local/kafka/bin/

# vim kafkastart.sh

  1. #!/bin/bash

  2. #啟動(dòng)zookeeper

  3. /usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties &

  4. sleep 3

  5. #Start kafka

  6. /usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties &

2)創(chuàng)建關(guān)閉kafka腳本

# vim kafkastop.sh

  1. #!/bin/bash

  2. #stop zookeeper

  3. /usr/local/kafka/bin/zookeeper-server-stop.sh /usr/local/kafka/config/zookeeper.properties &

  4. sleep 3

  5. #Stop kafka

  6. /usr/local/kafka/bin/kafka-server-stop.sh /usr/local/kafka/config/server.properties &

3)#添加腳本執(zhí)行權(quán)限

chmod +x kafkastart.sh

chmod +x kafkastop.sh

4)設(shè)置腳本開機(jī)自動(dòng)執(zhí)行

# vim /etc/rc.d/rc.local #編輯,在最后添加一行

  1. sh /usr/local/kafka/kafkastart.sh & #設(shè)置開機(jī)自動(dòng)在后臺(tái)運(yùn)行腳本

  2. sh /usr/local/kafka/kafkastart.sh #啟動(dòng)kafka

  3. sh /usr/local/kafka/kafkastop.sh #關(guān)閉kafka

到此為止CentOs6.5下Kafka安裝配置完成。

成功標(biāo)志:

四)測(cè)試kafka

步驟1:?jiǎn)?dòng)zookeeper

# sh $zookeeper_home/bin/zkServer.sh start

JMX enabled by default

Using config: /home/laoyang/zookeeper/bin/../conf/zoo.cfg

grep: /home/laoyang/zookeeper/bin/../conf/zoo.cfg: No such file or directory

Starting zookeeper ... STARTED

步驟2:?jiǎn)?dòng)kafka

# ./kafkastart.sh

步驟3:測(cè)試創(chuàng)建topic

# cd /usr/local/kafka/bin

# ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

步驟4:通過(guò)list命令查看創(chuàng)建的topic

# cd /usr/local/kafka/bin

# ./kafka-topics.sh –list –zookeeper localhost:2181

步驟5:生產(chǎn)消息測(cè)試

# ./kafka-console-producer.sh --broker-list localhost:9092 --topic test

Kafka test!    //這里的“Kafka test!”為手動(dòng)輸入的,輸入后“ctrl +c”退出;

步驟6:消費(fèi)消息測(cè)試

# ./kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

I'm laoyang  #之前測(cè)試輸入的內(nèi)容

kafka test!

經(jīng)過(guò)上面幾步,代表kafka安裝成功。

五)停止kafka

步驟1:停止Kafka

cd /usr/local/kafka

# ./kafkastop.sh   //這里的kafka進(jìn)程并沒(méi)有關(guān)掉,需要手動(dòng)kill

步驟2:停止Zookeeper server

# sh $zookeeper_home/bin/zkServer.sh stop

至此,啟動(dòng),測(cè)試,停止全過(guò)程ok。

kafka啟動(dòng)過(guò)程中的報(bào)錯(cuò):

 WARN caught end of stream exception (org.apache.zookeeper.server.NIOServerCnxn)

EndOfStreamException: Unable to read additional data from client sessionid 0x157ac94cd940002, likely client has closed socket

    at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:228)

    at org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:208)

    at java.lang.Thread.run(Thread.java:745)

報(bào)錯(cuò)原因:

          zookeeper服務(wù)端和客戶端的jar版本不一致導(dǎo)致的 ;

解決辦法:

          從zookeeper服務(wù)端安裝目錄的根目錄復(fù)制zookeeper-xxx.jar到kafka安裝目錄下的libs目錄下即可,將kafka下libs目錄下的jar包刪除;

報(bào)錯(cuò):

java.lang.RuntimeException: A broker is already registered on the path /brokers/ids/1. This probably indicates that you either have configured a brokerid that is already in use, or else you have shutdown this broker and restarted it faster than the zookeeper timeout so it appears to be re-registering.
        at kafka.utils.ZkUtils$.registerBrokerInZk(ZkUtils.scala:205)
        at kafka.server.KafkaHealthcheck.register(KafkaHealthcheck.scala:57)
        at kafka.server.KafkaHealthcheck.startup(KafkaHealthcheck.scala:44)
        at kafka.server.KafkaServer.startup(KafkaServer.scala:103)
        at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:34)
        at kafka.Kafka$.main(Kafka.scala:46)
        at kafka.Kafka.main(Kafka.scala)

報(bào)錯(cuò)原因:

          該錯(cuò)誤是由于server.properties中的broker.id重復(fù)

解決辦法:

# vim server.properties

# The id of the broker. This must be set to a unique integer for each broker.

broker.id=0

看完了這篇文章,相信你對(duì)“Centos6.5下kafka如何部署安裝”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

名稱欄目:Centos6.5下kafka如何部署安裝
文章源于:http://m.newbst.com/article42/ispihc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站定制開發(fā)網(wǎng)站設(shè)計(jì)自適應(yīng)網(wǎng)站全網(wǎng)營(yíng)銷推廣關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司