Une erreur s'est produite.

L'erreur a été envoyée par e-mail à l'administrateur pour analyse.

How do I try out clustered configuration, requests, events and shared data sources in development?

Install Zookeeper from the source code.

Hello, my name is Christopher Tate. I am a Red Hat consultant and I love open source software. A web application that is built to scale should be built using a centralized cluster manager like Zookeper. There is a lot of work that has gone into Zookeeper that fix the bugs and race conditions that are inevitable in distributed applications. You will benefit from clustered configuration, shared data source pool, shared background worker threads, and a clustered event bus for scaling and load balancing requests. I will help you install the most recent version of Zookeeper to scale your website the open source way.

Customize the whole site for your domain.

  1. Just click the [ Login ] button above.
  2. Click: New user? Register
  3. It's free, and your information is private.

How do I install the dependencies for Zookeeper?

Build the dependencies with yum.

sudo yum install -y ivy lsof maven ant git libtool automake cppunit cppunit-devel python-setuptools
  1. sudo
    : The command to install yum repositories begins with the command sudo. The "sudo" command allows your current user to have root privileges for a few minutes after entering your password. Installing yum repositories always requires root privileges.
  2. yum
    Stands for "Yellowdog Updater Modified", but nobody knows it as yellowdog, just yum. CentOS manages software packages and RPM application files with yum.
  3. install
    : For installing new yum packages.
  4. -y
    : Suppress messages asking to confirm if you want to install the software.
  5. ivy lsof maven ant git libtool automake cppunit cppunit-devel python-setuptools
    : The package names of the dependencies for building Zookeeper from the source code.

Where do I put the Zookeeper source code?

Create a zookeeper directory in /usr/local/src.

sudo install -d -o $USER -g $USER /usr/local/src/zookeeper
  1. sudo
  2. install: Creates directories and sets attributes on the new directory.
  3. -d: Create directories.
  4. -o: Set ownership on the directory (super-user only).
  5. $USER: The current user to make the owner of the directory.
  6. -g: Set group ownership on the directory (super-user only).
  7. $USER: The current user to make the group owner of the directory.
  8. /usr/local is a place for extra software that you install without the package manager. /usr/local/src is a good place to clone your open source software repositories.

How do I download the Zookeeper source code?

Clone the source code with the git command.

git clone https://github.com/apache/zookeeper.git /usr/local/src/zookeeper
  1. git: The distributed revision control system for most open source software.
  2. clone: Clone a repository into a directory.
  3. https://github.com/apache/zookeeper.git: The git URL to the Zookeeper source code repository.
  4. /usr/local/src/zookeeper: The directory where the Zookeeper source code will be cloned.

How do I pick a recent version of Zookeeper?

List all the tags in the git repository.

(cd /usr/local/src/zookeeper && git tag)
  1. (cd: Change directory temporarily, because of the open parenthesis.
  2. /usr/local/src/zookeeper: The directory where the Zookeeper source code was cloned.
  3. &&: Run the cd and git command together.
  4. git
  5. tag): Lists the current tags or assigned versions of the code and close the parenthesis.

How do I switch versions of the Zookeeper source code?

Checkout the git tag.

(cd /usr/local/src/zookeeper && git checkout release-3.5.5)
  1. (cd
  2. /usr/local/src/zookeeper
  3. &&
  4. git
  5. checkout: Checkout a branch to the working tree.
  6. release-3.5.5 ): The latest tag to base the branch from.

How do I build the Zookeeper source code?

Build Zookeeper with the configure command.

(cd /usr/local/src/zookeeper && ant package)
  1. (cd
  2. /usr/local/src/zookeeper
  3. &&
  4. ant: A platform-independent build tool for Java projects.
  5. package): Build Solr from the source code.

After compiling Zookeeper, where do I install it as a server?

Create a zookeeper directory in /srv.

sudo install -d -o $USER -g $USER /srv/zookeeper
  1. sudo
  2. install
  3. -d
  4. -o
  5. $USER
  6. -g
  7. $USER
  8. /srv is a good place to install open source software serveurs like Zookeeper that run as a service.
rsync -r /usr/local/src/zookeeper/build/zookeeper-3.5.5-SNAPSHOT/ /srv/zookeeper/
  1. rsync: a fast, versatile, remote (and local) file-copying tool.
  2. -r: Recurse into directories.
  3. /usr/local/src/zookeeper/build/zookeeper- 3.5.5 -SNAPSHOT/: The directory where the maven application was built. Don't forget the ending slash or rsync assumes it's a file inside the destination.
  4. /srv/zookeeper/: The directory where the server will be installed. It's best to always write directories with a trailing slash in rsync for fewer surprises.

How do I configure the Zookeeper server?

Create a zoo.cfg file in the conf directory.

echo '
tickTime=2000

