部分参考https://www.w3cschool.cn/apache_kafka/apache_kafka_installation_steps.html
1 java配置 openjdk
sudo apt install default-jre
sudo apt install default-jdk
java -version
2 java配置 oraclejdk
1 下载jdk
https://www.oracle.com/cn/java/technologies/javase-jdk16-downloads.html
ubuntu下我用的这个
jdk-16.0.2_linux-x64_bin.tar.gz
2 解压
tar -xvf jdk-16.0.2_linux-x64_bin.tar.gz
3 配置环境
这时候编辑这个文件会有权限的问题,它是只读的。
我把它改成rwx了(7)
chmod 7 /etc/profile
vie /etc/profile
按i添加如下内容
#jdk安装目录 就是上面解压的目录
#好多权限问题不懂 就暂时放到桌面的目录了 export JAVA_HOME=/usr/local/jdk-16.0.2
export JAVA_HOME=~/Desktop
export CLASSPATH=.:${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib:$CLASSPATH
export PATH=:${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin:$PATH
:wq
source /etc/profile
4 测试安装
javac
java -version

上面的流程会遇到个问题:jdk目录中没有jre。解决办法:
到安装目录中
window执行
cd jdk-16.0.2
bin\jlink.exe --module-path jmods --add-modules java.desktop --output jre
ununtu 执行
bin\jlink --module-path jmods --add-modules java.desktop --output jre
2 ZooKeeper安装

2.1 下载ZooKeeper
http://zookeeper.apache.org/releases.html
apache-zookeeper-3.7.0-bin.tar.gz
2.2
cd ~/Desktop
tar -zxf zookeeper-3.7.0.tar.gz
cd zookeeper-3.7.0
mkdir data
2.3创建配置文件
vi /conf/zoo.cfg
将以下所有参数设置为起点,保存并返回
tickTime=2000
dataDir=/path/to/zookeeper/data
clientPort=2181
initLimit=5
syncLimit=2
zoo_sample.cfg默认内容
# The number of milliseconds of each tick
# 单位ms,zookeeper每到tickTime的时间,会向注册的服务器
# 和slave发送一次心跳检测,也是zookeeper配置中的最小时间单位
# 其它配置会引用此配置
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
# slave在启动的时候,将首先从master同步数据,然后再对外提供服务。
# 如果slave没能在(initLimit*tickTime)的时间内完成这一动作(同步),
# 那么master会认为这个slave启动失败
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
# 在master和slave进行通讯时,请求和应答的时间总各,如果超过(syncLimit*tickTime),
# 则认为此次通讯失败,该slave不能正常提供服务,将停用此slave,所有指定此slave
# 的客户端将分配给其它服务。
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# 存储快照文件的目录,不要用临时的目录,这里只是个例子,需要换个真实的目录
# 日志文件也在这里放着
dataDir=/tmp/zookeeper
# 客户端连接此服务的端口
# the port at which the clients will connect
clientPort=2181
# 允许的最大客户端连接数
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
# 在数据快照目录中保存的快照数量
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# 自动清除的间隔,0是禁止清除
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
## Metrics Providers 不知道这是个啥
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
2.4启动zookeeper或停止

bin/zkServer.sh start
bin/zkServer.sh stop
2.5启动cli
bin/zkCli.sh
连上之后是一些连接信息,以及连接会话的信息

我再开一个 bin/zkCli.sh 则报错jJAVA_HOME没配置好,还不知道是为啥。

3 apache kafka安装
3.1 下载kafka
http://kafka.apache.org/downloads
2.8.0版本
3.2解压
cd opt/
tar -zxf kafka_2.8.0.tar.gz
cd kafka_2.8.0
3.3启动或停止
bin/kafka-server-start.sh config/server.properties
bin/kafka-server-start.sh config/server.properties
1726

被折叠的 条评论
为什么被折叠?



