hadoop-datanode 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. start() {
  27. echo -n $"Starting $desc (hadoop-datanode): "
  28. daemon --user hdfs ${HADOOP_PREFIX}/sbin/hadoop-daemon.sh --config "${HADOOP_CONF_DIR}" start datanode
  29. RETVAL=$?
  30. echo
  31. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hadoop-datanode
  32. return $RETVAL
  33. }
  34. stop() {
  35. echo -n $"Stopping $desc (hadoop-datanode): "
  36. daemon --user hdfs ${HADOOP_PREFIX}/sbin/hadoop-daemon.sh --config "${HADOOP_CONF_DIR}" stop datanode
  37. RETVAL=$?
  38. sleep 5
  39. echo
  40. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/hadoop-datanode $PIDFILE
  41. }
  42. restart() {
  43. stop
  44. start
  45. }
  46. checkstatus(){
  47. status -p $PIDFILE ${JAVA_HOME}/bin/java
  48. RETVAL=$?
  49. }
  50. condrestart(){
  51. [ -e /var/lock/subsys/hadoop-datanode ] && restart || :
  52. }
  53. case "$1" in
  54. start)
  55. start
  56. ;;
  57. stop)
  58. stop
  59. ;;
  60. status)
  61. checkstatus
  62. ;;
  63. restart)
  64. restart
  65. ;;
  66. condrestart)
  67. condrestart
  68. ;;
  69. *)
  70. echo $"Usage: $0 {start|stop|status|restart|condrestart}"
  71. exit 1
  72. esac
  73. exit $RETVAL