here is the docker file
FROM java:8
MAINTAINER Jia Zhai <[email protected]>
RUN apt-get update
RUN apt-get install -y wget
RUN apt-get install -y unzip
RUN mkdir -p /opt
RUN cd /opt
RUN wget https://github.com/twitter/distributedlog/releases/download/0.3.51-RC1/distributedlog-service-3ff9e33fa577f50eebb8ee971ddb265c971c3717.zip
RUN unzip distributedlog-service-3ff9e33fa577f50eebb8ee971ddb265c971c3717.zip
RUN mkdir -p /opt/dl_all
RUN mv distributedlog-service /opt/dl_all/
ENV ZK_URL master.mesos:2181
ENV bookiePort 3181
# all execute-able bin, download from distributed_log
WORKDIR /opt/dl_all
# After container up, Following instructions to build bookie cluster
# http://distributedlog.incubator.apache.org/docs/latest/deployment/cluster.html
COPY /entry_point.sh .
ENTRYPOINT ./entry_point.sh
Here is the entry_point.sh
#!/bin/bash
PORT0=${PORT0:-$bookiePort}
ZK_URL=${ZK_URL:-127.0.0.1:2181}
echo "bookie service port0 is $PORT0 "
echo "ZK_URL is $ZK_URL"
cp /opt/dl_all/distributedlog-service/conf/bookie.conf.template /opt/dl_all/distributedlog-service/conf/bookie.conf
sed -i 's/3181/'$PORT0'/' /opt/dl_all/distributedlog-service/conf/bookie.conf
sed -i "s/localhost:2181/${ZK_URL}/" /opt/dl_all/distributedlog-service/conf/bookie.conf
sed -i 's|journalDirectory=/tmp/data/bk/journal|journalDirectory=/bk/journal|' /opt/dl_all/distributedlog-service/conf/bookie.conf
sed -i 's|ledgerDirectories=/tmp/data/bk/ledgers|ledgerDirectories=/bk/ledgers|' /opt/dl_all/distributedlog-service/conf/bookie.conf
sed -i 's|indexDirectories=/tmp/data/bk/ledgers|indexDirectories=/bk/index|' /opt/dl_all/distributedlog-service/conf/bookie.conf
#Format bookie metadata in zookeeper, the command should be run only once, because this command will clear all the data in zk.
#Re-create all the needed metadata dir in zk is OK, if they exisited before.
FIRST_BOOKIE=0
retString=`/opt/dl_all/distributedlog-service/bin/dlog zkshell $ZK_URL stat /messaging/bookkeeper/ledgers/available/readonly 2>&1`
echo $retString | grep "not exist"
if [ $? -eq 0 ]; then
echo "bookkeeper metadata not be formated before, do the format. zk dir: /messaging/bookkeeper/ledgers"
/opt/dl_all/distributedlog-service/bin/dlog zkshell $ZK_URL create /messaging ''
/opt/dl_all/distributedlog-service/bin/dlog zkshell $ZK_URL create /messaging/bookkeeper ''
/opt/dl_all/distributedlog-service/bin/dlog zkshell $ZK_URL create /messaging/bookkeeper/ledgers ''
BOOKIE_CONF=/opt/dl_all/distributedlog-service/conf/bookie.conf /opt/dl_all/distributedlog-service/bin/dlog bkshell metaformat -f -n
FIRST_BOOKIE=1
else
echo "bookkeeper metadata be formated before, no need format"
fi
echo "format the bookie"
# format bookie
echo "Y" | BOOKIE_CONF=/opt/dl_all/distributedlog-service/conf/bookie.conf /opt/dl_all/distributedlog-service/bin/dlog bkshell bookieformat
echo "start a new bookie"
# start bookie,
SERVICE_PORT=$PORT0 /opt/dl_all/distributedlog-service/bin/dlog-daemon.sh start bookie --conf /opt/dl_all/distributedlog-service/conf/bookie.conf
if [ $FIRST_BOOKIE -eq 1 ]; then
echo "this is the first Bookie, could create dl namespace here"
/opt/dl_all/distributedlog-service/bin/dlog admin bind -dlzr $ZK_URL -dlzw $ZK_URL -s $ZK_URL -bkzr $ZK_URL -l /messaging/bookkeeper/ledgers -i false -r true -c distributedlog://$ZK_URL/messaging/distributedlog/mynamespace
else
echo "this is not the first Bookie"
fi
echo "start a while to keep docker alive"
while true; do sleep 3600; done
Content type
Image
Digest
Size
339.2 MB
Last updated
over 9 years ago
docker pull zhaijia/nbookie