hadoop-namenode 2.2 KB

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