简介环境:
window7 x64
Eclipse Java EE IDE for Web Developers.(Version: Kepler Service Release 1)(Build id: 20130919-0819)
HBase (hbase-0.98.3-hadoop2-bin.tar.gz)(在虚拟机CentOS6.5中)
错误内容:(部分被我用【...】代替了,一些计算机信息)
1 2014-09-02 15:39:22,900 WARN [main] util.NativeCodeLoader (NativeCodeLoader.java:<clinit>(62)) - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 2 2014-09-02 15:39:23,091 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT 3 2014-09-02 15:39:23,091 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:host.name=【...】 4 2014-09-02 15:39:23,091 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.version=1.7.0_60 5 2014-09-02 15:39:23,091 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.vendor=Oracle Corporation 6 2014-09-02 15:39:23,091 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.home=【...】 7 2014-09-02 15:39:23,091 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.class.path=【...】 8 2014-09-02 15:39:23,092 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.library.path=【...】 9 2014-09-02 15:39:23,092 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.io.tmpdir=【...】 10 2014-09-02 15:39:23,092 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:java.compiler=<NA> 11 2014-09-02 15:39:23,092 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.name=Windows 7 12 2014-09-02 15:39:23,092 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.arch=amd64 13 2014-09-02 15:39:23,092 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:os.version=6.1 14 2014-09-02 15:39:23,092 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.name=【...】 15 2014-09-02 15:39:23,092 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.home=【...】 16 2014-09-02 15:39:23,093 INFO [main] zookeeper.ZooKeeper (Environment.java:logEnv(100)) - Client environment:user.dir=【...】 17 2014-09-02 15:39:23,095 INFO [main] zookeeper.ZooKeeper (ZooKeeper.java:<init>(438)) - Initiating client connection, connectString=192.168.0.210:2181 sessionTimeout=90000 watcher=hconnection-0x4bc2fdde, quorum=192.168.0.210:2181, baseZNode=/hbase 18 2014-09-02 15:39:23,128 INFO [main] zookeeper.RecoverableZooKeeper (RecoverableZooKeeper.java:<init>(120)) - Process identifier=hconnection-0x4bc2fdde connecting to ZooKeeper ensemble=192.168.0.210:2181 19 2014-09-02 15:39:23,128 INFO [main-SendThread(192.168.0.210:2181)] zookeeper.ClientCnxn (ClientCnxn.java:logStartConnect(975)) - Opening socket connection to server 192.168.0.210/192.168.0.210:2181. Will not attempt to authenticate using SASL (unknown error) 20 2014-09-02 15:39:23,131 INFO [main-SendThread(192.168.0.210:2181)] zookeeper.ClientCnxn (ClientCnxn.java:primeConnection(852)) - Socket connection established to 192.168.0.210/192.168.0.210:2181, initiating session 21 2014-09-02 15:39:23,173 INFO [main-SendThread(192.168.0.210:2181)] zookeeper.ClientCnxn (ClientCnxn.java:onConnected(1235)) - Session establishment complete on server 192.168.0.210/192.168.0.210:2181, sessionid = 0x1481be77ced001a, negotiated timeout = 40000 22 2014-09-02 15:39:23,414 INFO [main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - hadoop.native.lib is deprecated. Instead, use io.native.lib.available 23 2014-09-02 15:39:26,188 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 1 of 35 failed; retrying after sleep of 100, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 24 2014-09-02 15:39:26,320 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 2 of 35 failed; retrying after sleep of 201, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 25 2014-09-02 15:39:26,636 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 3 of 35 failed; retrying after sleep of 302, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 26 2014-09-02 15:39:27,143 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 4 of 35 failed; retrying after sleep of 500, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 27 2014-09-02 15:39:28,075 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 5 of 35 failed; retrying after sleep of 1004, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 28 2014-09-02 15:39:29,084 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 6 of 35 failed; retrying after sleep of 2008, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 29 2014-09-02 15:39:31,098 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 7 of 35 failed; retrying after sleep of 4014, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 30 2014-09-02 15:39:35,120 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 8 of 35 failed; retrying after sleep of 10005, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 31 2014-09-02 15:39:47,690 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 9 of 35 failed; retrying after sleep of 10097, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 32 2014-09-02 15:40:00,349 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 10 of 35 failed; retrying after sleep of 10043, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 33 2014-09-02 15:40:12,956 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 11 of 35 failed; retrying after sleep of 10057, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 34 2014-09-02 15:40:25,777 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 12 of 35 failed; retrying after sleep of 20096, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 35 2014-09-02 15:40:48,656 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 13 of 35 failed; retrying after sleep of 20146, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 36 2014-09-02 15:41:11,363 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 14 of 35 failed; retrying after sleep of 20174, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 37 2014-09-02 15:41:34,114 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 15 of 35 failed; retrying after sleep of 20096, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 38 2014-09-02 15:41:57,174 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 16 of 35 failed; retrying after sleep of 20160, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 39 2014-09-02 15:42:19,894 INFO [main] client.HConnectionManager$HConnectionImplementation (HConnectionManager.java:makeStub(1637)) - getMaster attempt 17 of 35 failed; retrying after sleep of 20198, exception=com.google.protobuf.ServiceException: java.net.UnknownHostException: unknown host: mas 40 ......可能还在运行
JAVA代码如下:(我把Hbase中hbase-0.98.3-hadoop2lib下的jar包都加到工程中了)
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.HBaseAdmin; public class HBaseTest { public static void main(String[] agrs) throws Exception { String strTBName = "tb_test"; // 表 String strColFamily = "cf"; // 列族 // 配置 Configuration conf = HBaseConfiguration.create(); conf.set("hbase.zookeeper.quorum", "【这里是Master的IP值】"); // 管理员 HBaseAdmin hbaseAdmin = new HBaseAdmin(conf); // 表名称 TableName tableName = TableName.valueOf(strTBName); // 表描述器 HTableDescriptor tableDesc = new HTableDescriptor(tableName); tableDesc.addFamily(new HColumnDescriptor(strColFamily));// 添加列族 // 创建一个表,同步操作 hbaseAdmin.createTable(tableDesc); System.out.println("创建表" + strTBName + "成功"); } }
首先我是看了这篇文章:http://javacrazyer.iteye.com/blog/1186881
其中评论11楼:(我的是按自己的配置来的)
11 楼 sujianhu 2014-04-23 我也碰到 13/07/05 19:50:05 INFO zookeeper.ClientCnxn: Opening socket connection to server 192.168.56.101/192.168.56.101:2181. Will not attempt to authenticate using SASL (无法定位登录配置) 13/07/05 19:50:05 INFO zookeeper.ClientCnxn: Socket connection established to 192.168.56.101/192.168.56.101:2181, initiating session 13/07/05 19:50:05 INFO zookeeper.ClientCnxn: Session establishment complete on server 192.168.56.101/192.168.56.101:2181, sessionid = 0x13fae9d00dd0005, negotiated timeout = 180000 13/07/05 19:50:06 INFO client.HConnectionManager$HConnectionImplementation: getMaster attempt 0 of 10 failed; retrying after sleep of 1008 最终找到原因是节点在zookeeper注册的是主机名 所以在eclipse 远程调试的时候要把windows的host文件加上节点信息例如 192.168.159.2 master master 192.168.159.3 save1 save1 192.168.159.4 save2 save2 192.168.159.5 save3 save3 这种错误基本都是host错误,查找了不少zookeeper的资料都说对ip支持很弱,所以要配置主机名与ip的映射。不然很容易错。
改完后,再运行就可以了!
下面这个错误是因为HBase还在启动...稍等之后再试。
1 hbase(main):002:0> list 2 TABLE 3 4 ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet 5 at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:90) 6 at org.apache.hadoop.hbase.ipc.FifoRpcScheduler$1.run(FifoRpcScheduler.java:73) 7 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) 8 at java.util.concurrent.FutureTask.run(FutureTask.java:262) 9 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 10 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 11 at java.lang.Thread.run(Thread.java:745) 12 13 Here is some help for this command: 14 List all tables in hbase. Optional regular expression parameter could 15 be used to filter the output. Examples: 16 17 hbase> list 18 hbase> list 'abc.*' 19 hbase> list 'ns:abc.*' 20 hbase> list 'ns:.*'
2014年9月19日 连接集群的HBase的错误
2014-09-19 09:27:24,144 INFO [main] hbase.HBaseHelper (HBaseHelper.java:CreateTable(195)) - start create table ...... 2014-09-19 09:27:24,176 INFO [main] zookeeper.ZooKeeper (ZooKeeper.java:<init>(438)) - Initiating client connection, connectString=192.168.0.220:2181,192.168.0.210:2181,192.168.0.221:2181 sessionTimeout=90000 watcher=catalogtracker-on-hconnection-0x23627751, quorum=192.168.0.220:2181,192.168.0.210:2181,192.168.0.221:2181, baseZNode=/hbase 2014-09-19 09:27:24,176 INFO [main] zookeeper.RecoverableZooKeeper (RecoverableZooKeeper.java:<init>(120)) - Process identifier=catalogtracker-on-hconnection-0x23627751 connecting to ZooKeeper ensemble=192.168.0.220:2181,192.168.0.210:2181,192.168.0.221:2181 2014-09-19 09:27:24,176 INFO [main-SendThread(192.168.0.210:2181)] zookeeper.ClientCnxn (ClientCnxn.java:logStartConnect(975)) - Opening socket connection to server 192.168.0.210/192.168.0.210:2181. Will not attempt to authenticate using SASL (unknown error) 2014-09-19 09:27:24,192 INFO [main-SendThread(192.168.0.210:2181)] zookeeper.ClientCnxn (ClientCnxn.java:primeConnection(852)) - Socket connection established to 192.168.0.210/192.168.0.210:2181, initiating session 2014-09-19 09:27:24,207 INFO [main-SendThread(192.168.0.210:2181)] zookeeper.ClientCnxn (ClientCnxn.java:onConnected(1235)) - Session establishment complete on server 192.168.0.210/192.168.0.210:2181, sessionid = 0x1481be77ced0033, negotiated timeout = 40000 <--------------------------------------------------------等待了很久才出现下面的信息-------通过shell看表已经建好了---------------------------------------------------------> 2014-09-19 09:27:24,271 INFO [main] Configuration.deprecation (Configuration.java:warnOnceIfDeprecated(840)) - hadoop.native.lib is deprecated. Instead, use io.native.lib.available 2014-09-19 09:36:40,880 INFO [main] zookeeper.ZooKeeper (ZooKeeper.java:close(684)) - Session: 0x1481be77ced0033 closed 2014-09-19 09:36:40,880 INFO [main-EventThread] zookeeper.ClientCnxn (ClientCnxn.java:run(512)) - EventThread shut down 2014-09-19 09:36:40,880 ERROR [main] hbase.HBaseHelper (HBaseHelper.java:ExistsTable(165)) - Failed after attempts=35, exceptions: Fri Sep 19 09:27:27 CST 2014, org.apache.hadoop.hbase.client.RpcRetryingCaller@531856ad, java.net.UnknownHostException: unknown host: s1
......【有30多行一样的】2014-09-19 09:36:40,882 INFO [main] hbase.HBaseHelper (HBaseHelper.java:CloseHBaseAdmin(607)) - ExistsTable(...):关闭与HBase的连接!
<--------------------------------------------还在执行什么,估计是s2没找到--------------------------->
解决是修改hosts文件(系统盘:WindowsSystem32driversetc):
*.*.*.* m1 m1
*.*.*.* s1 s1
*.*.*.* s2 s2