Foreword:
When I was studying today, my teacher asked to install zookeeper on Linux. My computer could not be installed because of the virtual machine used in teaching, so I was going to install it on my Alibaba Cloud server, but it was reported that it was not installed on the virtual machine. After checking the log and Baidu, the error was finally solved. Now I will record the solution, first talk about the solution, and finally keep up with the process.
solution:
1. Screenshot of error report:
This picture tells me that the startup failed, and I am desperate! I didn't tell me why I failed, but I need to know why I failed to make corrections. Then I have to check the log. Don't panic, it's very simple.
2. Check the log to see why the error was reported
First, enter the log folder (that is, zookeeper's logs):
cd logs
You can see the log file (zookeeper-root-server-iZi39da7z1bbe9Z.out), and then check the log, just check the last 20 lines
tail -n 20 zookeeper-root-server-iZi39da7z1bbe9Z.out
See the screenshot of the error report as follows:
first look at the Chinese, the address is already in use, you should know that it is a port conflict when you see it, but I am very confused that the port of 2181 can still conflict... Then carefully look at the top of the error report: Caused by: java.io.IOException: Failed to bind to /0.0.0.0:8080………………The port 8080 conflicts here.
After searching on Baidu, I found out: In the latest version of zookeeper, there is an embedded management console that is started by jetty, which will occupy port 8080. If you want to download the old version, you won't have this problem.
solve:
There are three solutions:
(1). Delete jetty.
(2) Modify the port.
There are two ways to modify the method, one is to add in the startup script
Dzookeeper.admin.serverPort=你的端口号
One is to increase in zoo.cfg
admin.serverPort=没有被占用的端口号
(3) Disable this service and add it to the startup script
Dzookeeper.admin.enableServer=false
My own solution (modify the port number):
I used the way to change the port number:
first enter the conf directory
cd conf
Then edit the zoo.cfg file
vim zoo.cfg
Add the following sentence
admin.serverPort=随便一个不重复的端口号
For example:
then save it, just start it! ! !
……
……
……
……
Incidental installation process:
1. Upload compressed files
Upload to /usr/local/tmp
2. Unzip
tar zxf apache-zookeeper-3.5.5-bin.tar.gz
cp -r apache-zookeeper-3.5.5-bin ../zookeeper
3. Create a new data directory
Enter into zookeeper
cd /usr/local/zookeeper
mkdir data
4. Modify the configuration file
Enter conf
cd conf
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg
5. Modify dataDir to the path of the data folder
6. Start zookeeper
Enter the bin folder
cd /usr/local/zookeeper/bin
./zkServer.sh start
Screenshot of successful startup
7. View the startup status through status. There is a slight waiting time
./zkServer.sh status
View status screenshot: