HBASE API操作问题总结

org.apache.hadoop.hbase.MasterNotRunningException


 

在centos中查看,发现没有HMaster进程

解决方法:

 

1.启动hadoop后,需要等一段时间,再开启hbase

2、启动hadoop后,去掉hadoop的安全模式,然后启动hbase

hadoop dfsadmin -safemode leave

 

 

org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast to org.apache.hadoop.hbase.client.HTable


 

  HTablePool pool = new HTablePool(cfg, 1000); 

  HTable table = (HTable) pool.getTable(tableName);

原因:现在使用的api版本中pool.getTable返回的类型是HTableInterface ,无法强转为HTable

解决方法:不用转为HTable直接调用其put方法即可:

 HTablePool pool = new HTablePool(cfg, 1000); 

 pool.getTable(tableName).put(put); 

 

 HMaster aborted(出现后消失)


 

 已关闭安全模式,配置等正确,查看日志如下:

2014-05-26 10:59:41,887 ERROR org.apache.hadoop.security.UserGroupInformation: PriviledgedActionException as:root cause:java.io.IOException: File /usr/local/hadoop/tmp/mapred/system/jobtracker.info could only be replicated to 0 nodes, instead of 1

2014-05-26 10:59:41,887 INFO org.apache.hadoop.ipc.Server: IPC Server handler 3 on 9000, call addBlock(/usr/local/hadoop/tmp/mapred/system/jobtracker.info, DFSClient_NONMAPREDUCE_985848864_1, null) from 192.168.1.95:48016: error: java.io.IOException: File /usr/local/hadoop/tmp/mapred/system/jobtracker.info could only be replicated to 0 nodes, instead of 1

java.io.IOException: File /usr/local/hadoop/tmp/mapred/system/jobtracker.info could only be replicated to 0 nodes, instead of 1

    at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:1639)

    at org.apache.hadoop.hdfs.server.namenode.NameNode.addBlock(NameNode.java:736)

    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:578)

    at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1393)

    at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1389)

    at java.security.AccessController.doPrivileged(Native Method)

    at javax.security.auth.Subject.doAs(Subject.java:396)

    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1149)

    at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1387)

 

因为namenode多次格式化造成的

每次namenode format 会重新创建一个namenodeId,而dfs.data.dir 参数配置的目录中包含的是上次format 创建的id,和dfs.name.dir 参数配置的目录中的id 不一致。namenode format 清空了namenode 下的数据,但是没有清空datanode 下的数据,导致启动时失败

 

解决方法:fotmat 前,清空dfs.data.dir 参数配置的目录,重新格式化hdfs的命令。

 

 

 

你可能感兴趣的:(hbase)