virtualbox ubuntu22.04 zookeeper kafka cluster deploy

1 通过virtualbox配置3台主机ubuntu 22.04
1.1 网络配置为host-only & nat
参考:https://segmentfault.com/a/1190000044119197

1.2 hostname分别设置为zk1, zk2, zk3
hostname change command: hostnamectl hostname zk1

1.3 配置/etc/hosts

192.168.59.6 zk1
192.168.49.3 zk2
192.168.216.3 zk3

ip address根据具体情况替换
ip a command查询

2 install jdk
jdk-8u144-linux-x64.tar.gz: https://www.oracle.com/java/technologies/javase/javase8-archi...

设置zookeeper工作目录,比如 /data/soft/new/
将该目录user group设置当前用户可访问, 假设当前用户为zk chown zk:zk -R /data/soft/new/

解压: tar xvf jdk-8u144-linux-x64.tar.gz
移动: mv jdk-8u144-linux-x64 /data/soft/new/jdk
配置jdk全局变量:

# vim ~/.bashrc
export JAVA_HOME=/data/soft/new/jdk
export PATH=$PATH:$JAVA_HOME/bin

使生效:source ~/.bashrc

3 install zookeeper
zookeeper-3.4.6: https://archive.apache.org/dist/zookeeper/

tar xvf zookeeper-3.4.6.tar.gz
mv zookeeper-3.4.6 /data/soft/new/zookeeper
# 创建状态数据存储文件夹
mkdir -p /data/soft/new/zkdata

配置zoo.cfg

1 cd /data/soft/new/zookeeper/conf
2 cp zoo_sample.cfg zoo.cfg
3 vim zoo.cfg

编辑zoo.cfg

dataDir=/data/soft/new/zkdata
# 各个服务节点地址配置
server.1=zk1:2888:3888
server.2=zk2:2888:3888
server.3=zk3:2888:3888

/etc/hosts配置了hostname 与IP地址映射, 所以服务节点可以使用hostname配置

在dataDir目录下创建myid文件

# zk1 hostname
echo 1 > /data/soft/new/zkdata/myid
# zk2 hostname
echo 2 > /data/soft/new/zkdata/myid
# zk3 hostname
echo 3 > /data/soft/new/zkdata/myid

配置zookeeper环境变量

# vi ~/.bashrc
export ZK_HOME=/data/soft/new/zookeeper
export PATH=$PATH:$ZK_HOME/bin

使生效 source ~/.bashrc

针对3台主机做相同的操作

启动zookeeper
zkServer.sh start

4 单机部署kafka
kafka 0.10.2.0:

1 wget https://archive.apache.org/dist/kafka/0.10.2.0/kafka_2.11-0.10.2.0.tgz
2 tar xvf kafka_2.11-0.10.2.0.tgz
3 mv kafka_2.11-0.10.2.0 /data/soft/new/kafka

配置kafka全局变量

# vi ~/.bashrc
export KAFKA_HOME=/data/soft/new/kafka
export PATH=$PATH:$KAFKA_HOME/bin

使生效 source ~/.bashrc

你可能感兴趣的:(virtualbox ubuntu22.04 zookeeper kafka cluster deploy)