一、環(huán)境配置
創(chuàng)新互聯(lián)建站是一家專(zhuān)注于網(wǎng)站建設(shè)、做網(wǎng)站與策劃設(shè)計(jì),沿灘網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)建站做網(wǎng)站,專(zhuān)注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專(zhuān)業(yè)建站公司;建站業(yè)務(wù)涵蓋:沿灘等地區(qū)。沿灘做網(wǎng)站價(jià)格咨詢(xún):189820811081.系統(tǒng)環(huán)境
[root@date ~]# cat /etc/centos-release CentOS Linux release 7.4.1708 (Core)2..安裝JAVA環(huán)境
yum -y install java java-1.8.0-openjdk-devel #jps需要jdk-devel支持3.下載kafka
[root@slave1 ~]# ls kafka_2.11-1.0.0.tgz kafka_2.11-1.0.0.tgz二、配置zookeeper
1.修改kafka中zookeeper的配置文件
[root@slave1 ~]# cat /opt/kafka/config/zookeeper.properties | grep -v "^$" | grep -v "^#" tickTime=2000 initLimit=10 syncLimit=5 maxClientCnxns=300 dataDir=/opt/zookeeper/data dataLogDir=/opt/zookeeper/log clientPort=2181 server.1=20.0.5.11:2888:3888 server.2=20.0.5.12:2888:3888 server.3=20.0.5.13:2888:38882.復(fù)制配置文件到其他節(jié)點(diǎn)
[root@slave1 ~]# pscp.pssh -h zlist /opt/kafka/config/zookeeper.properties /opt/kafka/config/ [root@slave1 ~]# cat zlist 20.0.5.11 20.0.5.12 20.0.5.133.在各個(gè)節(jié)點(diǎn)創(chuàng)建數(shù)據(jù)和日志目錄
[root@slave1 ~]# pssh -h zlist 'mkdir /opt/zookeeper/data' [root@slave1 ~]# pssh -h zlist 'mkdir /opt/zookeeper/log'4.創(chuàng)建myid文件
[root@slave1 ~]# pssh -H slave1 -i 'echo 1 > /opt/zookeeper/data/myid' [root@slave1 ~]# pssh -H slave2 -i 'echo 2 > /opt/zookeeper/data/myid' [root@slave1 ~]# pssh -H slave3 -i 'echo 3 > /opt/zookeeper/data/myid'5.啟動(dòng)zookeeper
[root@slave1 ~]# pssh -h zlist 'nohup /opt/kafka/bin/zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties &' [root@slave1 ~]# pssh -h zlist -i 'jps' [1] 23:29:36 [SUCCESS] 20.0.5.12 3492 QuorumPeerMain 3898 Jps [2] 23:29:36 [SUCCESS] 20.0.5.11 7369 QuorumPeerMain 9884 Jps [3] 23:29:36 [SUCCESS] 20.0.5.13 3490 QuorumPeerMain 3898 Jps三、配置kafka
1.修改server.properties
[root@slave1 ~]# cat /opt/kafka/config/server.properties broker.id=1 #機(jī)器唯一標(biāo)識(shí) host.name=20.0.5.11 #當(dāng)前broker機(jī)器ip port=9092 #broker監(jiān)聽(tīng)端口 num.network.threads=3 #服務(wù)器接受請(qǐng)求和響應(yīng)請(qǐng)求的線(xiàn)程數(shù) num.io.threads=8 #io線(xiàn)程數(shù) socket.send.buffer.bytes=102400 #發(fā)送緩沖區(qū)大小,數(shù)據(jù)先存儲(chǔ)到緩沖區(qū)了到達(dá)一定的大小后在發(fā)送 socket.receive.buffer.bytes=102400 #接收緩沖區(qū)大小,達(dá)到一定大小后序列化到磁盤(pán) socket.request.max.bytes=104857600 #向kafka請(qǐng)求消息或者向kafka發(fā)送消息的請(qǐng)求的大數(shù) log.dirs=/opt/kafkalog #消息存放目錄 delete.topic.enable=true #能夠通過(guò)命令刪除topic num.partitions=1 #默認(rèn)的分區(qū)數(shù),一個(gè)topic默認(rèn)1個(gè)分區(qū)數(shù) num.recovery.threads.per.data.dir=1 #設(shè)置恢復(fù)和清理超時(shí)數(shù)據(jù)的線(xiàn)程數(shù)量 offsets.topic.replication.factor=3 #用于配置offset記錄的topic的partition的副本個(gè)數(shù) transaction.state.log.replication.factor=3 transaction.state.log.min.isr=3 log.retention.hours=168 #消息保存時(shí)間 log.segment.bytes=1073741824 #日志文件大值,當(dāng)日志文件的大于大值,則創(chuàng)建一個(gè)新的 log.retention.check.interval.ms=300000 #日志保留檢查間隔 zookeeper.connect=20.0.5.11:2181,20.0.5.12:2181,20.0.5.13:2181 #zookeeper地址 zookeeper.connection.timeout.ms=6000 #連接zookeeper超時(shí)時(shí)間2.復(fù)制broke配置文件到其他服務(wù)節(jié)點(diǎn)上(修改broker.id和host.name)
3.啟動(dòng)kafka broke
[root@slave1 ~]# pssh -h zlist '/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties > /root/kafka.log 2>1&' [1] 02:13:05 [SUCCESS] 20.0.5.11 [2] 02:13:05 [SUCCESS] 20.0.5.12 [3] 02:13:05 [SUCCESS] 20.0.5.13 [root@slave1 ~]# pssh -h zlist -i 'jps' [1] 02:14:51 [SUCCESS] 20.0.5.12 3492 QuorumPeerMain 6740 Jps 6414 Kafka [2] 02:14:51 [SUCCESS] 20.0.5.13 3490 QuorumPeerMain 4972 Kafka 5293 Jps [3] 02:14:51 [SUCCESS] 20.0.5.11 7369 QuorumPeerMain 11534 Kafka 11870 Jps4.創(chuàng)建topic
[root@slave1 ~]# /opt/kafka/bin/kafka-topics.sh --create --zookeeper 20.0.5.11:2181,20.0.5.12:2181,20.0.5.13:2181 --replication-factor 3 --partitions 3 --topic test1 Created topic "test1". [root@slave1 ~]# /opt/kafka/bin/kafka-topics.sh --describe --zookeeper 20.0.5.11:2181,20.0.5.12:2181,20.0.5.13:2181 --topic test1 Topic:test1 PartitionCount:3 ReplicationFactor:3 Configs: Topic: test1 Partition: 0 Leader: 2 Replicas: 2,3,1 Isr: 2,3,1 Topic: test1 Partition: 1 Leader: 3 Replicas: 3,1,2 Isr: 3,1,2 Topic: test1 Partition: 2 Leader: 1 Replicas: 1,2,3 Isr: 1,2,35.啟動(dòng)producer和consumer
[root@slave4 ~]# /opt/kafka/bin/kafka-console-producer.sh --broker-list 20.0.5.12:9092 --topic test1 [root@slave5 ~]# /opt/kafka/bin/kafka-console-consumer.sh --zookeeper 20.0.5.13:2181 --topic test16.刪除topic
[root@slave1 ~]# /opt/kafka/bin/kafka-topics.sh --delete --zookeeper 20.0.5.11:2181 --topic test1 Topic test1 is marked for deletion. Note: This will have no impact if delete.topic.enable is not set to true.另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。
分享題目:kafka集群安裝及管理(一)-創(chuàng)新互聯(lián)
鏈接分享:http://jinyejixie.com/article18/jgjgp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、企業(yè)建站、自適應(yīng)網(wǎng)站、服務(wù)器托管、動(dòng)態(tài)網(wǎng)站、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容