blob: a192147da93af667528ed95cd7896f9723a67a37 (
plain)
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
|
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
extra_commands="format"
DAEMON=${SVCNAME/hadoop-hdfs-}
depend() {
use dns net
}
chk_initd() {
if [ "${DAEMON}" == "${SVCNAME}" ]; then
eerror "You should not run this init script, use the provided aliases"
eend 1
return 1
fi
}
init_env_vars() {
if [ -n "${HADOOP_CONF_DIR}" ]; then
export HADOOP_CONF_DIR=${HADOOP_CONF_DIR}
else
export HADOOP_CONF_DIR=/etc/hadoop/conf
fi
# source hadoop-env.sh for configuration
if test -f ${HADOOP_CONF_DIR}/hadoop-env.sh; then
. ${HADOOP_CONF_DIR}/hadoop-env.sh
fi
export JAVA_HOME=${JAVA_HOME}
# fixed
export HADOOP_PREFIX=/usr/lib/hadoop
export HADOOP_LIBEXEC_DIR=/usr/lib/hadoop/libexec/
export HADOOP_PID_DIR=/var/run/hadoop-hdfs
export HADOOP_LOG_DIR=/var/log/hadoop-hdfs
# user defined, in hadoop-env.sh
if [ "${HADOOP_IDENT_STRING}" == "" ]; then
export HADOOP_IDENT_STRING=$HADOOP_IDENT_STRING
else
export HADOOP_IDENT_STRING=hdfs
fi
# Determine if we're starting a secure datanode, and if so, redefine appropriate variables
if [ -n "$HADOOP_SECURE_DN_USER" ] && [ "${DAEMON}" == "datanode" ]; then
DN_USER=root
IDENT_USER=${HADOOP_SECURE_DN_USER}
else
DN_USER=hdfs
IDENT_USER=${DN_USER}
fi
# check for the required paths
checkpath -d -m 0755 -o hdfs:hdfs "${HADOOP_PID_DIR}"
}
start() {
chk_initd || exit 1
ebegin "Starting Cloudera Hadoop ${DAEMON}"
init_env_vars
start-stop-daemon --start --quiet --wait 3000 \
--pidfile ${HADOOP_PID_DIR}/hadoop-${IDENT_USER}-${DAEMON}.pid \
-u ${DN_USER} -x ${HADOOP_PREFIX}/sbin/hadoop-daemon.sh -- \
--config ${HADOOP_CONF_DIR} start ${DAEMON}
eend $?
}
stop() {
chk_initd || exit 1
ebegin "Stopping Cloudera Hadoop ${DAEMON}"
init_env_vars
start-stop-daemon --stop --quiet \
--pidfile ${HADOOP_PID_DIR}/hadoop-${IDENT_USER}-${DAEMON}.pid
eend $?
}
format() {
if [ "${DAEMON}" == "namenode" ]; then
ebegin "Formatting Cloudera Hadoop ${DAEMON}"
init_env_vars
su ${DN_USER} --preserve-environment -- hdfs --config ${HADOOP_CONF_DIR} namenode -format
else
eerror "The format command is only available for the namenode daemon"
eend 1
fi
}
|