查询linux kafka安装目录,Kafka 1.0.0安装和配置--Linux篇
閱讀目錄:
1. 關閉防火墻和Selinux
2. 安裝所需環境JDK,Zookeeper
3. 下載Kafka 1.0.0版本
4. 配置Kafka
5. 啟動Kafka并驗證
6. 報錯及解決
7. 說明
1. 關閉防火墻和Selinux
Linux的防火墻是咱們新手的噩夢,很多情況會出現能ping通,但是訪問不了Web頁面。所以開始就干掉它!
1.1?關閉防火墻
[root@localhost ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
1.2 開機自動關閉防火墻
[root@localhost ~]# chkconfig iptables off
1.3 查看Selinux狀態
[root@localhost ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
1.4 關閉selinux
[root@localhost ~]# vim /etc/selinux/config
修改?SELINUX=disabled
注:永久開啟->改成:SELINUX=enforcing
2. 安裝所需環境JDK,Zookeeper
3. 下載Kafka 1.0.0版本
注:創建一個kafka消息目錄,主要存放kafka消息
[root@localhost /]# mkdir /usr/local/kafka
[root@localhost /]# mkdir /usr/local/kafka/kafka-logs
3.1 下載Kafka 1.0.0版本
[root@localhost /]# cd /usr/local/kafka
[root@localhost kafka]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/1.0.0/kafka_2.12-1.0.0.tgz
3.2 解壓
[root@localhost kafka]# tar -zxvf kafka_2.12-1.0.0.tgz
4.配置并啟動Kafka
4.1 進入到config目錄
[root@localhost kafka]# cd /usr/local/kafka/kafka_2.12-1.0.0/config
4.2 備份并修改server.properties
[root@localhost config]# cp server.properties server.properties.bak
[root@localhost config]# vim server.properties
修改標紅的三行,
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. ?See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. ?You may obtain a copy of the License at
#
# ? ?http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# see kafka.server.KafkaConfig for additional details and defaults
############################# Server Basics #############################
# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0
############################# Socket Server Settings #############################
# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
# ? FORMAT:
# ? ? listeners = listener_name://host_name:port
# ? EXAMPLE:
# ? ? listeners = PLAINTEXT://your.host.name:9092
#listeners=PLAINTEXT://:9092
port=9092
#這是你本機的ip地址
host.name=172.17.44.141
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://your.host.name:9092
num.network.threads=3
# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=102400
socket.request.max.bytes=104857600
############################# Log Basics #############################
# A comma seperated list of directories under which to store log files
log.dirs=/usr/local/kafka/kafka-logs
# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
num.partitions=1
....
4.3 配置Kafka環境變量
[root@localhost config]# vim /etc/profile
在文本末最后一行添加如下代碼:
export KAFKA_HOME=/usr/local/kafka/kafka_2.12-1.0.0
export PATH=$KAFKA_HOME/bin:$PATH
保存退出。
4.4 使配置立即生效
[root@localhost config]# source /etc/profile
5. 啟動Kafka并驗證
5.1 啟動zookeeper服務
[root@localhost config]#?/usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh?start
5.2 進入到kafka的bin目錄
[root@localhost config]# cd /usr/local/kafka/kafka_2.12-1.0.0
5.3 啟動kafka
[root@localhost kafka_2.12-1.0.0]# bin/kafka-server-start.sh?config/server.properties?&
5.4 驗證
[root@localhost kafka_2.12-1.0.0]# jps
3584?Jps
3299?QuorumPeerMainl
3519?Kafka
5.5?關閉kafka命令
[root@localhost kafka_2.12-1.0.0]# bin/kafka-server-stop.sh
6. 報錯及解決
啟動kafka報錯
[root@localhost kafka_2.12-1.0.0]# bin/kafka-server-start.sh?config/server.properties?&
Exception in thread "main" java.lang.UnsupportedClassVersionError: kafka/Kafka : Unsupported major.minor version 52.0
解決:請查看kafka對應的jdk版本,此次選用JDK版本為1.8
7. 說明
說明:本次使用
操作系統:CentOS 6.8?64位
Kafka版本:1.0.0
JDK版本:1.8.0_144
總結
以上是生活随笔為你收集整理的查询linux kafka安装目录,Kafka 1.0.0安装和配置--Linux篇的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: wordpress linux 目录,快
- 下一篇: 嵌入式linux应用程序实例,嵌入式Li