sudo
yum
install
redhat-lsb.x86_64
# This script is permitted for Hadoop user.
$sudo su - hadoop
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 | |
. /lib/lsb/init-functions | |
[ -e /etc/sysconfig/flume ] && . /etc/sysconfig/flume | |
STATUS_RUNNING=0 | |
STATUS_DEAD=1 | |
STATUS_DEAD_AND_LOCK=2 | |
STATUS_NOT_RUNNING=3 | |
ERROR_PROGRAM_NOT_INSTALLED=5 | |
FLUME_LOG_DIR=/home/hadoop/flume/logs | |
FLUME_CONF_DIR=/home/hadoop/flume/conf | |
FLUME_RUN_DIR=/home/hadoop/var/run/flume | |
FLUME_HOME=/home/hadoop/flume | |
FLUME_USER=hadoop | |
FLUME_LOCK_DIR="/home/hadoop/var/lock/subsys/" | |
LOCKFILE="${FLUME_LOCK_DIR}/flume-ng-agent" | |
desc="Flume NG agent daemon" | |
#FLUME_CONF_FILE=${FLUME_CONF_FILE:-${FLUME_CONF_DIR}/flume.conf} | |
FLUME_CONF_FILE=${FLUME_CONF_DIR}/flume.conf | |
EXEC_PATH=${FLUME_HOME}/bin/flume-ng | |
FLUME_PID_FILE=${FLUME_RUN_DIR}/flume-ng-agent.pid | |
# These directories may be tmpfs and may or may not exist | |
# depending on the OS (ex: /var/lock/subsys does not exist on debian/ubuntu) | |
for dir in "$FLUME_RUN_DIR" "$FLUME_LOCK_DIR"; do | |
[ -d "${dir}" ] || install -d -m 0755 -o $FLUME_USER -g $FLUME_USER ${dir} | |
done | |
#DEFAULT_FLUME_AGENT_NAME="agent1" | |
#FLUME_AGENT_NAME=${FLUME_AGENT_NAME:-${DEFAULT_FLUME_AGENT_NAME}} | |
# | |
FLUME_AGENT_NAME="agent1" | |
start() { | |
[ -x $exec ] || exit $ERROR_PROGRAM_NOT_INSTALLED | |
pidofproc -p $FLUME_PID_FILE java > /dev/null | |
status=$? | |
if [ "$status" -eq "$STATUS_RUNNING" ]; then | |
exit 0 | |
fi | |
log_success_msg "Starting $desc (flume-ng-agent): " | |
# /bin/su -s /bin/bash -c "/bin/bash -c 'echo \$\$ >${FLUME_PID_FILE} && exec ${EXEC_PATH} agent --no-reload-conf --conf $FLUME_CONF_DIR --conf-file $FLUME_CONF_FILE --name $FLUME_AGENT_NAME >>${FLUME_LOG_DIR}/flume.init.log 2>&1' &" $FLUME_USER | |
/bin/bash -c "/bin/bash -c 'echo \$\$ >${FLUME_PID_FILE} && exec ${EXEC_PATH} agent --no-reload-conf --conf $FLUME_CONF_DIR --conf-file $FLUME_CONF_FILE --name $FLUME_AGENT_NAME >>${FLUME_LOG_DIR}/flume.init.log 2>&1' &" | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && touch $LOCKFILE | |
return $RETVAL | |
} | |
stop() { | |
if [ ! -e $FLUME_PID_FILE ]; then | |
log_failure_msg "Flume agent is not running" | |
exit 0 | |
fi | |
FLUME_PID=`cat $FLUME_PID_FILE` | |
if [ -n $FLUME_PID ]; then | |
kill -TERM ${FLUME_PID} &>/dev/null | |
status=0 | |
while [ $status -eq 0 ]; do | |
sleep 1 | |
ps -p $FLUME_PID &> /dev/null | |
status=$? | |
done | |
fi | |
rm -f $LOCKFILE $FLUME_PID_FILE | |
log_success_msg "Stopping $desc (flume-ng-agent): " | |
return 0 | |
} | |
checkstatus(){ | |
pidofproc -p $FLUME_PID_FILE java > /dev/null | |
status=$? | |
case "$status" in | |
$STATUS_RUNNING) | |
log_success_msg "Flume NG agent is running" | |
;; | |
$STATUS_DEAD) | |
log_failure_msg "Flume NG agent is dead and pid file exists" | |
;; | |
$STATUS_DEAD_AND_LOCK) | |
log_failure_msg "Flume NG agent is dead and lock file exists" | |
;; | |
$STATUS_NOT_RUNNING) | |
log_failure_msg "Flume NG agent is not running" | |
;; | |
*) | |
log_failure_msg "Flume NG agent status is unknown" | |
;; | |
esac | |
return $status | |
} | |
condrestart(){ | |
[ -e ${LOCKFILE} ] && restart || : | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
checkstatus | |
;; | |
restart) | |
restart | |
;; | |
condrestart|try-restart) | |
condrestart | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart}" | |
exit 1 | |
esac | |
exit $RETVAL |
good work done and keep update more.i like your information's and that is very much useful for readers.
ReplyDeleteHadoop Training in Chennai
Big data training in chennai
hadoop training in velachery
JAVA Training in Chennai
Python Training in Chennai
Selenium Training in Chennai
Hadoop training in chennai
Big data training in chennai
big data course in chennai