模拟namenode挂掉利用secondary namenode恢复

测试机器:

10.0.50.144  master  (namenode,datanode)

10.0.50.145  node1    (datanode)

10.0.50.146  node2    (datanode)

 

一、在hdfs正常启动后执行以下命令查看目录/tmp 内容

[hbase@master sbin]$ hadoop fs -ls /tmp
Found 10 items
drwxr-xr-x   - hbase supergroup          0 2015-09-11 03:12 /tmp/arch
drwx------   - hbase supergroup          0 2015-09-10 03:32 /tmp/hadoop-yarn
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:32 /tmp/input
-rw-r--r--   3 hbase supergroup  153512879 2015-09-10 09:49 /tmp/jdk-7u79-linux-x64.gz
-rw-r--r--   3 hbase supergroup  312043744 2015-09-17 06:44 /tmp/mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:33 /tmp/out
drwxr-xr-x   - hbase supergroup          0 2015-09-22 02:54 /tmp/test1
drwxr-xr-x   - hbase supergroup          0 2015-09-23 09:49 /tmp/test2
drwxr-xr-x   - hbase supergroup          0 2015-09-23 10:44 /tmp/test3
drwxr-xr-x   - hbase supergroup          0 2015-09-23 11:14 /tmp/test4

在checkpoint执行之前,创建一个目录/tmp/test5

[hbase@master sbin]$ hadoop fs -mkdir /tmp/test5
[hbase@master sbin]$ hadoop fs -ls /tmp         
Found 11 items
drwxr-xr-x   - hbase supergroup          0 2015-09-11 03:12 /tmp/arch
drwx------   - hbase supergroup          0 2015-09-10 03:32 /tmp/hadoop-yarn
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:32 /tmp/input
-rw-r--r--   3 hbase supergroup  153512879 2015-09-10 09:49 /tmp/jdk-7u79-linux-x64.gz
-rw-r--r--   3 hbase supergroup  312043744 2015-09-17 06:44 /tmp/mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:33 /tmp/out
drwxr-xr-x   - hbase supergroup          0 2015-09-22 02:54 /tmp/test1
drwxr-xr-x   - hbase supergroup          0 2015-09-23 09:49 /tmp/test2
drwxr-xr-x   - hbase supergroup          0 2015-09-23 10:44 /tmp/test3
drwxr-xr-x   - hbase supergroup          0 2015-09-23 11:14 /tmp/test4
drwxr-xr-x   - hbase supergroup          0 2015-09-24 02:21 /tmp/test5

查看namenode的进程号,并执行kill

[hbase@master sbin]$ jps
20008 NameNode
20122 DataNode
20539 Jps
[hbase@master sbin]$ kill 20008
[hbase@master sbin]$ jps
20122 DataNode
20556 Jps

此时namenode日志里报错线上namenode已经shutdown

2015-09-24 02:21:58,561 ERROR org.apache.hadoop.hdfs.server.namenode.NameNode: RECEIVED SIGNAL 15: SIGTERM
2015-09-24 02:21:58,565 INFO org.apache.hadoop.hdfs.server.namenode.NameNode: SHUTDOWN_MSG: 
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at master/10.0.52.144
************************************************************/

此时集群已经不可用

[hbase@master sbin]$ hadoop fs -ls /tmp
ls: Call From master/10.0.52.144 to master:9000 failed on connection exception: java.net.ConnectException: Connection refused; For more details see:  http://wiki.apache.org/hadoop/ConnectionRefused

人为模拟namenode目录丢失

[hbase@master sbin]$ cd /app/HadoopData/
[hbase@master HadoopData]$ ll
total 8
drwxrwxr-x 4 hbase hbase 4096 Sep 24 10:20 dfs
drwxr-xr-x 5 hbase hbase 4096 Sep 23 19:59 nm-local-dir
[hbase@master HadoopData]$ cd dfs
[hbase@master dfs]$ ll
total 8
drwx------ 3 hbase hbase 4096 Sep 24 10:22 data
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:21 name
[hbase@master dfs]$ mv name name1
[hbase@master dfs]$ ll
total 8
drwx------ 3 hbase hbase 4096 Sep 24 10:22 data
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:21 name1

然后重新启动hdfs,namenode启动不起来,因为目录找不到了

2015-09-24 02:28:02,198 WARN org.apache.hadoop.hdfs.server.common.Storage: Storage directory /app/HadoopData/dfs/name does not exist
2015-09-24 02:28:02,200 WARN org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Encountered exception loading fsimage
org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /app/HadoopData/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible.
        at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverStorageDirs(FSImage.java:327)
        at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:215)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFSImage(FSNamesystem.java:975)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.loadFromDisk(FSNamesystem.java:681)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.loadNamesystem(NameNode.java:584)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:644)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:811)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:795)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1488)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1554)
