Deploy Zookeeper in Ubuntu: Install JDKsudoapt-getinstalldefault-jdk to install Zookeepercd/home/Hadoop/zookeepersudowgethttp: // developer.bjtu.edu.cn/apache/zookeeper/stable/zookee
Deploy Zookeeper in Ubuntu:
Install JDK
Sudo apt-get install Default-Jdk
Install Zookeeper
Cd/home/Hadoop/zookeeper
Sudo wget http://mirror.bjtu.edu.cn/apache/zookeeper/stable/zookeeper-3.3.5.tar.gz # Download zookeeper
Tar xvzf zookeeper-3.3.5.tar.gz # Extract
Ln-s zookeeper-3.3.5 zookeeper # Create soft link
Edit/etc/profile to set Environment Variables
# Zookeeper Configuration
Export ZOOKEEPER_INSTALL =/home/hadoop/zookeeper-3.3.5.
Export PATH = $ PATH: $ ZOOKEEPER_INSTALL/Bin
Configure zookeeper
Cd/home/hadoop/zookeeper/conf/
Cp zoo_sample.cfg zoo. cfg
Vim zoo. cfg
Modify the zoo. cfg file
SyncLimit = 5 # The maximum response time unit between the Leader and Follower. When the response exceeds syncLimit * tickTime, the Leader determines that the Follwer is dead and deletes the Follwer from the server list.
InitLimit = 10 # The initialization time of the new leader for voting.
TickTime = 2000 # Heartbeat time of the Zookeeper server, in milliseconds
ClientPort = 2181 # Connection Port
DataDir =/home/hadoop/zookeeper/data # Data Persistence path
DataLogDir =/home/hadoop/zookeeper/log # Log storage path
Start zookeeper server
Cd/home/hadoop/zookeeper/
Bin/zkServer. sh start
Bin/zkCli. sh-server localhost: 2181
When zookeeper server is started for the first time, an error message is displayed:
FAILED TO WRITE PID
Check that the zookeeper process exists and can be used properly.
This is zkServer. a bug in the sh script. dataDir is established inside the zookeeper process and has a certain delay. Therefore, dataDir has not been established when the zookeeper process id is written to the pidfile under dataDir, therefore, the above situation occurs.
Solution: Modify the script and write the pid after the dataDir directory is created.
...
If[$? -Eq0]
Then
While[! -D 'dirname $ ZOOPIDFILE']
Do
Sleep 1;
Done
If/Bin/echo-n $ Zkpid> " $ ZOOPIDFILE "
Then
Sleep 1
Echo STARTED
Else
Echo FAILED TO WRITE PID
Exit 1
Fi