Background: Ubuntu server, kakfa cluster installed

First, install Java

  1. Its installation
$ sudo apt update
$ sudo apt-get install openjdk-8-jdk
Copy the code
  1. Verifying the JDK version
$ java -version
Copy the code

2. Install ZooKeeper

  1. Example Create a ZooKeeper data storage directory
$ sudo mkdir -p /data/zookeeper
Copy the code
  1. Download the zookeeper zookeeper.apache.org/releases.ht…
$$CD/opt $sudo wget https://mirrors.bfsu.edu.cn/apache/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz Sudo tar XVF - apache - they are - 3.7.0 - bin. Tar. GzCopy the code
  1. Modifying a Configuration File
$ sudo nano /opt/zookeeper/conf/zoo.cfg
        tickTime = 2000
        dataDir = /data/zookeeper
        clientPort = 2181
        initLimit = 5
        syncLimit = 2
Copy the code
  1. Start the ZooKeeper service
$ sudo bin/zkServer.sh start
Copy the code

Start and view the log command

$ bin/zkServer.sh start-foreground
Copy the code
  1. The ZooKeeper service is connected
$sudo bin/ zkcli. sh -server 127.0.0.1:2181Copy the code

The connection to ZooKeeper is displayed. You can enter related commands to perform operations.

  • Help to view a list of available commands
  • Quit, close the session
  1. None example Stop the ZooKeeper service
$ sudo bin/zkServer.sh stop
Copy the code

Install Kafka

  1. Download the kafka kafka.apache.org/downloads
$sudo wget https://mirrors.bfsu.edu.cn/apache/kafka/2.8.0/kafka_2.12-2.8.0.tgz $sudo tar - XZF kafka_2. 12-2.8.0. TGZCopy the code
  1. Background Startup Service
$ sudo bin/kafka-server-start.sh -daemon config/server.properties
Copy the code
  1. Disable the Kafka service
$ bin/kafka-server-stop.sh config/server.properties
Copy the code

Four, problem,

  1. Kafka fails to be started, and an error message is displayed indicating that kafka is added to the wrong ZooKeeper cluster