2015-09-24 02:28:02,204 INFO org.mortbay.log: Stopped HttpServer2$SelectChannelConnectorWithSafeStartup@0.0.0.0:50070
2015-09-24 02:28:02,304 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: Stopping NameNode metrics system...
2015-09-24 02:28:02,305 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: NameNode metrics system stopped.
2015-09-24 02:28:02,305 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: NameNode metrics system shutdown complete.
2015-09-24 02:28:02,305 ERROR org.apache.hadoop.hdfs.server.namenode.NameNode: Failed to start namenode.

 

 

恢复方案一

将secondary namenode所在机器上的目录文件,打包拷贝到master上

[hbase@node1 dfs]$ ll
total 24
drwx------ 3 hbase hbase 4096 Sep 24 10:22 data
drwxrwxr-x 3 hbase hbase 4096 Sep 10 11:23 name
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:31 namesecondary
-rw-rw-r-- 1 hbase hbase 9891 Sep 24 10:33 namesecondary.tar.gz
[hbase@node1 dfs]$ 
[hbase@node1 dfs]$ scp namesecondary.tar.gz master:/app/HadoopData/dfs/

 

在master上解压后,重命名为name

[hbase@master dfs]$ tar xzvf namesecondary.tar.gz
[hbase@master dfs]$ ll
total 28
drwx------ 3 hbase hbase 4096 Sep 24 10:22 data
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:21 name1
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:31 namesecondary
-rw-rw-r-- 1 hbase hbase 9891 Sep 24 10:33 namesecondary.tar.gz
[hbase@master dfs]$ mv namesecondary name
[hbase@master dfs]$ ll
total 24
drwx------ 3 hbase hbase 4096 Sep 24 10:22 data
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:31 name
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:21 name1
-rw-rw-r-- 1 hbase hbase 9891 Sep 24 10:33 namesecondary.tar.gz

然后重新启动

[hbase@master sbin]$ ./start-dfs.sh

再次执行hadoop fs命令

[hbase@master sbin]$ jps
21888 NameNode
22008 DataNode
22251 Jps
[hbase@master sbin]$ hadoop fs -ls /tmp
Found 10 items
drwxr-xr-x   - hbase supergroup          0 2015-09-11 03:12 /tmp/arch
drwx------   - hbase supergroup          0 2015-09-10 03:32 /tmp/hadoop-yarn
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:32 /tmp/input
-rw-r--r--   3 hbase supergroup  153512879 2015-09-10 09:49 /tmp/jdk-7u79-linux-x64.gz
-rw-r--r--   3 hbase supergroup  312043744 2015-09-17 06:44 /tmp/mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:33 /tmp/out
drwxr-xr-x   - hbase supergroup          0 2015-09-22 02:54 /tmp/test1
drwxr-xr-x   - hbase supergroup          0 2015-09-23 09:49 /tmp/test2
drwxr-xr-x   - hbase supergroup          0 2015-09-23 10:44 /tmp/test3
drwxr-xr-x   - hbase supergroup          0 2015-09-23 11:14 /tmp/test4

 发现集群是恢复了,可用了,但是在最后一次checkpoint后至集群挂掉之后的操作是丢失了(/tmp/test5)

毕竟secondary namenode只保留了最近一次的fsimage.

 

 

观察namenode利用secondary namenode目录恢复时的日志

2015-09-24 02:35:02,452 INFO org.apache.hadoop.hdfs.server.namenode.FileJournalManager: Recovering unfinalized segments in /app/HadoopData/dfs/name/current
2015-09-24 02:35:02,491 INFO org.apache.hadoop.hdfs.server.namenode.FSImage: No edit log streams selected.
2015-09-24 02:35:02,642 INFO org.apache.hadoop.hdfs.server.namenode.FSImageFormatPBINode: Loading 35 INodes.
2015-09-24 02:35:02,791 INFO org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf: Loaded FSImage in 0 seconds.
2015-09-24 02:35:02,791 INFO org.apache.hadoop.hdfs.server.namenode.FSImage: Loaded image for txid 760 from /app/HadoopData/dfs/name/current/fsimage_0000000000000000760
2015-09-24 02:35:02,813 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Need to save fs image? true (staleImage=true, haEnabled=false, isRollingUpgrade=false)
2015-09-24 02:35:02,813 INFO org.apache.hadoop.hdfs.server.namenode.FSImage: Save namespace ...
2015-09-24 02:35:02,985 INFO org.apache.hadoop.hdfs.server.namenode.NNStorageRetentionManager: Going to retain 2 images with txid >= 757
2015-09-24 02:35:03,066 INFO org.apache.hadoop.hdfs.server.namenode.FSEditLog: Starting log segment at 761
2015-09-24 02:35:03,235 INFO org.apache.hadoop.hdfs.server.namenode.NameCache: initialized with 0 entries 0 lookups
2015-09-24 02:35:03,236 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Finished loading FSImage in 1028 msecs

 

 

恢复方案二

将secondary namenode所在机器上的目录文件,打包拷贝到master上

[hbase@node1 dfs]$ ll
total 24
drwx------ 3 hbase hbase 4096 Sep 24 10:22 data
drwxrwxr-x 3 hbase hbase 4096 Sep 10 11:23 name
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:31 namesecondary
-rw-rw-r-- 1 hbase hbase 9891 Sep 24 10:33 namesecondary.tar.gz
[hbase@node1 dfs]$ 
[hbase@node1 dfs]$ scp namesecondary.tar.gz master:/app/HadoopData/dfs/

 

在master上的namenode目录下创建文件夹name

[hbase@master dfs]$ mkdir name
[hbase@master dfs]$ ll
total 28
drwx------ 3 hbase hbase 4096 Sep 24 11:14 data
drwxrwxr-x 2 hbase hbase 4096 Sep 24 11:15 name
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:21 name1
drwxrwxr-x 3 hbase hbase 4096 Sep 24 11:14 name2
-rw-rw-r-- 1 hbase hbase 9891 Sep 24 10:33 namesecondary.tar.gz
[hbase@master dfs]$ tar xzvf namesecondary.tar.gz
[hbase@master dfs]$ ll
total 32
drwx------ 3 hbase hbase 4096 Sep 24 11:14 data
drwxrwxr-x 3 hbase hbase 4096 Sep 24 11:19 name
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:21 name1
drwxrwxr-x 3 hbase hbase 4096 Sep 24 11:14 name2
drwxrwxr-x 3 hbase hbase 4096 Sep 24 10:31 namesecondary
-rw-rw-r-- 1 hbase hbase 9891 Sep 24 10:33 namesecondary.tar.gz

 

执行 hadoop namenode -importCheckpoint

[hbase@master dfs]$ hadoop namenode -importCheckpoint
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

