首页 > 代码库 > [hadoop]Cannot create directory /mdrill/tablelist/fact_seller_all_d. Name node is in safe mode.

[hadoop]Cannot create directory /mdrill/tablelist/fact_seller_all_d. Name node is in safe mode.

在执行mdrill创建表的时候报如下异常(蓝色部分为关键):

[mdrill@hadoop1101 bin]$ ./bluewhale mdrill create ./create.sql higo execute [create, ./create.sql]Exception in thread "main" org.apache.hadoop.ipc.RemoteException: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create directory /mdrill/tablelist/fact_seller_all_d. Name node is in safe mode.The ratio of reported blocks 0.0000 has not reached the threshold 0.9990. Safe mode will be turned off automatically.        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirsInternal(FSNamesystem.java:1761)        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirs(FSNamesystem.java:1735)        at org.apache.hadoop.hdfs.server.namenode.NameNode.mkdirs(NameNode.java:542)        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)        at java.lang.reflect.Method.invoke(Method.java:616)        at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:508)        at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:959)        at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:955)        at java.security.AccessController.doPrivileged(Native Method)        at javax.security.auth.Subject.doAs(Subject.java:416)        at org.apache.hadoop.ipc.Server$Handler.run(Server.java:953)        at org.apache.hadoop.ipc.Client.call(Client.java:740)        at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220)        at com.sun.proxy.$Proxy0.mkdirs(Unknown Source)        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)        at java.lang.reflect.Method.invoke(Method.java:597)        at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82)        at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59)        at com.sun.proxy.$Proxy0.mkdirs(Unknown Source)        at org.apache.hadoop.hdfs.DFSClient.mkdirs(DFSClient.java:912)        at org.apache.hadoop.hdfs.DistributedFileSystem.mkdirs(DistributedFileSystem.java:262)        at org.apache.hadoop.fs.FileSystem.mkdirs(FileSystem.java:1120)        at com.alimama.mdrill.topology.MdrillMain.createtable(MdrillMain.java:136)        at com.alimama.mdrill.topology.MdrillMain.main(MdrillMain.java:45)        at com.alimama.bluewhale.core.drpc.Mdrill.main(Mdrill.java:11)

原因:因为在分布式文件系统启动的时候,开始的时候会有安全模式,当分布式文件系统处于安全模式的情况下,文件系统中的内容不允许修改也不允许删除,直到安全模式结束。安全模式主要是为了系统启动的时候检查各个DataNode上数据块的有效性,同时根据策略必要的复制或者删除部分数据块。运行期通过命令也可以进入安全模式。在实践过程中,系统启动的时候去修改和删除文件也会有安全模式不允许修改的出错提示,只需要等待一会儿即可。

如果您想立即离开安全模式可执行如下命令:

[mdrill@hadoop1101 bin]$ hadoop dfsadmin -safemode leaveSafe mode is OFF

在此执行mdrill创建表,成功。