分为三部分:
- 安装配置jdk
- 安装配置zookeeper
- 安装配置kafka
简要介绍安装配置jdk
下载jdk-8u291-linux-x64.tar.gz,解压到指定文件
export JAVA_HOME=/usr/java/jdk1.8.0_291
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
安装配置zookeeper
3.5版本之后请下载bin压缩包
wget https://downloads.apache.org/zookeeper/zookeeper-3.5.9/apache-zookeeper-3.5.9-bin.tar.gz
解压到/tmp目录
tar -zxvf apache-zookeeper-3.5.9-bin.tar.gz
修改配置文件
cd zookeeper/conf
cp zoo_sample.cfg zoo.cfg
cat zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper/data
clientPort=2181
创建dataDir
mkdir /tmp/zookeeper/data
启动
cd /tmp/zookeeper/bin
./zkServer.sh start
查看
zkServer.sh status
ps -ef|grep zookeeper
设置开机启动
cd /etc/init.d
vi zookeeper
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
ZK_PATH=/tmp/zookeeper/
export JAVA_HOME=/usr/java/jdk1.8.0_291
case $1 in
start) sh $ZK_PATH/bin/zkServer.sh start;;
stop) sh $ZK_PATH/bin/zkServer.sh stop;;
status) sh $ZK_PATH/bin/zkServer.sh status;;
restart) sh $ZK_PATH/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
修改权限
chmod +x zookeeper
chmod -R 777 zookeeper
启动服务
service zookeeper start
service zookeeper status
ps -ef|grep zookeeper
安装配置kafka
wget http://archive.apache.org/dist/kafka/2.8.0/kafka_2.12-2.8.0.tgz
解压到/tmp目录并重命名为kafka
修改配置
cd /tmp/kafka/config/
[root@computer2 config]# grep -v ^# server.properties | grep -v ^$
broker.id=0
dvertised.listeners=PLAINTEXT://172.20.13.234: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=/tmp/kafka/kafka-0-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=172.20.13.234:2181
dataDir=/tmp/zookeeper
zookeeper.connection.timeout.ms=18000
group.initial.rebalance.delay.ms=0
后台启动
cd /tmp/kafka/ ./bin/kafka-server-start.sh ../config/server.properties 1>/dev/null 2>&1 &