15/09/24 05:59:17 INFO namenode.NameNode: STARTUP_MSG: 
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG:   host = master/10.0.52.144
STARTUP_MSG:   args = [-importCheckpoint]
STARTUP_MSG:   version = 2.7.1
STARTUP_MSG:   classpath = /usr/local/hadoop/etc/hadoop:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/slf4j-api-1.7.10.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/servlet-api-2.5.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jersey-server-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/hadoop-annotations-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/hadoop-auth-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jsch-0.1.42.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/api-asn1-api-1.0.0-M20.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-httpclient-3.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/curator-framework-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/avro-1.7.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jaxb-impl-2.2.3-1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-logging-1.1.3.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/paranamer-2.3.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/curator-recipes-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/asm-3.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/httpclient-4.2.5.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/gson-2.2.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/activation-1.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/stax-api-1.0-2.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/zookeeper-3.4.6.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/junit-4.11.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/hamcrest-core-1.3.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-compress-1.4.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jettison-1.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/java-xmlbuilder-0.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-digester-1.8.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/apacheds-i18n-2.0.0-M15.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-beanutils-1.7.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jackson-xc-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/log4j-1.2.17.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jets3t-0.9.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-codec-1.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/mockito-all-1.8.5.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jsr305-3.0.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/netty-3.6.2.Final.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/api-util-1.0.0-M20.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-configuration-1.6.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/htrace-core-3.1.0-incubating.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jersey-core-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-collections-3.2.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-cli-1.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/apacheds-kerberos-codec-2.0.0-M15.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-io-2.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jsp-api-2.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/snappy-java-1.0.4.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-math3-3.1.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/xz-1.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jetty-util-6.1.26.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-lang-2.6.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-beanutils-core-1.8.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/xmlenc-0.52.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jetty-6.1.26.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/httpcore-4.2.5.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jaxb-api-2.2.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/commons-net-3.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/guava-11.0.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jersey-json-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/jackson-jaxrs-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/lib/curator-client-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/hadoop-nfs-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/hadoop-common-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/common/hadoop-common-2.7.1-tests.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/servlet-api-2.5.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/jersey-server-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/xml-apis-1.3.04.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/commons-daemon-1.0.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/netty-all-4.0.23.Final.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/commons-logging-1.1.3.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/asm-3.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/leveldbjni-all-1.8.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/log4j-1.2.17.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/commons-codec-1.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/jsr305-3.0.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/netty-3.6.2.Final.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/htrace-core-3.1.0-incubating.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/jersey-core-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/commons-cli-1.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/xercesImpl-2.9.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/commons-io-2.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/jetty-util-6.1.26.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/commons-lang-2.6.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/xmlenc-0.52.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/jetty-6.1.26.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/lib/guava-11.0.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/hadoop-hdfs-nfs-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/hadoop-hdfs-2.7.1-tests.jar:/usr/local/hadoop-2.7.1/share/hadoop/hdfs/hadoop-hdfs-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/servlet-api-2.5.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jersey-server-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jaxb-impl-2.2.3-1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/commons-logging-1.1.3.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/asm-3.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/leveldbjni-all-1.8.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/activation-1.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/stax-api-1.0-2.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/zookeeper-3.4.6.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/commons-compress-1.4.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jettison-1.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jersey-client-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jackson-xc-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/guice-servlet-3.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/guice-3.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/log4j-1.2.17.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/commons-codec-1.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/aopalliance-1.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/javax.inject-1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jsr305-3.0.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/netty-3.6.2.Final.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jersey-core-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/commons-collections-3.2.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/commons-cli-1.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jersey-guice-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/commons-io-2.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/xz-1.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jetty-util-6.1.26.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/commons-lang-2.6.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jetty-6.1.26.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jaxb-api-2.2.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/guava-11.0.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jersey-json-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/jackson-jaxrs-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/lib/zookeeper-3.4.6-tests.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-server-common-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-server-resourcemanager-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-api-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-server-tests-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-server-sharedcachemanager-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-registry-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-client-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-server-applicationhistoryservice-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/yarn/hadoop-yarn-common-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/jersey-server-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/hadoop-annotations-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/avro-1.7.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/paranamer-2.3.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/asm-3.2.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/leveldbjni-all-1.8.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/junit-4.11.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/hamcrest-core-1.3.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/commons-compress-1.4.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/guice-servlet-3.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/guice-3.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/log4j-1.2.17.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/aopalliance-1.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/javax.inject-1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/netty-3.6.2.Final.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/jersey-core-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/jersey-guice-1.9.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/commons-io-2.4.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/snappy-java-1.0.4.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/xz-1.0.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/hadoop-mapreduce-client-common-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-plugins-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/hadoop-mapreduce-client-shuffle-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/hadoop-mapreduce-client-app-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.1.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.1-tests.jar:/usr/local/hadoop-2.7.1/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.1.jar:/contrib/capacity-scheduler/*.jar:/usr/local/hadoop-2.7.1/contrib/capacity-scheduler/*.jar
STARTUP_MSG:   build = https://git-wip-us.apache.org/repos/asf/hadoop.git -r 15ecc87ccf4a0228f35af08fc56de536e6ce657a; compiled by 'jenkins' on 2015-06-29T06:04Z
STARTUP_MSG:   java = 1.7.0_17
************************************************************/
15/09/24 05:59:17 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT]
15/09/24 05:59:17 INFO namenode.NameNode: createNameNode [-importCheckpoint]
15/09/24 05:59:18 INFO impl.MetricsConfig: loaded properties from hadoop-metrics2.properties
15/09/24 05:59:18 INFO impl.MetricsSystemImpl: Scheduled snapshot period at 10 second(s).
15/09/24 05:59:18 INFO impl.MetricsSystemImpl: NameNode metrics system started
15/09/24 05:59:18 INFO namenode.NameNode: fs.defaultFS is hdfs://master:9000
15/09/24 05:59:18 INFO namenode.NameNode: Clients are to use master:9000 to access this namenode/service.
15/09/24 05:59:19 INFO hdfs.DFSUtil: Starting Web-server for hdfs at: http://0.0.0.0:50070
15/09/24 05:59:19 INFO mortbay.log: Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
15/09/24 05:59:19 INFO server.AuthenticationFilter: Unable to initialize FileSignerSecretProvider, falling back to use random secrets.
15/09/24 05:59:19 INFO http.HttpRequestLog: Http request log for http.requests.namenode is not defined
15/09/24 05:59:19 INFO http.HttpServer2: Added global filter 'safety' (class=org.apache.hadoop.http.HttpServer2$QuotingInputFilter)
15/09/24 05:59:19 INFO http.HttpServer2: Added filter static_user_filter (class=org.apache.hadoop.http.lib.StaticUserWebFilter$StaticUserFilter) to context hdfs
15/09/24 05:59:19 INFO http.HttpServer2: Added filter static_user_filter (class=org.apache.hadoop.http.lib.StaticUserWebFilter$StaticUserFilter) to context static
15/09/24 05:59:19 INFO http.HttpServer2: Added filter static_user_filter (class=org.apache.hadoop.http.lib.StaticUserWebFilter$StaticUserFilter) to context logs
15/09/24 05:59:19 INFO http.HttpServer2: Added filter 'org.apache.hadoop.hdfs.web.AuthFilter' (class=org.apache.hadoop.hdfs.web.AuthFilter)
15/09/24 05:59:19 INFO http.HttpServer2: addJerseyResourcePackage: packageName=org.apache.hadoop.hdfs.server.namenode.web.resources;org.apache.hadoop.hdfs.web.resources, pathSpec=/webhdfs/v1/*
15/09/24 05:59:19 INFO http.HttpServer2: Jetty bound to port 50070
15/09/24 05:59:19 INFO mortbay.log: jetty-6.1.26
15/09/24 05:59:19 WARN mortbay.log: Can't reuse /tmp/Jetty_0_0_0_0_50070_hdfs____w2cu08, using /tmp/Jetty_0_0_0_0_50070_hdfs____w2cu08_528369526129709161
15/09/24 05:59:19 INFO mortbay.log: Started HttpServer2$SelectChannelConnectorWithSafeStartup@0.0.0.0:50070
15/09/24 05:59:20 WARN namenode.FSNamesystem: !!! WARNING !!!
        The NameNode currently runs without persistent storage.
        Any changes to the file system meta-data may be lost.
        Recommended actions:
                - shutdown and restart NameNode with configured "dfs.namenode.edits.dir.required" in hdfs-site.xml;
                - use Backup Node as a persistent and up-to-date storage of the file system meta-data.
15/09/24 05:59:20 WARN namenode.FSNamesystem: Only one image storage directory (dfs.namenode.name.dir) configured. Beware of data loss due to lack of redundant storage directories!
15/09/24 05:59:20 WARN namenode.FSNamesystem: Only one namespace edits storage directory (dfs.namenode.edits.dir) configured. Beware of data loss due to lack of redundant storage directories!
15/09/24 05:59:20 INFO namenode.FSNamesystem: No KeyProvider found.
15/09/24 05:59:20 INFO namenode.FSNamesystem: fsLock is fair:true
15/09/24 05:59:20 INFO blockmanagement.DatanodeManager: dfs.block.invalidate.limit=1000
15/09/24 05:59:20 INFO blockmanagement.DatanodeManager: dfs.namenode.datanode.registration.ip-hostname-check=true
15/09/24 05:59:20 INFO blockmanagement.BlockManager: dfs.namenode.startup.delay.block.deletion.sec is set to 000:00:00:00.000
15/09/24 05:59:20 INFO blockmanagement.BlockManager: The block deletion will start around 2015 Sep 24 05:59:20
15/09/24 05:59:20 INFO util.GSet: Computing capacity for map BlocksMap
15/09/24 05:59:20 INFO util.GSet: VM type       = 64-bit
15/09/24 05:59:20 INFO util.GSet: 2.0% max memory 888.9 MB = 17.8 MB
15/09/24 05:59:20 INFO util.GSet: capacity      = 2^21 = 2097152 entries
15/09/24 05:59:20 INFO blockmanagement.BlockManager: dfs.block.access.token.enable=false
15/09/24 05:59:20 INFO blockmanagement.BlockManager: defaultReplication         = 3
15/09/24 05:59:20 INFO blockmanagement.BlockManager: maxReplication             = 512
15/09/24 05:59:20 INFO blockmanagement.BlockManager: minReplication             = 1
15/09/24 05:59:20 INFO blockmanagement.BlockManager: maxReplicationStreams      = 2
15/09/24 05:59:20 INFO blockmanagement.BlockManager: shouldCheckForEnoughRacks  = false
15/09/24 05:59:20 INFO blockmanagement.BlockManager: replicationRecheckInterval = 3000
15/09/24 05:59:20 INFO blockmanagement.BlockManager: encryptDataTransfer        = false
15/09/24 05:59:20 INFO blockmanagement.BlockManager: maxNumBlocksToLog          = 1000
15/09/24 05:59:20 INFO namenode.FSNamesystem: fsOwner             = hbase (auth:SIMPLE)
15/09/24 05:59:20 INFO namenode.FSNamesystem: supergroup          = supergroup
15/09/24 05:59:20 INFO namenode.FSNamesystem: isPermissionEnabled = true
15/09/24 05:59:20 INFO namenode.FSNamesystem: HA Enabled: false
15/09/24 05:59:20 INFO namenode.FSNamesystem: Append Enabled: true
15/09/24 05:59:20 INFO util.GSet: Computing capacity for map INodeMap
15/09/24 05:59:20 INFO util.GSet: VM type       = 64-bit
15/09/24 05:59:20 INFO util.GSet: 1.0% max memory 888.9 MB = 8.9 MB
15/09/24 05:59:20 INFO util.GSet: capacity      = 2^20 = 1048576 entries
15/09/24 05:59:20 INFO namenode.FSDirectory: ACLs enabled? false
15/09/24 05:59:20 INFO namenode.FSDirectory: XAttrs enabled? true
15/09/24 05:59:20 INFO namenode.FSDirectory: Maximum size of an xattr: 16384
15/09/24 05:59:20 INFO namenode.NameNode: Caching file names occuring more than 10 times
15/09/24 05:59:20 INFO util.GSet: Computing capacity for map cachedBlocks
15/09/24 05:59:20 INFO util.GSet: VM type       = 64-bit
15/09/24 05:59:20 INFO util.GSet: 0.25% max memory 888.9 MB = 2.2 MB
15/09/24 05:59:20 INFO util.GSet: capacity      = 2^18 = 262144 entries
15/09/24 05:59:20 INFO namenode.FSNamesystem: dfs.namenode.safemode.threshold-pct = 0.9990000128746033
15/09/24 05:59:20 INFO namenode.FSNamesystem: dfs.namenode.safemode.min.datanodes = 0
15/09/24 05:59:20 INFO namenode.FSNamesystem: dfs.namenode.safemode.extension     = 30000
15/09/24 05:59:20 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.window.num.buckets = 10
15/09/24 05:59:20 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.num.users = 10
15/09/24 05:59:20 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.windows.minutes = 1,5,25
15/09/24 05:59:20 INFO namenode.FSNamesystem: Retry cache on namenode is enabled
15/09/24 05:59:20 INFO namenode.FSNamesystem: Retry cache will use 0.03 of total heap and retry cache entry expiry time is 600000 millis
15/09/24 05:59:20 INFO util.GSet: Computing capacity for map NameNodeRetryCache
15/09/24 05:59:20 INFO util.GSet: VM type       = 64-bit
15/09/24 05:59:20 INFO util.GSet: 0.029999999329447746% max memory 888.9 MB = 273.1 KB
15/09/24 05:59:20 INFO util.GSet: capacity      = 2^15 = 32768 entries
15/09/24 05:59:20 INFO common.Storage: Lock on /app/HadoopData/dfs/name/in_use.lock acquired by nodename 24822@master
15/09/24 05:59:20 INFO namenode.FSImage: Storage directory /app/HadoopData/dfs/name is not formatted.
15/09/24 05:59:20 INFO namenode.FSImage: Formatting ...
15/09/24 05:59:20 INFO common.Storage: Lock on /app/HadoopData/dfs/namesecondary/in_use.lock acquired by nodename 24822@master
15/09/24 05:59:20 WARN namenode.FSNamesystem: !!! WARNING !!!
        The NameNode currently runs without persistent storage.
        Any changes to the file system meta-data may be lost.
        Recommended actions:
                - shutdown and restart NameNode with configured "dfs.namenode.edits.dir.required" in hdfs-site.xml;
                - use Backup Node as a persistent and up-to-date storage of the file system meta-data.
15/09/24 05:59:20 INFO namenode.FileJournalManager: Recovering unfinalized segments in /app/HadoopData/dfs/namesecondary/current
15/09/24 05:59:20 INFO namenode.FSImage: No edit log streams selected.
15/09/24 05:59:20 INFO namenode.FSImageFormatPBINode: Loading 35 INodes.
15/09/24 05:59:21 INFO namenode.FSImageFormatProtobuf: Loaded FSImage in 0 seconds.
15/09/24 05:59:21 INFO namenode.FSImage: Loaded image for txid 760 from /app/HadoopData/dfs/namesecondary/current/fsimage_0000000000000000760
15/09/24 05:59:21 WARN namenode.FSNamesystem: !!! WARNING !!!
        The NameNode currently runs without persistent storage.
        Any changes to the file system meta-data may be lost.
        Recommended actions:
                - shutdown and restart NameNode with configured "dfs.namenode.edits.dir.required" in hdfs-site.xml;
                - use Backup Node as a persistent and up-to-date storage of the file system meta-data.
15/09/24 05:59:21 INFO namenode.FileJournalManager: Recovering unfinalized segments in /app/HadoopData/dfs/name/current
15/09/24 05:59:21 INFO namenode.FSImage: Save namespace ...
15/09/24 05:59:21 INFO namenode.FSImageTransactionalStorageInspector: No version file in /app/HadoopData/dfs/name
15/09/24 05:59:21 INFO namenode.FSNamesystem: Need to save fs image? false (staleImage=false, haEnabled=false, isRollingUpgrade=false)
15/09/24 05:59:21 INFO namenode.FSEditLog: Starting log segment at 761
15/09/24 05:59:21 INFO namenode.NameCache: initialized with 0 entries 0 lookups
15/09/24 05:59:21 INFO namenode.FSNamesystem: Finished loading FSImage in 857 msecs
15/09/24 05:59:21 INFO namenode.NameNode: RPC server is binding to master:9000
15/09/24 05:59:21 INFO ipc.CallQueueManager: Using callQueue class java.util.concurrent.LinkedBlockingQueue
15/09/24 05:59:22 INFO ipc.Server: Starting Socket Reader #1 for port 9000
15/09/24 05:59:22 INFO namenode.FSNamesystem: Registered FSNamesystemState MBean
15/09/24 05:59:22 WARN namenode.FSNamesystem: !!! WARNING !!!
        The NameNode currently runs without persistent storage.
        Any changes to the file system meta-data may be lost.
        Recommended actions:
                - shutdown and restart NameNode with configured "dfs.namenode.edits.dir.required" in hdfs-site.xml;
                - use Backup Node as a persistent and up-to-date storage of the file system meta-data.
15/09/24 05:59:22 INFO namenode.LeaseManager: Number of blocks under construction: 0
15/09/24 05:59:22 INFO namenode.LeaseManager: Number of blocks under construction: 0
15/09/24 05:59:22 INFO hdfs.StateChange: STATE* Safe mode ON. 
The reported blocks 0 needs additional 20 blocks to reach the threshold 0.9990 of total blocks 20.
The number of live datanodes 0 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.
15/09/24 05:59:22 INFO blockmanagement.DatanodeDescriptor: Number of failed storage changes from 0 to 0
15/09/24 05:59:22 INFO ipc.Server: IPC Server Responder: starting
15/09/24 05:59:22 INFO ipc.Server: IPC Server listener on 9000: starting
15/09/24 05:59:22 INFO namenode.NameNode: NameNode RPC up at: master/10.0.52.144:9000
15/09/24 05:59:22 INFO namenode.FSNamesystem: Starting services required for active state
15/09/24 05:59:22 INFO blockmanagement.CacheReplicationMonitor: Starting CacheReplicationMonitor with interval 30000 milliseconds


15/09/24 06:03:22 INFO ipc.Server: IPC Server handler 1 on 9000, call org.apache.hadoop.hdfs.protocol.ClientProtocol.mkdirs from 10.0.52.144:48599 Call#2 Retry#0: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create directory /tmp/test5. Name node is in safe mode.
The reported blocks 0 needs additional 20 blocks to reach the threshold 0.9990 of total blocks 20.
The number of live datanodes 0 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.

 

此时namenode已经启动了,并且是安全模式

[hbase@master root]$ jps
24908 Jps
24822 NameNode
[hbase@master root]$ hadoop fs -ls /tmp
Found 10 items
drwxr-xr-x   - hbase supergroup          0 2015-09-11 03:12 /tmp/arch
drwx------   - hbase supergroup          0 2015-09-10 03:32 /tmp/hadoop-yarn
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:32 /tmp/input
-rw-r--r--   3 hbase supergroup  153512879 2015-09-10 09:49 /tmp/jdk-7u79-linux-x64.gz
-rw-r--r--   3 hbase supergroup  312043744 2015-09-17 06:44 /tmp/mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:33 /tmp/out
drwxr-xr-x   - hbase supergroup          0 2015-09-22 02:54 /tmp/test1
drwxr-xr-x   - hbase supergroup          0 2015-09-23 09:49 /tmp/test2
drwxr-xr-x   - hbase supergroup          0 2015-09-23 10:44 /tmp/test3
drwxr-xr-x   - hbase supergroup          0 2015-09-23 11:14 /tmp/test4
[hbase@master root]$ hadoop fs -mkdir /tmp/test5
mkdir: Cannot create directory /tmp/test5. Name node is in safe mode.

此时name下面已经有数据
按Ctrl+C 结束

然后在master上重新启动集群,正常恢复

[hbase@master sbin]$ ./start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Starting namenodes on [master]
master: starting namenode, logging to /usr/local/hadoop-2.7.1/logs/hadoop-hbase-namenode-master.out
node1: starting datanode, logging to /usr/local/hadoop-2.7.1/logs/hadoop-hbase-datanode-node1.out
node2: starting datanode, logging to /usr/local/hadoop-2.7.1/logs/hadoop-hbase-datanode-node2.out
master: starting datanode, logging to /usr/local/hadoop-2.7.1/logs/hadoop-hbase-datanode-master.out
Starting secondary namenodes [node1]
node1: starting secondarynamenode, logging to /usr/local/hadoop-2.7.1/logs/hadoop-hbase-secondarynamenode-node1.out
starting yarn daemons
starting resourcemanager, logging to /usr/local/hadoop-2.7.1/logs/yarn-hbase-resourcemanager-master.out
master: starting nodemanager, logging to /usr/local/hadoop-2.7.1/logs/yarn-hbase-nodemanager-master.out
node1: starting nodemanager, logging to /usr/local/hadoop-2.7.1/logs/yarn-hbase-nodemanager-node1.out
node2: starting nodemanager, logging to /usr/local/hadoop-2.7.1/logs/yarn-hbase-nodemanager-node2.out
[hbase@master sbin]$ jps
25188 NameNode
25595 ResourceManager
25711 NodeManager
26031 Jps
25303 DataNode

可以正常读写

[hbase@master sbin]$ hadoop fs -ls /tmp         
Found 10 items
drwxr-xr-x   - hbase supergroup          0 2015-09-11 03:12 /tmp/arch
drwx------   - hbase supergroup          0 2015-09-10 03:32 /tmp/hadoop-yarn
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:32 /tmp/input
-rw-r--r--   3 hbase supergroup  153512879 2015-09-10 09:49 /tmp/jdk-7u79-linux-x64.gz
-rw-r--r--   3 hbase supergroup  312043744 2015-09-17 06:44 /tmp/mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:33 /tmp/out
drwxr-xr-x   - hbase supergroup          0 2015-09-22 02:54 /tmp/test1
drwxr-xr-x   - hbase supergroup          0 2015-09-23 09:49 /tmp/test2
drwxr-xr-x   - hbase supergroup          0 2015-09-23 10:44 /tmp/test3
drwxr-xr-x   - hbase supergroup          0 2015-09-23 11:14 /tmp/test4
[hbase@master sbin]$ hadoop fs -mkdir /tmp/test5
[hbase@master sbin]$ hadoop fs -ls /tmp         
Found 11 items
drwxr-xr-x   - hbase supergroup          0 2015-09-11 03:12 /tmp/arch
drwx------   - hbase supergroup          0 2015-09-10 03:32 /tmp/hadoop-yarn
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:32 /tmp/input
-rw-r--r--   3 hbase supergroup  153512879 2015-09-10 09:49 /tmp/jdk-7u79-linux-x64.gz
-rw-r--r--   3 hbase supergroup  312043744 2015-09-17 06:44 /tmp/mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x   - hbase supergroup          0 2015-09-10 03:33 /tmp/out
drwxr-xr-x   - hbase supergroup          0 2015-09-22 02:54 /tmp/test1
drwxr-xr-x   - hbase supergroup          0 2015-09-23 09:49 /tmp/test2
drwxr-xr-x   - hbase supergroup          0 2015-09-23 10:44 /tmp/test3
drwxr-xr-x   - hbase supergroup          0 2015-09-23 11:14 /tmp/test4
drwxr-xr-x   - hbase supergroup          0 2015-09-24 06:10 /tmp/test5

 

总结

利用secondary namenode恢复namenode有两种方案,一种是人工拷贝目录数据,一种是利用importcheckpoint

import checkpoint。步骤如下:
拿一台和原来机器一样的机器,包括配置和文件,一般来说最快的是拿你节点机器中的一台,立马能用(部分配置要改成NameNode的配置)
创建一个空的文件夹,该文件夹就是配置文件中dfs.name.dir所指向的文件夹。
拷贝你的secondary NameNode checkpoint出来的文件,到某个文件夹,该文件夹为fs.checkpoint.dir指向的文件夹
执行命令bin/hadoop namenode -importCheckpoint
这样NameNode会读取checkpoint文件,保存到dfs.name.dir。但是如果你的dfs.name.dir包含合法的fsimage,是会执行失败的。因为NameNode会检查fs.checkpoint.dir目录下镜像的一致性,但是不会去改动它

 利用secondary namenode恢复的数据并不是最新的,毕竟它只保存了最近一次的快照

posted on 2015-09-24 14:34  诗圆  阅读(5121)  评论(0编辑  收藏  举报

导航