-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstart-accumulo
executable file
·105 lines (87 loc) · 2.57 KB
/
start-accumulo
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
#!/bin/bash
rewrite() {
cat $1 | \
sed \
-e "s#@ZOOKEEPERS@#${ZOOKEEPERS}#" \
-e "s#@HDFS_VOLUMES@#${HDFS_VOLUMES}#" \
-e "s#@SECRET@#${SECRET}#" \
-e "s#@INSTANCE_NAME@#${INSTANCE_NAME}#" \
-e "s#@MEMORY_MAPS_MAX@#${MEMORY_MAPS_MAX}#" \
-e "s#@CACHE_DATA_SIZE@#${CACHE_DATA_SIZE}#" \
-e "s#@CACHE_INDEX_SIZE@#${CACHE_INDEX_SIZE}#" \
-e "s#@SORT_BUFFER_SIZE@#${SORT_BUFFER_SIZE}#" \
-e "s#@WALOG_MAX_SIZE@#${WALOG_MAX_SIZE}#" \
> $1.tmp
mv -f $1.tmp $1
}
# Default memory allocations
MEMORY_MAPS_MAX=${MEMORY_MAPS_MAX:-8M}
CACHE_DATA_SIZE=${CACHE_DATA_SIZE:-2M}
CACHE_INDEX_SIZE=${CACHE_INDEX_SIZE:-2M}
SORT_BUFFER_SIZE=${SORT_BUFFER_SIZE:-5M}
WALOG_MAX_SIZE=${WALOG_MAX_SIZE:-5M}
MY_IP=$(/usr/sbin/ifconfig | grep 'inet[^6]' | awk '{print $2}' |
sed 's/addr://' | grep -v 127.0.0.1 | grep -v 0.0.0.0 |
head -n 1)
echo My IP is ${MY_IP}.
MY_HOSTNAME=${MY_HOSTNAME:-${MY_IP}}
if [ "${MY_HOSTNAME}" == MY_IP ]
then
MY_HOSTNAME=${MY_IP}
fi
ZOOKEEPERS=${ZOOKEEPERS:-zookeeper:2181}
HDFS_VOLUMES=${HDFS_VOLUMES:-hdfs://hadoop:9000/accumulo}
NAMENODE_URI=${NAMENODE_URI:-hdfs://hadoop:9000/}
INSTANCE_NAME=${INSTANCE_NAME:-accumulo}
SECRET=${SECRET:-accumulo}
ACCUMULO_INIT=${ACCUMULO_INIT:-${HDFS_VOLUMES}_init}
DAEMONS=${DAEMONS:-manager,gc,monitor,tserver}
rewrite ${ACCUMULO_HOME}/conf/accumulo-env.sh
rewrite ${ACCUMULO_HOME}/conf/accumulo.properties
rewrite ${ACCUMULO_HOME}/conf/accumulo-client.properties
(
echo "<configuration>"
echo " <property>"
echo " <name>fs.defaultFS</name>"
echo " <value>${NAMENODE_URI}</value>"
echo " </property>"
echo "</configuration>"
) > /usr/local/hadoop/etc/hadoop/core-site.xml
# Loop until Accumulo is successfully initialised.
while true
do
/usr/local/hadoop/bin/hdfs dfs -ls /
if [ $? -ne 0 ]
then
echo 'Hadoop not up?'
sleep 10
continue
fi
/usr/local/hadoop/bin/hdfs dfs -ls ${ACCUMULO_INIT}
if [ $? -eq 0 ]
then
echo 'Accumulo has been initialised.'
break
fi
echo 'Accumulo not initialised.'
echo 'Initialise accumulo...'
/usr/local/accumulo/bin/accumulo init --instance-name ${INSTANCE_NAME} \
--password ${SECRET} --clear-instance-name --upload-accumulo-props --force
if [ $? -ne 0 ]
then
echo Initialisation failed.
sleep 1
continue
fi
/usr/local/hadoop/bin/hdfs dfs -put /dev/null ${ACCUMULO_INIT}
done
for v in $(echo ${DAEMONS} |
sed -e 's/,/ /g' -e "s/MY_IP/${MY_IP}/g")
do
echo "Starting $v..."
/usr/local/accumulo/bin/accumulo-service $v start
done
while true
do
sleep 100000
done