Deploy Zookeeper in Ubuntu

Source: Internet
Author: User
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.