forked from LLNL/magpie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
magpie-setup-zookeeper
executable file
·166 lines (139 loc) · 5.26 KB
/
magpie-setup-zookeeper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
#############################################################################
# Copyright (C) 2013 Lawrence Livermore National Security, LLC.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Albert Chu <chu11@llnl.gov>
# LLNL-CODE-644248
#
# This file is part of Magpie, scripts for running Hadoop on
# traditional HPC systems. For details, see <URL>.
#
# Magpie is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Magpie is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Magpie. If not, see <http://www.gnu.org/licenses/>.
#############################################################################
# This script sets up configuration files for jobs. For the most
# part, it shouldn't be editted. See job submission files for
# configuration details.
if [ "${ZOOKEEPER_SETUP}" != "yes" ]
then
exit 0
fi
source ${MAGPIE_SCRIPTS_HOME}/magpie-submission-convert
source ${MAGPIE_SCRIPTS_HOME}/magpie-common-exports
source ${MAGPIE_SCRIPTS_HOME}/magpie-common-functions
# zookeepernoderank set if succeed and it's a Zookeeper slave
# Zookeeper master is only for setup/teardown management, not for actual Zookeeper
if ! Magpie_am_I_a_zookeeper_node
then
exit 0
fi
if [ "${zookeepernoderank}X" != "X" ]
then
if [ "${ZOOKEEPER_FILESYSTEM_MODE}" == "networkfs" ]
then
# Setup node directory per node
zookeeperdatadirpath="${ZOOKEEPER_DATA_DIR}/node-${zookeepernoderank}"
zookeeperdatadirpathsubst=`echo "${zookeeperdatadirpath}" | sed "s/\\//\\\\\\\\\//g"`
mkdir -p ${zookeeperdatadirpath}
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${zookeeperdatadirpath}"
exit 1
fi
elif [ "${ZOOKEEPER_FILESYSTEM_MODE}" == "local" ]
then
zookeeperdatadirpath="${ZOOKEEPER_DATA_DIR}"
zookeeperdatadirpathsubst=`echo "${zookeeperdatadirpath}" | sed "s/\\//\\\\\\\\\//g"`
mkdir -p ${zookeeperdatadirpath}
if [ $? -ne 0 ] ; then
echo "mkdir failed making ${zookeeperdatadirpath}"
exit 1
fi
fi
echo "${zookeepernoderank}" > ${zookeeperdatadirpath}/myid
if [ "${ZOOKEEPER_TICKTIME}X" != "X" ]
then
zookeeperticktime=${ZOOKEEPER_TICKTIME}
else
zookeeperticktime=2000
fi
if [ "${ZOOKEEPER_INITLIMIT}X" != "X" ]
then
zookeeperinitlimit=${ZOOKEEPER_INITLIMIT}
else
zookeeperinitlimit=10
fi
if [ "${ZOOKEEPER_SYNCLIMIT}X" != "X" ]
then
zookeepersynclimit=${ZOOKEEPER_SYNCLIMIT}
else
zookeepersynclimit=5
fi
fi
#
# Get config files for setup
#
if [ "${ZOOKEEPER_CONF_FILES}X" == "X" ]
then
zookeeperconffiledir=${MAGPIE_SCRIPTS_HOME}/conf
else
zookeeperconffiledir=${ZOOKEEPER_CONF_FILES}
fi
pre_zookeepercfg=${zookeeperconffiledir}/zoo.cfg
pre_zookeeperenvsh=${zookeeperconffiledir}/zookeeper-env.sh
pre_log4jproperties=${zookeeperconffiledir}/zookeeper.log4j.properties
post_zookeepercfg=${ZOOKEEPER_CONF_DIR}/zoo.cfg
post_zookeeperenvsh=${ZOOKEEPER_CONF_DIR}/zookeeper-env.sh
post_log4jproperties=${ZOOKEEPER_CONF_DIR}/log4j.properties
#
# Setup Zookeeper configuration files and environment files
#
cp ${pre_zookeepercfg} ${post_zookeepercfg}
ZOOKEEPER_THIS_HOST=`hostname`
sed -i \
-e "s/ZOOKEEPERDATADIR/${zookeeperdatadirpathsubst}/g" \
-e "s/ZOOKEEPERTICKTIME/${zookeeperticktime}/g" \
-e "s/ZOOKEEPERINITLIMIT/${zookeeperinitlimit}/g" \
-e "s/ZOOKEEPERSYNCLIMIT/${zookeepersynclimit}/g" \
-e "s/ZOOKEEPERCLIENTPORT/${ZOOKEEPER_CLIENT_PORT}/g" \
-e "s/ZOOKEEPERHOST/${ZOOKEEPER_THIS_HOST}/g" \
${post_zookeepercfg}
zookeepernodes=`cat ${ZOOKEEPER_CONF_DIR}/zookeeper_slaves`
servercount=1
for zookeepernode in ${zookeepernodes}
do
echo "server.${servercount}=${zookeepernode}:${ZOOKEEPER_PEER_PORT}:${ZOOKEEPER_LEADER_PORT}" >> ${post_zookeepercfg}
servercount=$((servercount+1))
done
zookeeperjavahomesubst=`echo "${JAVA_HOME}" | sed "s/\\//\\\\\\\\\//g"`
zookeeperlogdirsubst=`echo "${ZOOKEEPER_LOG_DIR}" | sed "s/\\//\\\\\\\\\//g"`
zookeeperconfdirsubst=`echo "${ZOOKEEPER_CONF_DIR}" | sed "s/\\//\\\\\\\\\//g"`
zookeeperhomesubst=`echo "${ZOOKEEPER_HOME}" | sed "s/\\//\\\\\\\\\//g"`
magpiescriptshome=`echo "${MAGPIE_SCRIPTS_HOME}" | sed "s/\\//\\\\\\\\\//g"`
cp ${pre_zookeeperenvsh} ${post_zookeeperenvsh}
sed -i \
-e "s/MAGPIEJAVAHOME/${zookeeperjavahomesubst}/g" \
-e "s/ZOOKEEPERLOGDIR/${zookeeperlogdirsubst}/g" \
-e "s/ZOOKEEPERCONFDIR/${zookeeperconfdirsubst}/g" \
-e "s/ZOOKEEPERHOME/${zookeeperhomesubst}/g" \
-e "s/MAGPIESCRIPTSHOME/${magpiescriptshome}/g" \
${post_zookeeperenvsh}
if [ "${MAGPIE_REMOTE_CMD:-ssh}" != "ssh" ]
then
echo "export ZOOKEEPER_SSH_CMD=\"${MAGPIE_REMOTE_CMD}\"" >> ${post_zookeeperenvsh}
fi
if [ "${MAGPIE_REMOTE_CMD_OPTS}X" != "X" ]
then
echo "export ZOOKEEPER_SSH_OPTS=\"${MAGPIE_REMOTE_CMD_OPTS}\"" >> ${post_zookeeperenvsh}
fi
cp ${pre_log4jproperties} ${post_log4jproperties}
exit 0