kafka单节点安装

本文涉及的产品
注册配置 MSE Nacos/ZooKeeper,118元/月
服务治理 MSE Sentinel/OpenSergo,Agent数量 不受限
云原生网关 MSE Higress,422元/月
简介: kafka和zookeeper单节点安装

jdk安装

1、下载

jdk下载镜像:/mirrors_toolkit/java/jdk/8u202-b08/
jdk下载地址:

https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz

2、解压缩

[root@kafka ~]# tar zxvf jdk-8u202-linux-x64.tar.gz

3、安装

[root@kafka ~]# mv jdk1.8.0_202/ /usr/local
[root@kafka local]# ln -s jdk1.8.0_202 jdk
[root@kafka local]# ls -lrt
total 48
drwxr-xr-x. 2 root root 4096 Apr 11  2018 src
drwxr-xr-x. 2 root root 4096 Apr 11  2018 sbin
drwxr-xr-x. 2 root root 4096 Apr 11  2018 libexec
drwxr-xr-x. 2 root root 4096 Apr 11  2018 lib64
drwxr-xr-x. 2 root root 4096 Apr 11  2018 lib
drwxr-xr-x. 2 root root 4096 Apr 11  2018 include
drwxr-xr-x. 2 root root 4096 Apr 11  2018 games
drwxr-xr-x. 2 root root 4096 Apr 11  2018 etc
drwxr-xr-x. 2 root root 4096 Apr 11  2018 bin
drwxr-xr-x. 6 root root 4096 Dec  3  2018 share
drwxr-xr-x  6 root root 4096 Dec 18 09:13 aegis
lrwxrwxrwx  1 root root   13 Dec 18 09:22 jdk -> jdk1.8.0_202/
drwxr-xr-x  7   10  143 4096 Dec 18 10:26 jdk1.8.0_202

添加环境变量
在/etc/profile中添加

export JAVA_HOME=/usr/local/jdk
export PATH=$PATH:${JAVA_HOME}/bin

使环境变量生效source /etc/profile
输入java,若出现如下内容则安装成功

[root@kafka local]# java
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32      use a 32-bit data model if available
    -d64      use a 64-bit data model if available
    -server      to select the "server" VM
                  The default VM is server,
                  because you are running on a server-class machine.


    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.

zookeeper安装

新建用户

zookeeper安装在zoo用户下首先创建用户:
useradd zoo
切换到zoo用户下
su - zoo

下载

zookeeper下载镜像:https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper
本次版本为:3.6.2
下载地址为:https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2.tar.gz
使用命令:
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.6.2/apache-zookeeper-3.6.2.tar.gz
下载zookeeper包并解压
tar zxvf apache-zookeeper-3.6.2.tar.gz

安装

ln -s apache-zookeeper-3.6.2-bin zookeeper
新增环境变量:
在/home/zoo下执行:
vi .bashrc
新增两行:
export ZOOKEEPER_HOME=/home/zoo/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
保存退出后执行: source ~/.bashrc 使环境变量生效
修改配置文件
cd zookeeper/conf
cp zoo_sample.cfg zoo.cfg
编辑zoo.cfg
修改或添加如下两行
dataDir=/home/zoo/data
dataLogDir=/home/zoo/log

启动

执行如下命令观察是否能启动成功

zkServer.sh start

kafka安装

新建用户

kafka安装在kafka用户下首先创建用户:
useradd kafka
切换到kafka用户下
su - kafka

下载

kafka下载镜像:https://mirrors.tuna.tsinghua.edu.cn/apache/kafka
本次版本为:2.5.1
下载地址为:https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.5.1/kafka_2.13-2.5.1.tgz
使用命令:
wget https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.5.1/kafka_2.13-2.5.1.tgz
下载kafka包并解压
tar zxvf kafka_2.13-2.5.1.tgz

安装

ln -s kafka_2.13-2.5.1 kafka
新增环境变量:
在/home/kafka下执行:
vi .bashrc
新增两行:
export KAFKA_HOME=/home/kafka/kafka
export PATH=$PATH:$KAFKA_HOME/bin
保存退出后执行: source ~/.bashrc 使环境变量生效
修改配置文件
cd kafka/conf
编辑server.xml
修改或添加如下两行
log.dirs=/home/kafka/kafka-logs
zookeeper.connect=kafka:2181

启动

执行如下命令观察是否能启动成功

kafka-server-start.sh -daemon /home/kafka/kafka/config/server.properties

将zookeeper,kafka加入supervisor进程管理

kafka.ini

[program:kafka]
environment=JAVA_HOME=/usr/local/jdk
command=sh /home/kafka/kafka/bin/kafka-server-start.sh /home/kafka/kafka/config/server.properties
user=kafka
startsecs=0
stopwaitsecs=0
stopasgroup=true
autostart=true
autorestart=true
stdout_logfile=/home/kafka/log/supervisor_kafka.log
stderr_logfile=/home/kafka/log/supervisor_kafka.err

zookeeper.ini

[program:zookeeper]
environment=JAVA_HOME=/usr/local/jdk
command=/home/zoo/zookeeper/bin/zkServer.sh start-foreground
user=zoo
startsecs=0   
stopwaitsecs=0    
stopasgroup=true
autostart=true
autorestart=true
stdout_logfile=/home/zoo/log/supervisor_zoo.log                          
stderr_logfile=/home/zoo/log/supervisor_zoo_err.log
相关文章
|
6月前
|
消息中间件 监控 数据可视化
Linux安装Kafka图形化界面
Linux安装Kafka图形化界面
279 4
|
4月前
|
消息中间件 Ubuntu Java
在Ubuntu 18.04上安装Apache Kafka的方法
在Ubuntu 18.04上安装Apache Kafka的方法
217 0
|
1月前
|
消息中间件 Ubuntu Java
Ubuntu系统上安装Apache Kafka
Ubuntu系统上安装Apache Kafka
|
3月前
|
消息中间件 Java Linux
linux 之centos7安装kafka;;;;;待补充,未完成
linux 之centos7安装kafka;;;;;待补充,未完成
|
7月前
|
消息中间件 Java Kafka
Kafka【环境搭建 01】kafka_2.12-2.6.0 单机版安装+参数配置及说明+添加到service服务+开机启动配置+验证+chkconfig配置说明(一篇入门kafka)
【2月更文挑战第19天】Kafka【环境搭建 01】kafka_2.12-2.6.0 单机版安装+参数配置及说明+添加到service服务+开机启动配置+验证+chkconfig配置说明(一篇入门kafka)
314 1
|
5月前
|
消息中间件 Java Kafka
kafka Linux环境搭建安装及命令创建队列生产消费消息
kafka Linux环境搭建安装及命令创建队列生产消费消息
123 4
|
4月前
|
消息中间件 存储 Ubuntu
在Ubuntu 14.04上安装Apache Kafka的方法
在Ubuntu 14.04上安装Apache Kafka的方法
26 0
|
4月前
|
消息中间件 Java Kafka
Docker 安装 kafka
Docker 安装 kafka
109 0
|
4月前
|
消息中间件 Kafka Apache
部署安装kafka集群
部署安装kafka集群
|
6月前
|
消息中间件 存储 Ubuntu
Linux安装kafka3.5.1
Linux安装kafka3.5.1
156 2

热门文章

最新文章