dataDir=/srv/zookeeper/data

admin.serverPort=10280

clientPort=10281

' | tee /srv/zookeeper/conf/zoo.cfg
  1. echo '...': Write a string to the console.
  2. tickTime=2000: The recommended length of a single tick, which is the basic time unit used by ZooKeeper, as measured in milliseconds. tickTime=2000: It is used to regulate heartbeats, and timeouts.
  3. dataDir=/srv/zookeeper/data: The location where ZooKeeper will store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database.
  4. admin.serverPort=10280: The port the embedded Jetty server listens on.
  5. clientPort=10281: The port to listen for client connections.
  6. |: Read the string into the following command.
  7. tee: Write a string to a file.
  8. /srv/zookeeper/conf/zoo.cfg: A new config file for Zookeeper.

How do I run Zookeeper all the time, when my computer starts up?

How to run Zookeeper as a systemd service.

echo '
[Unit]

Description=An open source centralized cluster manager.

After=network.target

[Service]
Type=forking
User='"$USER"'
Group='"$USER"'
ExecStart=/srv/zookeeper/bin/zkServer.sh start
Restart=on-failure

[Install]
WantedBy=multi-user.target
' | sudo tee /usr/lib/systemd/system/zookeeper.service
  1. echo '...': Write a string to the console.
  2. [Unit]: A unit configuration file whose name ends in ".service" encodes information about a process controlled and supervised by systemd.
  3. Description=...: The description of the service.
  4. After=...: The Zookeeper service will be started after the following dependencies.
  5. [Service]: Information about a service controlled and supervised by systemd.
  6. Type=forking: Because it is expected that the process configured with ExecStart= will call fork() as part of its start-up.
  7. User=...: The user as the current user that will run the service.
  8. Group=...: The group user as the current user that will run the service.
  9. ExecStart=...: The Zookeeper command that will start the service.
  10. Restart=on-failure: Restart the service if it fails.
  11. [Install]: This section is optional and is used to define the behavior or a unit if it is enabled or disabled.
  12. WantedBy=multi-user.target: When the service is enabled, a directory called multi-user.target.wants will be created within /etc/systemd/system (if not already available) and a symbolic link to the current unit will be placed within.
  13. |: Read the string into the following command.
  14. sudo
  15. tee: Write a string to a file.
  16. /usr/lib/systemd/system/zookeeper.service: A new systemd service file to write to for Zookeeper.

How does the system know about the new service?

Reload the systemd daemon.

sudo systemctl daemon-reload
  1. sudo
  2. systemctl: Controls the systemd system and service manager.
  3. daemon-reload: Reload the configuration file of a systemd unit.

How do I enable the Zookeeper service?

Use the systemctl enable command.

sudo systemctl enable zookeeper
  1. sudo
  2. systemctl
  3. enable: Enable one or more unit files or unit file instances.
  4. zookeeper: Enable the Zookeeper service to start when the computer starts.

How do I start the Zookeeper service?

Use the systemctl start command.

sudo systemctl start zookeeper
  1. sudo
  2. systemctl
  3. start: Start one or more services.
  4. zookeeper: Start the Zookeeper service.

How do I make sure the Zookeeper service started successfully?

Use the systemctl status command.

sudo systemctl status zookeeper
  1. sudo
  2. systemctl
  3. status: Check the status of one or more services.
  4. zookeeper: Check the status of the Zookeeper service.

And just like that, your Zookeeper server is ready for client to connect and begin clustering. In future lessons we will connect a search engine, as well as your web applications to Zookeeper to allow them to scale.

To review:

Monday
June 3 2019 How do I try out clustered configuration, requests, events and shared data sources in development? Install Zookeeper from the source code. By Christopher Tate
Questions Answers
How do I install the dependencies for Zookeeper? Build the dependencies with yum.
Where do I put the Zookeeper source code? Create a zookeeper directory in /usr/local/src.
How do I download the Zookeeper source code? Clone the source code with the git command.
How do I pick a recent version of Zookeeper? List all the tags in the git repository.
How do I switch versions of the Zookeeper source code? Checkout the git tag.
How do I build the Zookeeper source code? Build Zookeeper with the ant command.
After compiling Zookeeper, where do I install it as a server? Create a zookeeper directory in /srv.
How do I configure the Zookeeper server? Create a zoo.cfg file in the conf directory.
How do I run Zookeeper all the time, when my computer starts up? How to run Zookeeper as a systemd service.
How does the system know about the new service? Reload the systemd daemon.
How do I enable the Zookeeper service? Use the systemctl enable command.
How do I start the Zookeeper service? Use the systemctl start command.
How do I make sure the Zookeeper service started successfully? Use the systemctl status command.

Previous and next articles.

Don't give up on your dreams. You can do hard things!

Share this story.

Let's get connected.
Up to the top.