Ubic::Service::ZooKeeper - running ZooKeeper as Ubic service
version 0.02
use Ubic::Service::ZooKeeper; return Ubic::Service::ZooKeeper->new({ config => { clientPort => 2181, dataDir => '/var/lib/zookeeper', tickTime => 2000, initLimit => 10, syncLimit => 5, servers => { 1 => { server => "host1:2888:3888" }, 2 => { server => "host2:2888:3888" }, 3 => { server => "host3:2888:3888" }, }, } myid => 1, ubic_log => '/var/log/zookeeper/ubic.log', stdout => '/var/log/zookeeper/stdout.log', stderr => '/var/log/zookeeper/stderr.log', user => 'zookeeper', gen_cfg => '/etc/zookeeper/conf/zoo.cfg', pidfile => '/tmp/zookeeper.pid', java_cp => '/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:' . '/usr/share/java/xercesImpl.jar:' . '/usr/share/java/xmlParserAPIs.jar:/usr/share/java/zookeeper.jar', });
This module intends for running/shutdown ZooKeeper as a Ubic service. It accepts all config options of ZooKeeper (and some other options), generates config and myid file and run it.
Typically you need to use only new() method, but you can find below description of some another methods also.
new()
new($params)
Creates new ZooKeeper service. $params is hashref with different ZooKeeper and Ubic params. The keys are following:
$params
All ZooKeeper config related params holds in config key. You can place here any ZooKeeper config keys and their values.
config
You can find description for this params on http://zookeeper.apache.org/doc/trunk/zookeeperAdmin.html#sc_configuration. You should specify at least clientPort, dataDir and tickTime for successful configuration (defaults are 2181, /var/lib/zookeeper and 2000).
clientPort
dataDir
tickTime
2181
/var/lib/zookeeper
2000
Two exceptions are here.
The first is a servers param. It combines server.x and weight.x params from ZooKeeper config. servers is a hashref where key is a number of server and the values is a hashref with keys server and weight.
servers
server.x
weight.x
server
weight
The second is a groups param. It is a hashref, where the key is a number of group and the value is arrayref with server numbers in this group.
groups
Id of the current server in ZooKeeper cluster. Based on this value Ubic::Service::Zookeeper will create myid file in dataDir.
myid
Default is 1.
1
Coderef for checking ZooKeeper status. Takes current instance of Ubic::Service::ZooKeeper as a first param.
Ubic::Service::ZooKeeper
Default implemetation uses ruok ZooKeeper command.
ruok
User name that will be used as real and effective user identifier during exec of ZooKeeper.
Path to ubic log.
Path to stdout log.
ZooKeeper supports custom logging setup, so in most cases this param is meaningless.
Path to stderr log.
Pidfile for Ubic::Daemon module.
Ubic::Daemon
If not specified it is a /tmp/zookeeper.<clientPort>.pid.
Generated ZooKeeper config file name.
If not specified it is a /tmp/zoo.<clientPort>.cfg.
Path to java binary. Default is just "java", so your PATH should be setted properly in default case.
java
PATH
Java classpath. See ZooKeeper administration guide for more information.
It should be something like this: /usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr/share/java/xercesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/zookeeper.jar
Enable JMX. Default is 1
Enable JMX only locally. Default is 0.
0
Where zookeeper will place own logs. Default is /var/log/zookeeper.
/var/log/zookeeper
Log4j properties for ZooKeeper. Default is INFO,ROLLINGFILE.
INFO,ROLLINGFILE
Main ZooKeeper class. Default is org.apache.zookeeper.server.quorum.QuorumPeerMain. Typically you don't need to redefine this param.
org.apache.zookeeper.server.quorum.QuorumPeerMain
Some additional options that you want to pass to java.
create_cfg_file()
Generates .cfg file basing on constuctor params.
create_myid_file()
Generates myid file basing on myid and dataDir params in constructor.
pidfile()
Get pidfile name.
http://zookeeper.apache.org/doc/trunk/zookeeperAdmin.html
Ubic
Yury Zavarin <yury.zavarin@gmail.com>
This software is copyright (c) 2011 by Yury Zavarin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Ubic::Service::ZooKeeper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ubic::Service::ZooKeeper
CPAN shell
perl -MCPAN -e shell install Ubic::Service::ZooKeeper
For more information on module installation, please visit the detailed CPAN module installation guide.