Background: Ubuntu server, kakfa cluster installed
First, install Java
- Its installation
$ sudo apt update
$ sudo apt-get install openjdk-8-jdk
Copy the code
- Verifying the JDK version
$ java -version
Copy the code
2. Install ZooKeeper
- Example Create a ZooKeeper data storage directory
$ sudo mkdir -p /data/zookeeper
Copy the code
- 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
- 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
- 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
- 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
- None example Stop the ZooKeeper service
$ sudo bin/zkServer.sh stop
Copy the code
Install Kafka
- 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
- Background Startup Service
$ sudo bin/kafka-server-start.sh -daemon config/server.properties
Copy the code
- Disable the Kafka service
$ bin/kafka-server-stop.sh config/server.properties
Copy the code
Four, problem,
- Kafka fails to be started, and an error message is displayed indicating that kafka is added to the wrong ZooKeeper cluster