1. 将scala-2.12.10.tgz、kafka_2.12-2.3.0.tgz解压到/usr/local目录下,重命名为scala、kafka:
如果虚拟机中已经安装了scala,则只安装kafka即可。
2. 对scala、kafka设置相应权限:
$ cd /usr/local
$ sudo chown -R hadoop ./scala
$ sudo chown -R hadoop ./kafka
3. 配置scala和kafka的环境变量,在~/.bashrc文件中,添加如下内容:
修改完毕后,别忘记执行如下命令使之生效:
$ source ~/.bashrc
4. 执行如下命令,测试scala是否安装配置成功:
$ cd ~
$ scala -version
执行如下命令,测试kafka是否安装配置成功
:
$ cd ~
$ kafka-topics.sh --help
至此,Scala和Kafka已经安装成功。
5. 启动ZK(/usr/local下已安装):
$ cd /usr/local/zookeeper
$ bin/zkServer.sh start
6. 配置Kafka的配置文件,位置是/usr/local/kafka/config/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 ##########################