同時在125、129、130節(jié)點依次執(zhí)行
mkdir /app
cd /app
wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
2. 解壓tar -zxvf zookeeper-3.4.8.tar.gz
3. 創(chuàng)建目錄cd /app/zookeeper-3.4.8
mkdir data logs
4. 調整配置cp conf/zoo_sample.cfg conf/zoo.cfg
vim conf/zoo.cfg
第一處:配置dataDir
dataDir=/app/zookeeper-3.4.8/data
第二處:新增配置
server.1=192.168.105.125:2288:3388
server.2=192.168.105.129:2288:3388
server.3=192.168.105.130:2288:3388
5. 配置myidvim /app/zookeeper-3.4.8/data/myid
內容:1
vim /app/zookeeper-3.4.8/data/myid
內容:2
vim /app/zookeeper-3.4.8/data/myid
內容:3
6. 開放防火墻125/129/130節(jié)點依次執(zhí)行
firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --zone=public --add-port=2288/tcp --permanent
firewall-cmd --zone=public --add-port=3388/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports
7.啟動驗證zk/app/zookeeper-3.4.8/bin/zkServer.sh start /app/zookeeper-3.4.8/conf/zoo.cfg
/app/zookeeper-3.4.8/bin/zkServer.sh status /app/zookeeper-3.4.8/conf/zoo.cfg
二、kafka集群搭建同時在125、129、130節(jié)點依次執(zhí)行
2.1. 下載軟件wget https://archive.apache.org/dist/kafka/2.2.0/kafka_2.12-2.2.0.tgz
2.2. 解壓tar -zxvf kafka_2.12-2.2.0.tgz
2.3. 配置cd /app/kafka_2.12-2.2.0/config
cp server.properties server.properties.bak
vim server.properties
內容如下:
broker.id=1
listeners=PLAINTEXT://192.168.105.125:9092
advertised.listeners=PLAINTEXT://192.168.105.125:9092
port=9092
host.name=192.168.105.125
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/app/kafka/data
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=3
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=24
log.retention.bytes=1073741824
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=192.168.105.125:2181,192.168.105.129:2181,192.168.105.130:2181
zookeeper.connection.timeout.ms=6000
auto.create.topics.enable = false
delete.topic.enable=true
message.max.byte=52428880
log.cleanup.policy=delete
log.segment.delete.delay.ms=0
group.initial.rebalance.delay.ms=0
vim server.properties
內容如下:
broker.id=2
listeners=PLAINTEXT://192.168.105.129:9092
advertised.listeners=PLAINTEXT://192.168.105.129:9092
port=9092
host.name=192.168.105.125
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/app/kafka/data
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=3
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=24
log.retention.bytes=1073741824
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=192.168.105.125:2181,192.168.105.129:2181,192.168.105.130:2181
zookeeper.connection.timeout.ms=6000
auto.create.topics.enable = false
delete.topic.enable=true
message.max.byte=52428880
log.cleanup.policy=delete
log.segment.delete.delay.ms=0
group.initial.rebalance.delay.ms=0
vim server.properties
內容如下:
broker.id=3
listeners=PLAINTEXT://192.168.105.130:9092
advertised.listeners=PLAINTEXT://192.168.105.130:9092
port=9092
host.name=192.168.105.130
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/app/kafka/data
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=3
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=24
log.retention.bytes=1073741824
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=192.168.105.125:2181,192.168.105.129:2181,192.168.105.130:2181
zookeeper.connection.timeout.ms=6000
auto.create.topics.enable = false
delete.topic.enable=true
message.max.byte=52428880
log.cleanup.policy=delete
log.segment.delete.delay.ms=0
group.initial.rebalance.delay.ms=0
``
###### 2.4. 防火墻
125/129/130節(jié)點依次執(zhí)行
```bash
firewall-cmd --zone=public --add-port=9092/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports
2.5. 啟動kafka啟動kafka(第一次前臺)
cd /app/kafka_2.12-2.2.0
./bin/kafka-server-start.sh config/server.properties
啟動kafka(前臺)
cd /app/kafka_2.12-2.2.0
./bin/kafka-server-start.sh -daemon config/server.properties
125節(jié)點
129節(jié)點
130節(jié)點
使用kafka,創(chuàng)建一個主題(topic)
bin/kafka-topics.sh --create --zookeeper 192.168.105.125:2181,192.168.105.129:2181,192.168.105.130:2181 --replication-factor 1 --partitions 1 --topic pis-business
3.2. 發(fā)送消息bin/kafka-console-producer.sh --broker-list 192.168.105.125:9092 --topic pis-business
3.3. 消費消息bin/kafka-console-consumer.sh --bootstrap-server 192.168.105.125:9092 --from-beginning --topic pis-business
你是否還在尋找穩(wěn)定的海外服務器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機房具備T級流量清洗系統(tǒng)配攻擊溯源,準確流量調度確保服務器高可用性,企業(yè)級服務器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧
分享文章:linuxzookeeperkafka-創(chuàng)新互聯(lián)
URL標題:http://www.rwnh.cn/article0/ccghio.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供服務器托管、網(wǎng)站設計、品牌網(wǎng)站制作、標簽優(yōu)化、響應式網(wǎng)站、網(wǎng)站建設
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)