1.下载zookeeper (我的版本是:apache-zookeeper-3.6.2-bin.tar.gz 、os镜像是 CentOS-7-x86_64-DVD-2009.iso, kafka是:kafka_2.12-2.7.0.tgz)
2.上传前可先到某个地方生成一个文件夹:mkdir java, 然后cd 到java中,然后上传
2.1.rz上传(找不到提示:yum install lrzsz)
3.解压:tar -zxvf apache-zookeeper-3.6.2-bin.tar.gz
4.重命名:mv apache-zookeeper-3.6.2-bin zookeeper
6.vi /etc/profile
#jdk 安装路径
export JAVA_HOME=/usr/local/java/jdk1.8.0_271
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
#zookeeper 安装路径
export ZOOKEEPER_HOME=/usr/local/java/zookeeper
export PATH=$PATH:/usr/local/java/zookeeper/bin
输入命令:source /etc/profile 文件生效
7. cd /usr/local/java/zookeeper/conf
8. cp zoo_sample.cfg zoo.cfg
9. mv zoo_sample.cfg zoo_sample_bak.cfg_bak # 防止启动不成功,我这里就是启动不成功报:拒绝访问,日志在:/usr/local/java/zookeeper/log下面
10. vi zoo.cfg
# 按i编辑
#....省略 若zookeeper下没有 data文件夹,则使用命令:mkdir data 生成一个
dataDir=/usr/local/java/zookeeper/data
#....省略,在最后加上,server.6 中:.6为zk集群编号
server.6=192.168.56.6:2888:3888
server.7=192.168.56.7:2888:3888
server.8=192.168.56.8:2888:3888
# 按esc退出 输入 :wq 保存
输入命令复制给其他centos7集群节点,也可以等安装jdk 安装zookeeper后一起复制
scp -r /usr/local/java/zookeeper/ node2:/usr/local/java/
scp -r /usr/local/java/zookeeper/ node3:/usr/local/java/
11. systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
12. cd /usr/local/java/zookeeper/bin
zkServer.sh start #开启
zkServer.sh status #查看状态
zkServer.sh stop # 关闭
开启后:一个node节点是leader 其他是 follower
#kafka
1、rz 上传
2、tar -zxf kafka_xxx #解压
3、mv kafka_xxx kafka #重命名
4、cd /kafka
mkdir data # 创建日志文件夹data
5、cd /config
6、cp server.properties server.properties_bak #拷贝
7、vi server.properties #编辑
#按i修改:
....
broker.id=7
....
log.dirs=/opt/kafka/data
....
zookeeper.connect=node1:2181,node3:2181,node3:2181
#按esc 退出 :wq保存
cd /opt/
scp -r kafka root@node2:/opt/ #拷贝到其他节点,并修改broker.id
scp -r kafka root@node3:/opt/
vi /etc/profile
.........
export JAVA_HOME=/usr/local/java/jdk1.8.0_271
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export ZOOKEEPER_HOME=/opt/zookeeper
export PATH=$PATH:/opt/zookeeper/bin:/opt/kafka/bin
source /etc/profile生效
启动kafka
kafka-server-start.sh /opt/kafka/config/server.properties