diff options
author | Andre Barboza <bmg.andre@gmail.com> | 2016-01-12 06:53:41 +0700 |
---|---|---|
committer | Robby Workman <rworkman@slackbuilds.org> | 2016-01-12 21:58:11 -0600 |
commit | aa59088973d5d87c7ed9875b91bb6a202735e1bd (patch) | |
tree | f1e890587772b3871107620de37c4b53a989ce02 /system | |
parent | 5bfc33d67c95c024cddbc2da901a13e5ffaebd5c (diff) | |
download | slackbuilds-aa59088973d5d87c7ed9875b91bb6a202735e1bd.tar.gz |
system/zookeeper: Added (distributed coordination server).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system')
-rw-r--r-- | system/zookeeper/README | 16 | ||||
-rw-r--r-- | system/zookeeper/doinst.sh | 28 | ||||
-rw-r--r-- | system/zookeeper/java.env | 19 | ||||
-rw-r--r-- | system/zookeeper/rc.zookeeper | 42 | ||||
-rw-r--r-- | system/zookeeper/slack-desc | 19 | ||||
-rw-r--r-- | system/zookeeper/zoo.cfg | 28 | ||||
-rw-r--r-- | system/zookeeper/zookeeper-env.sh | 4 | ||||
-rw-r--r-- | system/zookeeper/zookeeper.SlackBuild | 140 | ||||
-rw-r--r-- | system/zookeeper/zookeeper.info | 10 |
9 files changed, 306 insertions, 0 deletions
diff --git a/system/zookeeper/README b/system/zookeeper/README new file mode 100644 index 0000000000..a752f3834e --- /dev/null +++ b/system/zookeeper/README @@ -0,0 +1,16 @@ +ZooKeeper is a centralized service for maintaining configuration information, +naming, providing distributed synchronization, and providing group services. +All of these kinds of services are used in some form or another by distributed +applications. Each time they are implemented there is a lot of work that goes +into fixing the bugs and race conditions that are inevitable. Because of the +difficulty of implementing these kinds of services, applications initially +usually skimp on them ,which make them brittle in the presence of change and +difficult to manage. Even when done correctly, different implementations of +these services lead to management complexity when the applications are +deployed. + +This script requires a 'zookeeper' user/group to exist before running. +The recommended UID/GID is 322. You can create these like so: + +groupadd -g 322 zookeeper +useradd -u 322 -g 322 -c "Zookeeper user" -d /var/lib/zookeeper -s /bin/sh zookeeper diff --git a/system/zookeeper/doinst.sh b/system/zookeeper/doinst.sh new file mode 100644 index 0000000000..265749411d --- /dev/null +++ b/system/zookeeper/doinst.sh @@ -0,0 +1,28 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + rm $NEW + fi +} + +preserve_perms() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ -e $OLD ]; then + cp -a $OLD ${NEW}.incoming + cat $NEW > ${NEW}.incoming + mv ${NEW}.incoming $NEW + fi + config $NEW +} + +preserve_perms etc/rc.d/rc.zookeeper.new +preserve_perms etc/zookeeper/configuration.xsl.new +preserve_perms etc/zookeeper/log4j.properties.new +preserve_perms etc/zookeeper/zoo_sample.cfg.new +preserve_perms etc/zookeeper/zoo.cfg.new +preserve_perms etc/zookeeper/java.env.new +preserve_perms etc/zookeeper/zookeeper-env.sh.new diff --git a/system/zookeeper/java.env b/system/zookeeper/java.env new file mode 100644 index 0000000000..efe1e4af77 --- /dev/null +++ b/system/zookeeper/java.env @@ -0,0 +1,19 @@ +#!/bin/bash + +# See the following page for extensive details on setting +# up the JVM to accept JMX remote management: +# http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html +# by default we allow local JMX connections +# export JMXLOCALONLY=false + +# Disable ZooKeeper JMX +# export JMXDISABLE=true + +# export JMXPORT= +# export JMXAUTH=false +# export JMXSSL=false +# export JMXLOG4J=true + +# JVM flags +# export SERVER_JVMFLAGS= +# export CLIENT_JVMFLAGS= diff --git a/system/zookeeper/rc.zookeeper b/system/zookeeper/rc.zookeeper new file mode 100644 index 0000000000..4753036060 --- /dev/null +++ b/system/zookeeper/rc.zookeeper @@ -0,0 +1,42 @@ +#!/bin/sh +# Start/stop/restart Apache Zookeeper daemon + +USER=zookeeper + +zookeeper_start(){ + sudo -u ${USER} sh -c "/usr/bin/zkServer start" +} + +zookeeper_stop() { + sudo -u ${USER} sh -c "/usr/bin/zkServer stop" +} + +zookeeper_restart() { + sudo -u ${USER} sh -c "/usr/bin/zkServer restart" +} + +zookeeper_status() { + sudo -u ${USER} sh -c "/usr/bin/zkServer status" +} + +print_usage() { + echo "usage $0 start|stop|restart|status" +} + +case "$1" in + 'start') + zookeeper_start + ;; + 'stop') + zookeeper_stop + ;; + 'restart') + zookeeper_restart + ;; + 'status') + zookeeper_status + ;; + *) + print_usage + ;; +esac diff --git a/system/zookeeper/slack-desc b/system/zookeeper/slack-desc new file mode 100644 index 0000000000..5f8d3afcba --- /dev/null +++ b/system/zookeeper/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +zookeeper: zookeeper (Highly reliable distributed coordination server) +zookeeper: +zookeeper: ZooKeeper is a centralized service for maintaining configuration +zookeeper: information, naming, providing distributed synchronization, and +zookeeper: providing group services. +zookeeper: +zookeeper: Homepage: https://zookeeper.apache.org/ +zookeeper: +zookeeper: +zookeeper: +zookeeper: diff --git a/system/zookeeper/zoo.cfg b/system/zookeeper/zoo.cfg new file mode 100644 index 0000000000..9d0a53ca7c --- /dev/null +++ b/system/zookeeper/zoo.cfg @@ -0,0 +1,28 @@ +# The number of milliseconds of each tick +tickTime=2000 +# The number of ticks that the initial +# synchronization phase can take +initLimit=10 +# The number of ticks that can pass between +# sending a request and getting an acknowledgement +syncLimit=5 +# the directory where the snapshot is stored. +# do not use /tmp for storage, /tmp here is just +# example sakes. +dataDir=/var/lib/zookeeper +# the port at which the clients will connect +clientPort=2181 +# the maximum number of client connections. +# increase this if you need to handle more clients +#maxClientCnxns=60 +# +# Be sure to read the maintenance section of the +# administrator guide before turning on autopurge. +# +# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance +# +# The number of snapshots to retain in dataDir +#autopurge.snapRetainCount=3 +# Purge task interval in hours +# Set to "0" to disable auto purge feature +#autopurge.purgeInterval=1 diff --git a/system/zookeeper/zookeeper-env.sh b/system/zookeeper/zookeeper-env.sh new file mode 100644 index 0000000000..5a5372147e --- /dev/null +++ b/system/zookeeper/zookeeper-env.sh @@ -0,0 +1,4 @@ +#! /bin/bash + +export ZOO_LOG_DIR=/var/log/zookeeper +export ZOO_LOG4J_PROP=INFO,ROLLINGFILE diff --git a/system/zookeeper/zookeeper.SlackBuild b/system/zookeeper/zookeeper.SlackBuild new file mode 100644 index 0000000000..8194e21668 --- /dev/null +++ b/system/zookeeper/zookeeper.SlackBuild @@ -0,0 +1,140 @@ +#!/bin/sh + +# Slackware build script for Apache Zookeeper + +# Copyright 2016 Andre Barboza, Belo Horizonte - Brazil +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PRGNAM=zookeeper +VERSION=${VERSION:-3.4.6} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} + +ZOOKEEPER_USER=${ZOOKEEPER_USER:-zookeeper} +ZOOKEEPER_UID=${ZOOKEEPER_UID:-322} +ZOOKEEPER_GROUP=${ZOOKEEPER_GROUP:-zookeeper} +ZOOKEEPER_GID=${ZOOKEEPER_GID:-322} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i486 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +bailout() { + echo " You must have a $ZOOKEEPER_USER user and $ZOOKEEPER_GROUP group to run this script. " + echo " Something like this should suffice for most systems: " + echo " # groupadd -g $ZOOKEEPER_GID $ZOOKEEPER_GROUP " + echo " # useradd -u $ZOOKEEPER_UID -g $ZOOKEEPER_GID -c \"Zookeeper user\" -d /var/lib/zookeeper -s /bin/sh $ZOOKEEPER_USER " + echo " Giving /bin/sh as $ZOOKEEPER_USER shell is important as the init script will try tu 'su -' to it." + exit 1 +} + +# Bail if user and/or group isn't valid on your system +# uid=322 is suggested to avoid conflicts with other SBo packages, +# but it's your call: http://slackbuilds.org/uid_gid.txt +if ! grep -q "^$ZOOKEEPER_USER:" /etc/passwd; then + bailout +elif ! grep -q "^$ZOOKEEPER_GROUP:" /etc/group; then + bailout +fi + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "x86_64" ]; then + LIBDIRSUFFIX="64" +else + LIBDIRSUFFIX="" +fi + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +tar xvf $CWD/$PRGNAM-$VERSION.tar.gz +cd $PRGNAM-$VERSION +chown -R root:root . +find -L . \ + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + +mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/$PRGNAM/lib +cp lib/*.jar $PKG/usr/lib${LIBDIRSUFFIX}/$PRGNAM/lib +cp $PRGNAM-$VERSION.jar $PKG/usr/lib${LIBDIRSUFFIX}/$PRGNAM/ + +mkdir -p $PKG/usr/bin $PKG/usr/lib${LIBDIRSUFFIX}/$PRGNAM/bin +install -m 775 bin/zkCleanup.sh \ + bin/zkCli.sh \ + bin/zkEnv.sh \ + bin/zkServer.sh \ + $PKG/usr/lib${LIBDIRSUFFIX}/$PRGNAM/bin + +( + cd $PKG/usr/lib${LIBDIRSUFFIX}/$PRGNAM/bin + sed -i "s|^ZOOBIN=\"\$(dirname \"\${ZOOBIN}\")\"|ZOOBIN=\"/usr/lib${LIBDIRSUFFIX}/$PRGNAM/bin\"|" *.sh +) + +( + cd $PKG/usr/bin + ln -s ../lib${LIBDIRSUFFIX}/$PRGNAM/bin/zkServer.sh zkServer + ln -s ../lib${LIBDIRSUFFIX}/$PRGNAM/bin/zkCli.sh zkCli + ln -s ../lib${LIBDIRSUFFIX}/$PRGNAM/bin/zkCleanup.sh zkCleanup +) + +install -dm 750 ${PKG}/var/log/$PRGNAM +install -dm 750 ${PKG}/var/lib/$PRGNAM +chown -R $ZOOKEEPER_USER:$ZOOKEEPER_GROUP $PKG/var/{lib,log}/$PRGNAM + +install -dm 750 ${PKG}/etc/$PRGNAM +install -m 644 conf/configuration.xsl $PKG/etc/$PRGNAM/configuration.xsl.new +install -m 644 conf/log4j.properties $PKG/etc/$PRGNAM/log4j.properties.new +install -m 644 conf/zoo_sample.cfg $PKG/etc/$PRGNAM/zoo_sample.cfg.new +install -m 644 $CWD/zoo.cfg $PKG/etc/$PRGNAM/zoo.cfg.new +install -m 644 $CWD/java.env $PKG/etc/$PRGNAM/java.env.new +install -m 644 $CWD/zookeeper-env.sh $PKG/etc/$PRGNAM/zookeeper-env.sh.new +chown -R $ZOOKEEPER_USER:$ZOOKEEPER_GROUP $PKG/etc/$PRGNAM +( + cd $PKG/usr/lib${LIBDIRSUFFIX}/$PRGNAM + ln -s /etc/zookeeper conf +) + +mkdir -p ${PKG}/etc/rc.d +install -o root -g root -m 644 $CWD/rc.$PRGNAM $PKG/etc/rc.d/rc.${PRGNAM}.new + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a CHANGES.txt LICENSE.txt NOTICE.txt README.txt README_packaging.txt docs/* \ + $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/system/zookeeper/zookeeper.info b/system/zookeeper/zookeeper.info new file mode 100644 index 0000000000..4f08112065 --- /dev/null +++ b/system/zookeeper/zookeeper.info @@ -0,0 +1,10 @@ +PRGNAM="zookeeper" +VERSION="3.4.6" +HOMEPAGE="https://zookeeper.apache.org/" +DOWNLOAD="http://www.us.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz" +MD5SUM="971c379ba65714fd25dc5fe8f14e9ad1" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="jdk" +MAINTAINER="Andre Barboza" +EMAIL="bmg.andre@gmail.com" |