【手打】kafka集群设置

服务器

192.168.0.7  4c16G

192.168.0.8 4c16G

192.168.0.9 4c16G

版本

wget https://archive.apache.org/dist/kafka/1.1.1/kafka_2.11-1.1.1.tgz
tar xf kafka_2.11-1.1.1.tgz
mv kafka_2.11-1.1.1 /usr/local/kafka-1.1.1

# java版本jdk-8u241-linux-x64.rpm

1、 zookeeper集群
dataDir=/usr/local/kafka-1.1.1/data/zookeeper
# the port at which the clients will connect
clientPort=2181
# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=0
initLimit=5
syncLimit=2
server.7=192.168.0.7:2666:3666
server.8=192.168.0.8:2666:3666
server.9=192.168.0.9:2666:3666
admin.serverPort=8080

# zookeeper node-1
echo "7" > /usr/local/kafka-1.1.1/data/zookeeper/myid
#zookeper node-2
echo "8" > /usr/local/kafka-1.1.1/data/zookeeper/myid
#zookeeper node-3
echo "9" > /usr/local/kafka-1.1.1/data/zookeeper/myid

cat > /etc/systemd/system/zookeeper.service << EOF
[Unit]
Description=Apache Zookeeper server (Kafka)
Documentation=http://zookeeper.apache.org
Requires=network.target remote-fs.target
After=network.target remote-fs.target
[Service]
Type=simple
User=root
Group=root
Environment=JAVA_HOME=/usr/java/default
ExecStart=/usr/local/kafka-1.1.1/bin/zookeeper-server-start.sh /usr/local/kafka-1.1.1/config/zookeeper.properties
ExecStop=/usr/local/kafka-1.1.1/bin/zookeeper-server-stop.sh
[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload;
systemctl enable zookeeper;
systemctl start zookeeper;
systemctl status zookeeper


2、kafka集群

broker.id=9
listeners=PLAINTEXT://192.168.0.7:9092
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=/usr/local/kafka-1.1.1/kafka-logs
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=192.168.0.7:2181,192.168.0.8:2181,192.168.0.9:2181
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1


cat > /etc/systemd/system/kafka.service << EOF
[Unit]
Description=Apache Kafka server (broker)
Documentation=http://kafka.apache.org/documentation.html
Requires=network.target remote-fs.target
After=network.target remote-fs.target zookeeper.service
[Service]
Type=simple
User=root
Group=root
Environment=JAVA_HOME=/usr/java/default
ExecStart=/usr/local/kafka-1.1.1/bin/kafka-server-start.sh /usr/local/kafka-1.1.1/config/server.properties
ExecStop=/usr/local/kafka-1.1.1/bin/kafka-server-stop.sh
[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable kafka
systemctl start kafka
systemctl status kafka

原文地址:https://www.cnblogs.com/wangshuyang/p/14742262.html