十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
同时在125、129、130节点依次执行
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. 创建目录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节点依次执行
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节点依次执行
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节点依次执行
```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节点
129节点
130节点
使用kafka,创建一个主题(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. 发送消息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
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