NAME
Ubic::Service::ZooKeeper - running ZooKeeper as Ubic service
VERSION
version 0.02
SYNOPSIS
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',
});
DESCRIPTION
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.
METHODS
Typically you need to use only new()
method, but you can find below description of some another methods also.
new($params)
-
Creates new ZooKeeper service.
$params
is hashref with different ZooKeeper and Ubic params. The keys are following:- config (optional)
-
All ZooKeeper config related params holds in
config
key. You can place here any ZooKeeper config keys and their values.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
andtickTime
for successful configuration (defaults are2181
,/var/lib/zookeeper
and2000
).Two exceptions are here.
The first is a
servers
param. It combinesserver.x
andweight.x
params from ZooKeeper config.servers
is a hashref where key is a number of server and the values is a hashref with keysserver
andweight
.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. - myid (optional)
-
Id of the current server in ZooKeeper cluster. Based on this value Ubic::Service::Zookeeper will create
myid
file indataDir
.Default is
1
. - status (optional)
-
Coderef for checking ZooKeeper status. Takes current instance of
Ubic::Service::ZooKeeper
as a first param.Default implemetation uses
ruok
ZooKeeper command. - user (optional)
-
User name that will be used as real and effective user identifier during exec of ZooKeeper.
- ubic_log (optional)
-
Path to ubic log.
- stdout (optional)
-
Path to stdout log.
ZooKeeper supports custom logging setup, so in most cases this param is meaningless.
- stderr (optional)
-
Path to stderr log.
- pidfile (optional)
-
Pidfile for
Ubic::Daemon
module.If not specified it is a /tmp/zookeeper.<clientPort>.pid.
- gen_cfg (optional)
-
Generated ZooKeeper config file name.
If not specified it is a /tmp/zoo.<clientPort>.cfg.
- java (optional)
-
Path to
java
binary. Default is just "java", so yourPATH
should be setted properly in default case. - java_cp (optional)
-
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
- jmx_enable (optional)
-
Enable JMX. Default is
1
- jmx_local_only (optional)
-
Enable JMX only locally. Default is
0
. - zoo_log_dir (optional)
-
Where zookeeper will place own logs. Default is
/var/log/zookeeper
. - zoo_log4j_prop (optional)
-
Log4j properties for ZooKeeper. Default is
INFO,ROLLINGFILE
. - zoo_main_class (optional)
-
Main ZooKeeper class. Default is
org.apache.zookeeper.server.quorum.QuorumPeerMain
. Typically you don't need to redefine this param. - java_opts (optional)
-
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 onmyid
anddataDir
params in constructor. pidfile()
-
Get pidfile name.
SEE ALSO
http://zookeeper.apache.org/doc/trunk/zookeeperAdmin.html
AUTHOR
Yury Zavarin <yury.zavarin@gmail.com>
COPYRIGHT AND LICENSE
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.