Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms


apache_zookeeper (17) Versions 1.2.0

Installs/Configures Apache Zookeeper

cookbook 'apache_zookeeper', '~> 1.2.0'
cookbook 'apache_zookeeper', '~> 1.2.0', :supermarket
knife cookbook site install apache_zookeeper
knife cookbook site download apache_zookeeper

Apache Zookeeper Cookbook

Cookbook Version Build Status

Installs and configures Apache Zookeeper.

View the Change Log to see what has changed.


  • CentOS
  • Ubuntu


Using the default attributes will setup a single Zookeeper server in standalone mode.

If you are wanting to setup Zookeeper in a multi-server cluster make sure to fill out the node["apache_zookeeper"]["servers"] like this,

node["apache_zookeeper"]["servers"] = ["", "","]

The array should include a value per server and can be any of the following values,

  • FQDN - node['fqdn']
  • Host Name - node['hostname']
  • Machine Name - node['machinename']
  • Any network interface - node["network"]["interfaces"][..]
  • EC2 Host Name - node['ec2']['public_hostname']
  • EC2 IP Address - node['ec2']['public_ipv4']

This array is used to configure/calculate the server ids for each zookeeper.

You can also provide the server ids yourself by including values for the attributes node["apache_zookeeper"]["zoo.cfg"]["server.[ID]"]. If this is done you don't have to provide the node["apache_zookeeper"]["servers"] attribute.

What does the installation look like

By default the installation will look like,

zkCli | /usr/bin/zkCli  - The Zookeeper cli binary command
/opt/zookeeper/current/*        - All of Zookeeper's files (config, binaries, logs...)
/var/opt/zookeeper/logs - Zookeeper log information
/var/opt/zookeeper/data - Zookeeper data
/etc/init.d/zookeeper   - An init.d script to start/stop zookeeper. You can use service
                        zookeeper [start|stop|restart|status] instead

Unique Quorum and Leader Election Ports

It is possible to provide unique quorum and leader election ports in a few different ways.

node["apache_zookeeper"]["servers"] = ["host1", "host2", "host3"]
node["apache_zookeeper"]["follower_port"] = 2888
node["apache_zookeeper"]["election_port"] = 3888


node["apache_zookeeper"]["servers"] = ["host1:2888:3888", "host2:2888:3888", "host3:2888:3888"]


node["apache_zookeeper"]["zoo.cfg"]["server.1"] = "host1:2888:3888"
node["apache_zookeeper"]["zoo.cfg"]["server.2"] = "host2:2888:3888"
node["apache_zookeeper"]["zoo.cfg"]["server.3"] = "host3:2888:3888"

Environment Variables

Should note that the and other various scripts provided by zookeeper taken in various environment variables to tweak runtime settings. Here are some,

  • ZOO_LOG_DIR : Overwrites log4j zookeeper.log.file. Defaults to . if not set which is why we provide a default value for it to the node["apache_zookeeper"]["log_directory"] value.
  • ZOO_LOG4J_PROP : Overwrites log4j zookeeper.root.logger. Defaults to 'INFO, CONSOLE' if not set which is why we provide a default value for it 'INFO,CONSOLE,ROLLINGFILE'
  • JMXDISABLE : Disables jmx. Defaults to enabling JMX. To disable set to any value
  • SERVER_JVMFLAGS : JVM flags for the server process


  • default: Installs, configures and runs zookeeper as a service
  • install: Installs zookeeper
  • configure: Configures zookeeper
  • service: Runs zookeeper


  • node["apache_zookeeper"]["install_java"] : If you want to use the java cookbook to install java (default=true)
  • node["apache_zookeeper"]["user"] : The user that owns the Zookeeper installation (default="zookeeper")
  • node["apache_zookeeper"]["group"] : The group that owns the Zookeeper installation (default="zookeeper")
  • node["apache_zookeeper"]["env_vars"] : The environment variables set for the zookeeper user (default={"ZOO_LOG_DIR" => node["apache_zookeeper"]["log_dir"], "ZOO_LOG4J_PROP" => "'INFO, CONSOLE, ROLLINGFILE'"})
  • node["apache_zookeeper"]["servers"] : The array of fqdn/hostnames/ips for the zookeeper servers in the cluster (default=[])
  • node["apache_zookeeper"]["follower_port"] : The port used by zookeeper followers (default=2888)
  • node["apache_zookeeper"]["election_port"] : The port used for zookeeper elections (default=3888)
  • node["apache_zookeeper"]["version"] : The version of Zookeeper to install (default="3.4.6")
  • node["apache_zookeeper"]["mirror"] : The URL to the mirror that hosts the zookeeper binary (default=
  • node["apache_zookeeper"]["binary_url"] : The full binary url of Zookeeper. If you override this value make sure to provide a valid and up to date value for node["apache_zookeeper"]["version"] (default=File.join node["apache_zookeeper"]["mirror"], "zookeeper-#{node["apache_zookeeper"]["version"]}", "zookeeper-#{node["apache_zookeeper"]["version"]}.tar.gz")
  • node["apache_zookeeper"]["init_style"] : The style of script to use for running the zookeeper service. Currently only supports init. (default = init)
  • node["apache_zookeeper"]["install_dir"] : The base directory Zookeeper should be installed into (default="/opt/zookeeper")
  • node["apache_zookeeper"]["local_state_dir"] : The base directory for all of Zookeepers local state (data, logs)
  • node["apache_zookeeper"]["data_dir"] : The data directory for Zookeeper (default="#{node["apache_zookeeper"]["local_state_dir"]}/data")
  • node["apache_zookeeper"]["log_dir"] : The log directory for Zookeeper (default="#{node["apache_zookeeper"]["local_state_dir"]}/logs")
  • node["apache_zookeeper"]["bin_dir"] : The bind directory for Zookeeper (default="#{node["apache_zookeeper"]["install_dir"]}/current/bin")
  • node["apache_zookeeper"]["config_dir"] : The config directory for Zookeeper (default="#{node["apache_zookeeper"]["install_dir"]}/current/config")
  • node["apache_zookeeper"]["zoo.cfg"][*] : The key/values set for the zoo.cfg config file (see attributes file for defaults)
  • node["apache_zookeeper"][""][*] : The key/values set for the config file (see attributes file for defaults)
  • node['apache_zookeeper']['install']['type'] : Type of zookeeper installation. Can be source or package
  • node['apache_zookeeper']['package']['version'] : Default nil. Set if you need not the latest version.

Dependent cookbooks

ulimit >= 0.0.0
java >= 0.0.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

Change Log

1.2.0 - 08-04-2017

  • [Feature] Issue-48 : Package installation support

1.1.1 - 05-24-2017

  • [Bug] Issue-47 : binary_url doesn't adhere to version or mirror

1.1.0 - 05-24-2017

  • [Enhancement] Issue-45 : Running service status with the correct user
  • [Bug] Issue-40 : init.d scripts have the CONFIG path hardcoded.

1.0.1 - 09-23-2016

  • [Bug] Issue-43 : Readme references "binary_url", but the cookbook doesn't seem to actually have that

1.0.0 - 12-11-2015

  • [Feature] Issue-38 : Provide recipes for install/configure/service
  • [Feature] Issue-37 : Support different init styles
  • [Enhancement] Issue-36 : Remove xml-simple
  • [Bug] Issue-27 : Package daemon is missing
  • [Enhancement] Issue-25 : zookeeper as system user

0.5.0 - 06-23-2015

  • [Enhancement] Issue-24 : Fix up tests
  • [Enhancement] Issue-23 : Recipe downgrades java to 1.6
  • [Enhancement] Issue-20 : Add test zkcli works
  • [Enhancement] Issue-13 : Use ulimit cookbook

0.4.0 - 10-20-2014

  • [Enhancement] Issue-19 : Documentation update for default ports
  • [Enhancement] Issue-18 : Match any IP address, not just the default

0.3.2 - 09-09-2014

0.3.1 - 09-09-2014

  • [Bug] Issue-14 : attributes? not a method -- affects ec2 provisioning

0.3.0 - 08-21-2014

  • [Enhancement] Issue-10 : Additional attribute tweaks

0.2.2 - 08-21-2014

  • [Bug] Issue-11 : Release without PaxHeaders

0.2.1 - 07-24-2014

  • [Enhancement] Issue-9 : Set zookeeper log directory by default
  • [Bug] Issue-8 : Client port is always appended to hosts
  • [Enhancement] Issue-2 : Add tests

0.2.0 - 07-15-2014

  • [Feature] Issue-7 : Additional attributes

0.1.3 - 07-12-2014

0.1.2 - 06-30-2014

  • [Bug] Issue-5 : Init script does not support chkconfig

0.1.1 - 06-21-2014

  • [Bug] Issue-4 : Metadata does not include java depends

0.1.0 - 06-21-2014

  • [Feature] Issue-1 : Initial Cookbook

Collaborator Number Metric

1.2.0 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric

1.2.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of, and your repo must contain a file

Foodcritic Metric

1.2.0 passed this metric

License Metric

1.2.0 passed this metric

No Binaries Metric

1.2.0 passed this metric

Publish Metric

1.2.0 passed this metric

Supported Platforms Metric

1.2.0 passed this metric

Testing File Metric

1.2.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of, and your repo must contain a file

Version Tag Metric

1.2.0 passed this metric