Last active
August 29, 2015 14:19
-
-
Save myui/9b0b2bfc7c1737be3e9b to your computer and use it in GitHub Desktop.
Init.d script for DataNode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Licensed to the Apache Software Foundation (ASF) under one or more | |
# contributor license agreements. See the NOTICE file distributed with | |
# this work for additional information regarding copyright ownership. | |
# The ASF licenses this file to You under the Apache License, Version 2.0 | |
# (the "License"); you may not use this file except in compliance with | |
# the License. You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
# Starts a Hadoop HDFS DataNode | |
# | |
# chkconfig: 2345 90 20 | |
# description: Hadoop HDFS DataNode | |
source /etc/profile.d/hadoop26-env.sh | |
source /etc/profile.d/jdk.sh | |
source /etc/init.d/functions | |
source ${HADOOP_HOME}/etc/hadoop/hadoop-env.sh | |
ulimit -l 2097152 | |
mkdir -p /mnt/disk{1,2}/hadoop/dfs/dn | |
mkdir -p /mnt/disk{1,2}/hadoop/mapred/local | |
chown -R hadoop.hadoop /mnt/disk{1,2}/hadoop | |
mkdir -p /var/run/hadoop-hdfs | |
chown -R hadoop.hadoop /var/run/hadoop-hdfs | |
RETVAL=0 | |
PIDFILE="${HADOOP_PID_DIR}/hadoop-hdfs-datanode.pid" | |
desc="Hadoop HDFS DataNode daemon" | |
start() { | |
mkdir -p /var/run/hadoop-hdfs | |
echo -n $"Starting $desc (hadoop-datanode): " | |
daemon -u hadoop ${HADOOP_HOME}/sbin/hadoop-daemon.sh --config "${HADOOP_CONF_DIR}" start datanode | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch /var/lock/hadoop-datanode | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $desc (hadoop-datanode): " | |
daemon -u hadoop ${HADOOP_HOME}/sbin/hadoop-daemon.sh --config "${HADOOP_CONF_DIR}" stop datanode | |
RETVAL=$? | |
sleep 5 | |
echo | |
[ $RETVAL -eq 0 ] && rm -f /var/lock/hadoop-datanode $PIDFILE | |
} | |
restart() { | |
stop | |
start | |
} | |
checkstatus(){ | |
echo $"$desc $(status -p $PIDFILE)" | |
RETVAL=$? | |
} | |
condrestart(){ | |
[ -e /var/lock/hadoop-datanode ] && restart || : | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
checkstatus | |
;; | |
restart) | |
restart | |
;; | |
condrestart) | |
condrestart | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart|condrestart}" | |
exit 1 | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo ln -sf /lib/lsb/init-functions /etc/init.d/functions
sudo apt-get install daemon