hadoop-datanode 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # Starts a Hadoop datanode
  18. #
  19. # chkconfig: 2345 90 10
  20. # description: Hadoop datanode
  21. source /etc/rc.d/init.d/functions
  22. source /etc/default/hadoop-env.sh
  23. RETVAL=0
  24. PIDFILE="${HADOOP_PID_DIR}/hadoop-hdfs-datanode.pid"
  25. desc="Hadoop datanode daemon"
  26. HADOOP_PREFIX="/usr"
  27. start() {
  28. echo -n $"Starting $desc (hadoop-datanode): "
  29. if [ -n "$HADOOP_SECURE_DN_USER" ]; then
  30. daemon ${HADOOP_PREFIX}/sbin/hadoop-daemon.sh --config "${HADOOP_CONF_DIR}" start datanode
  31. else
  32. daemon --user hdfs ${HADOOP_PREFIX}/sbin/hadoop-daemon.sh --config "${HADOOP_CONF_DIR}" start datanode
  33. fi
  34. RETVAL=$?
  35. echo
  36. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hadoop-datanode
  37. return $RETVAL
  38. }
  39. stop() {
  40. echo -n $"Stopping $desc (hadoop-datanode): "
  41. if [ -n "$HADOOP_SECURE_DN_USER" ]; then
  42. daemon ${HADOOP_PREFIX}/sbin/hadoop-daemon.sh --config "${HADOOP_CONF_DIR}" stop datanode
  43. else
  44. daemon --user hdfs ${HADOOP_PREFIX}/sbin/hadoop-daemon.sh --config "${HADOOP_CONF_DIR}" stop datanode
  45. fi
  46. RETVAL=$?
  47. sleep 5
  48. echo
  49. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/hadoop-datanode $PIDFILE
  50. }
  51. restart() {
  52. stop
  53. start
  54. }
  55. checkstatus(){
  56. status -p $PIDFILE ${JAVA_HOME}/bin/java
  57. RETVAL=$?
  58. }
  59. condrestart(){
  60. [ -e /var/lock/subsys/hadoop-datanode ] && restart || :
  61. }
  62. case "$1" in
  63. start)
  64. start
  65. ;;
  66. stop)
  67. stop
  68. ;;
  69. status)
  70. checkstatus
  71. ;;
  72. restart)
  73. restart
  74. ;;
  75. condrestart)
  76. condrestart
  77. ;;
  78. *)
  79. echo $"Usage: $0 {start|stop|status|restart|condrestart}"
  80. exit 1
  81. esac
  82. exit $RETVAL