hadoop-namenode 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 namenode
  18. #
  19. # chkconfig: 2345 90 10
  20. # description: Hadoop namenode
  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-namenode.pid"
  25. desc="Hadoop namenode daemon"
  26. export HADOOP_PREFIX=${HADOOP_PREFIX:-/usr}
  27. start() {
  28. echo -n $"Starting $desc (hadoop-namenode): "
  29. daemon --user hdfs ${HADOOP_PREFIX}/sbin/hadoop-daemon.sh --config "${HADOOP_CONF_DIR}" start namenode $1
  30. RETVAL=$?
  31. echo
  32. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hadoop-namenode
  33. return $RETVAL
  34. }
  35. upgrade() {
  36. start -upgrade
  37. }
  38. stop() {
  39. echo -n $"Stopping $desc (hadoop-namenode): "
  40. daemon --user hdfs ${HADOOP_PREFIX}/sbin/hadoop-daemon.sh --config "${HADOOP_CONF_DIR}" stop namenode
  41. RETVAL=$?
  42. sleep 5
  43. echo
  44. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/hadoop-namenode $PIDFILE
  45. }
  46. checkstatus(){
  47. status -p $PIDFILE ${JAVA_HOME}/bin/java
  48. RETVAL=$?
  49. }
  50. restart() {
  51. stop
  52. start
  53. }
  54. condrestart(){
  55. [ -e /var/lock/subsys/hadoop-namenode ] && restart || :
  56. }
  57. format() {
  58. daemon --user hdfs ${HADOOP_PREFIX}/bin/hadoop namenode -format
  59. }
  60. case "$1" in
  61. start)
  62. start
  63. ;;
  64. upgrade)
  65. upgrade
  66. ;;
  67. format)
  68. format
  69. ;;
  70. stop)
  71. stop
  72. ;;
  73. status)
  74. checkstatus
  75. ;;
  76. restart)
  77. restart
  78. ;;
  79. condrestart|try-restart)
  80. condrestart
  81. ;;
  82. *)
  83. echo $"Usage: $0 {start|stop|status|restart|try-restart|upgrade}"
  84. exit 1
  85. esac
  86. exit $RETVAL