Skip to content
This repository has been archived by the owner on Apr 8, 2021. It is now read-only.

cakesolutions/puppet-zookeeper

 
 

Repository files navigation

#puppet-zookeeper

Puppet Forge Build Status

A puppet receipt for Apache Zookeeper. ZooKeeper is a high-performance coordination service for maintaining configuration information, naming, providing distributed synchronization, and providing group services.

Requirements

  • Puppet 2.7, Puppet 3.x
  • Ruby 1.8.7, 1.9.3, 2.0.0, 2.1.x
  • binary package of ZooKeeper

Basic Usage:

class { 'zookeeper': }

Cluster setup

When running ZooKeeper in the distributed mode each node must have unique ID (1-255). The easiest way how to setup multiple ZooKeepers, is by using Hiera.

hiera/host/zk1.example.com.yaml:

zookeeper::id: '1'

hiera/host/zk2.example.com.yaml:

zookeeper::id: '2'

hiera/host/zk3.example.com.yaml:

zookeeper::id: '3'

A ZooKeeper quorum should consist of odd number of nodes (usually 3 or 5). For defining a quorum it is enough to list all IP addresses of all its members.

class { 'zookeeper':
  servers => ['192.168.1.1', '192.168.1.2', '192.168.1.3']
}

Currently, first ZooKeeper in the array above, will be assigned ID = 1. This would produce following configuration:

server.1=192.168.1.1:2888:3888
server.2=192.168.1.2:2888:3888
server.3=192.168.1.3:2888:3888

where first port is election_port and second one leader_port. Both ports could be customized for each ZooKeeper instance.

class { 'zookeeper':
  election_port => 2889,
  leader_port   => 3889,
  servers       => ['192.168.1.1', '192.168.1.2', '192.168.1.3']
}

Observers

Observers were introduced in ZooKeeper 3.3.0. To enable this feature simply state which of ZooKeeper servers are observing:

class { 'zookeeper':
  servers   => ['192.168.1.1', '192.168.1.2', '192.168.1.3', '192.168.1.4', '192.168.1.5'],
  observers => ['192.168.1.4', '192.168.1.5']
}

Setting IP address

If $::ipaddress is not your public IP (e.g. you are using Docker) make sure to setup correct IP:

class { 'zookeeper':
  client_ip => $::ipaddress_eth0
}

or in Hiera:

zookeeper::client_ip: "%{::ipaddress_eth0}"

This is a workaround for a a Facter issue.

Parameters

  • id - cluster-unique zookeeper's instance id (1-255)
  • datastore
  • datalogstore - specifying this configures the dataLogDir Zookeeper config values and allows for transaction logs to be stored in a different location, improving IO performance
  • log_dir
  • purge_interval - automatically will delete zookeeper logs (available since 3.4.0)
  • snap_retain_count - number of snapshots that will be kept after purging (since 3.4.0)
  • min_session_timeout - the minimum session timeout in milliseconds that the server will allow the client to negotiate. Defaults to 2 times the tickTime (since 3.3.0)
  • max_session_timeout - the maximum session timeout in milliseconds that the server will allow the client to negotiate. Defaults to 20 times the tickTime (since 3.3.0)

and many others, see the init.pp file for more details.

If your distribution has multiple packages for ZooKeeper, you can provide all package names as an array.

class { 'zookeeper':
  packages => ['zookeeper', 'zookeeper-java']
}

Hiera Support

All parameters could be defined in hiera files, e.g. common.yaml, Debian.yaml or zookeeper.yaml:

zookeeper::id: 1
zookeeper::client_port: 2181
zookeeper::datastore: '/var/lib/zookeeper'
zookeeper::datalogstore: '/disk2/zookeeper'

Cloudera package

In Cloudera distribution ZooKeeper package does not provide init scripts (same as in Debian). Package containing init scripts is called zookeeper-server and the service as well. Moreover there's initialization script which should be called after installation. So, the configuration might look like this:

class { 'zookeeper':
  packages             => ['zookeeper', 'zookeeper-server'],
  service_name         => 'zookeeper-server',
  initialize_datastore => true
}

Managing repository

For RedHat family curretly we support also managing an yum repo. It can be enabled with repo parameter:

class { 'zookeeper':
  repo => 'cloudera'
}

Java installation

Default: false

By changing these two parameters you can ensure, that given Java package will be installed before ZooKeeper packages.

class { 'zookeeper':
  install_java => true,
  java_package => 'openjdk-7-jre-headless'
}

Install

Librarian (recommended)

For puppet-librarian just add to Puppetfile

from Forge:

mod 'deric-zookeeper'

latest (development) version from GitHub

mod 'deric-zookeeper', git: 'git://github.com/deric/puppet-zookeeper.git'

submodules

If you are versioning your puppet conf with git just add it as submodule, from your repository root:

git submodule add git://github.com/deric/puppet-zookeeper.git modules/zookeeper

Dependencies

  • stdlib > 2.3.3 - function ensure_resources is required

Supported platforms

  • Debian/Ubuntu
    • Debian 6 Squeeze: you can get ZooKeeper package from Wheezy or Sid repo.
    • Debian 7 Wheezy: available in apt repository
  • RedHat/CentOS/Fedora

Tested on:

  • Debian 6 Squeeze, 7 Wheezy
  • Ubuntu 12.04.03 LTS, 14.04
  • CentOS 6

Packages

No packages published

Languages

  • Ruby 47.5%
  • Puppet 38.9%
  • HTML 13.6%