Zookeeper is a centralized service for managing configuration info, naming, distributed synchronization, and provisioning of group companies that’s printed as open supply software program. It’s written in a Java language that means that you can deal with the core software logic with out worrying in regards to the distributed nature of the appliance. ZooKeeper’s structure helps excessive availability by way of redundant companies. Zookeeper permits distributed processes to coordinate with one another by way of a typical hierarchical namespace of knowledge registers. Zookeeper additionally gives its prospects excessive throughput, excessive availability, low latency and strictly managed entry to the Znodes. Zookeeper is particularly designed to retailer standing info, configurations, location info, and extra. ZooKeeper gives many options like dependable system, easy structure, quick processing, scalability and rather more.
On this tutorial, we are going to discover ways to arrange a single node Apache ZooKeeper Cluster on Ubuntu 18.04.
Necessities
- A server working Ubuntu 18.04.
- A root password is setup in your server.
Getting Began
First, you’ll need to replace your system with the newest model. You are able to do this by working the next command:
apt-get replace -y
apt-get improve -y
As soon as the system is up to date, restart your system to use all of the modifications.
Set up Java
Zookeeper is written in Java. So, you’ll need to put in Java to your system. By default, the newest model of Java will not be accessible within the Ubuntu 18.04 default repository. So, add the Java repository with the next command:
add-apt-repository ppa:linuxuprising/java
Subsequent, replace the repository and set up Java with the next command:
apt-get replace -y
apt-get set up oracle-java11-set-default
As soon as the Java has been put in, you possibly can test the Java model with the next command:
java --version
You need to see the next output:
java 11.0.2 2018-10-16 LTS Java(TM) SE Runtime Setting 18.9 (construct 11.0.2+7-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (construct 11.0.2+7-LTS, combined mode)
After getting completed, you possibly can proceed to the following step.
Create a ZooKeeper Consumer
Subsequent, you’ll need to create a zookeeper consumer to run zookeeper service.
First, create a zookeeper consumer with the next command:
useradd zookeeper -m
usermod --shell /bin/bash zookeeper
Subsequent, set a password with the next command:
passwd zookeeper
Subsequent, add the zookeeper consumer to the sudo group so it could possibly run instructions in a privileged mode:
usermod -aG sudo zookeeper
After creating consumer, you possibly can procced to put in ZooKeeper.
Set up ZooKeeper
ZooKeeper shops all configuration and state information to disk. So, you’ll need to create a listing construction for ZooKeeper with the next command:
mkdir -p /information/zookeeper
Subsequent, give correct possession to the /information listing with the next command:
chown -R zookeeper:zookeeper /information/zookeeper
Subsequent, change the listing to the /choose and obtain the newest model of ZooKeeper with the next command:
cd /choose
wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
Subsequent, extract the downloaded file with the next command:
tar -xvzf zookeeper-3.4.9.tar.gz
Subsequent, rename the extracted binary with the next command:
mv zookeeper-3.4.9 zookeeper
Subsequent, give possession to the ZooKeeper consumer with the next command:
chown -R zookeeper:zookeeper /choose/zookeeper
Configure ZooKeeper
Subsequent, you’ll need to create a configuration file for ZooKeeper. You are able to do it with the next command:
nano /choose/zookeeper/conf/zoo.cfg
Add the next traces:
tickTime=2500 dataDir=/information/zookeeper clientPort=2181 maxClientCnxns=80
Save and shut the file, when you’re completed.
Subsequent, begin the ZooKeeper service with the next command:
cd /choose/zookeeper
bin/zkServer.sh begin
You need to see the next output:
ZooKeeper JMX enabled by default Utilizing config: /choose/zookeeper/bin/../conf/zoo.cfg Beginning zookeeper ... STARTED
You possibly can hook up with the native ZooKeeper server with the next command:
bin/zkCli.sh -server 127.0.0.1:2181
After getting linked efficiently, you need to see the next output:
[zk: 127.0.0.1:2181(CONNECTED) 1]
Now, sort assistance on the immediate, you need to see the a listing of instructions that you could execute from the shopper.
assist ZooKeeper -server host:port cmd args stat path [watch] set path information [version] ls path [watch] delquota [-n|-b] path ls2 path [watch] setAcl path acl setquota -n|-b val path historical past redo cmdno printwatches on|off delete path [version] sync path listquota path rmr path get path [watch] create [-s] [-e] path information acl addauth scheme auth stop getAcl path shut join host:port
Now, sort stop to exit from the linked session.
You possibly can cease the ZooKeeper with the next command:
bin/zkServer.sh cease
You need to see the next output:
ZooKeeper JMX enabled by default Utilizing config: /choose/zookeeper/bin/../conf/zoo.cfg Stopping zookeeper ... STOPPED
Create a Systemd Service file for ZooKeeper
Subsequent, you’ll need to create a systemd service file to handle ZooKeeper service. You are able to do it with the next command:
nano /and so forth/systemd/system/zookeeper.service
Add the next traces:
[Unit] Description=Zookeeper Daemon Documentation=http://zookeeper.apache.org Requires=community.goal After=community.goal [Service] Kind=forking WorkingDirectory=/choose/zookeeper Consumer=zookeeper Group=zookeeper ExecStart=/choose/zookeeper/bin/zkServer.sh begin /choose/zookeeper/conf/zoo.cfg ExecStop=/choose/zookeeper/bin/zkServer.sh cease /choose/zookeeper/conf/zoo.cfg ExecReload=/choose/zookeeper/bin/zkServer.sh restart /choose/zookeeper/conf/zoo.cfg TimeoutSec=30 Restart=on-failure [Install] WantedBy=default.goal
Save and shut the file, when you’re completed.
Subsequent, reload the systemd daemon, begin the ZooKeeper service and allow it to begin on boot time with the next command:
systemctl daemon-reload
systemctl begin zookeeper
systemctl allow zookeeper
You possibly can test the standing of ZooKeeper service with the next command:
systemctl standing zookeeper
You need to see the next output:
? zookeeper.service - Zookeeper Daemon Loaded: loaded (/and so forth/systemd/system/zookeeper.service; disabled; vendor preset: enabled) Lively: lively (working) since Wed 2019-03-06 15:03:01 UTC; 5s in the past Docs: http://zookeeper.apache.org Course of: 3909 ExecStart=/choose/zookeeper/bin/zkServer.sh begin /choose/zookeeper/conf/zoo.cfg (code=exited, standing=0/SUCCESS) Principal PID: 3926 (java) Duties: 17 (restrict: 1113) CGroup: /system.slice/zookeeper.service ??3926 java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /choose/zookeeper/bin/../construct/courses:/choose/zookeeper/bin/.. Mar 06 15:03:00 ubuntu1804 systemd[1]: Beginning Zookeeper Daemon... Mar 06 15:03:00 ubuntu1804 zkServer.sh[3909]: ZooKeeper JMX enabled by default Mar 06 15:03:00 ubuntu1804 zkServer.sh[3909]: Utilizing config: /choose/zookeeper/conf/zoo.cfg Mar 06 15:03:01 ubuntu1804 zkServer.sh[3909]: Beginning zookeeper ... STARTED Mar 06 15:03:01 ubuntu1804 systemd[1]: Began Zookeeper Daemon.
Congratulations! you may have efficiently put in and configured ZooKeeper single node cluster on Ubuntu 18.04 server. Now you can deploy multi-node ZooKeeper cluster for manufacturing. Be at liberty to ask me when you’ve got any questions.
Comments