我在ubuntu上设置了hbase 0.98.13,看起来工作正常。我在Windows中有一个Java客户端示例程序,用于在hbase中创建一个表。如果我将java程序和ftp打包到ubuntu并在本地运行java客户端,它可以创建hbase表' people'。但是,如果我从Windows运行java程序,则不会创建hbase表。 hbase日志显示从我的Windows PC建立的会话,即10.154.14.43。但那之后什么也没发生。这是我从windows运行java客户端时的hbase日志。
2015-09-02 11:05:14,477 INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxnFactory: Accepted socket connection from /10.154.14.43:59780
2015-09-02 11:05:14,479 INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.ZooKeeperServer: Client attempting to establish new session at /10.154.14.43:59780
2015-09-02 11:05:14,500 INFO [SyncThread:0] server.ZooKeeperServer: Established session 0x14f8bf64aa20026 with negotiated timeout 40000 for client /10.154.14.43:59780
2015-09-02 11:05:19,013 DEBUG [LruStats #0] hfile.LruBlockCache: Total=415.43 KB, free=386.27 MB, max=386.68 MB, blockCount=4, accesses=99, hits=95, hitRatio=95.96%, , cachingAccesses=99, cachingHits=95, cachingHitsRatio=95.96%, evictions=89, evicted=0, evictedPerRun=0.0
2015-09-02 11:05:25,149 DEBUG [cju-linux,33912,1441162218543-BalancerChore] balancer.BaseLoadBalancer: Not running balancer because only 1 active regionserver(s)
2015-09-02 11:10:19,013 DEBUG [LruStats #0] hfile.LruBlockCache: Total=415.43 KB, free=386.27 MB, max=386.68 MB, blockCount=4, accesses=101, hits=97, hitRatio=96.04%, , cachingAccesses=101, cachingHits=97, cachingHitsRatio=96.04%, evictions=119, evicted=0, evictedPerRun=0.0
2015-09-02 11:10:25,149 DEBUG [cju-linux,33912,1441162218543-BalancerChore] balancer.BaseLoadBalancer: Not running balancer because only 1 active regionserver(s)
2015-09-02 11:15:19,013 DEBUG [LruStats #0] hfile.LruBlockCache: Total=415.43 KB, free=386.27 MB, max=386.68 MB, blockCount=4, accesses=103, hits=99, hitRatio=96.12%, , cachingAccesses=103, cachingHits=99, cachingHitsRatio=96.12%, evictions=149, evicted=0, evictedPerRun=0.0
2015-09-02 11:15:25,150 DEBUG [cju-linux,33912,1441162218543-BalancerChore] balancer.BaseLoadBalancer: Not running balancer because only 1 active regionserver(s)
2015-09-02 11:18:01,831 WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxn: Exception causing close of session 0x14f8bf64aa20026 due to java.io.IOException: Connection reset by peer
2015-09-02 11:18:01,832 INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxn: Closed socket connection for client /10.154.14.43:59780 which had sessionid 0x14f8bf64aa20026
2015-09-02 11:18:42,000 INFO [SessionTracker] server.ZooKeeperServer: Expiring session 0x14f8bf64aa20026, timeout of 40000ms exceeded
2015-09-02 11:18:42,000 INFO [ProcessThread(sid:0 cport:-1):] server.PrepRequestProcessor: Processed session termination for sessionid: 0x14f8bf64aa20026
这是我从同一个ubuntu运行java客户端时的日志。
2015-09-02 10:54:22,890 INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxnFactory: Accepted socket connection from /127.0.0.1:49964
2015-09-02 10:54:22,892 INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.ZooKeeperServer: Client attempting to establish new session at /127.0.0.1:49964
2015-09-02 10:54:22,909 INFO [SyncThread:0] server.ZooKeeperServer: Established session 0x14f8bf64aa2001b with negotiated timeout 40000 for client /127.0.0.1:49964
2015-09-02 10:54:23,267 INFO [FifoRpcScheduler.handler1-thread-14] master.HMaster: Client=hduser/null create 'people', {NAME => 'contactinfo', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'name', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
2015-09-02 10:54:23,269 INFO [ProcessThread(sid:0 cport:-1):] server.PrepRequestProcessor: Got user-level KeeperException when processing sessionid:0x14f8bf64aa20000 type:create cxid:0x206 zxid:0x21d txntype:-1 reqpath:n/a Error Path:/hbase/table-lock/people Error:KeeperErrorCode = NoNode for /hbase/table-lock/people
2015-09-02 10:54:23,342 DEBUG [FifoRpcScheduler.handler1-thread-14] lock.ZKInterProcessLockBase: Acquired a lock for /hbase/table-lock/people/write-master:339120000000000
2015-09-02 10:54:23,370 INFO [MASTER_TABLE_OPERATIONS-cju-linux:33912-0] handler.CreateTableHandler: Create table people
2015-09-02 10:54:23,382 DEBUG [MASTER_TABLE_OPERATIONS-cju-linux:33912-0] util.FSTableDescriptors: Wrote descriptor into: file:/home/hduser/hbase/.tmp/data/default/people/.tabledesc/.tableinfo.0000000001
如您所见,当我从ubuntu运行java客户端时,会显示以下行。
[FifoRpcScheduler.handler1-thread-14] master.HMaster: Client=hduser/null create 'people', .....
这是我的源代码。
public class CreateTable {
public static void main(String[] args) throws IOException {
Configuration config = HBaseConfiguration.create();
// Example of setting zookeeper values for HDInsight
// in code instead of an hbase-site.xml file
//
config.set("hbase.zookeeper.quorum", "cju-linux");
//config.set("hbase.zookeeper.property.clientPort", "2181");
//config.set("hbase.cluster.distributed", "true");
System.out.println("before creating table people 1111111111");
// create an admin object using the config
HBaseAdmin admin = new HBaseAdmin(config);
System.out.println("before creating table people 22222222");
// create the table...
HTableDescriptor tableDescriptor = new HTableDescriptor(TableName.valueOf("people"));
// ... with two column families
tableDescriptor.addFamily(new HColumnDescriptor("name"));
tableDescriptor.addFamily(new HColumnDescriptor("contactinfo"));
System.out.println("before creating table people 33333");
admin.createTable(tableDescriptor);
System.out.println("before creating table people 4444");
// define some people
String[][] people = {
{ "1", "Marcel", "Haddad", "marcel@fabrikam.com"},
{ "2", "Franklin", "Holtz", "franklin@contoso.com" },
{ "3", "Dwayne", "McKee", "dwayne@fabrikam.com" },
{ "4", "Rae", "Schroeder", "rae@contoso.com" },
{ "5", "Rosalie", "burton", "rosalie@fabrikam.com"},
{ "6", "Gabriela", "Ingram", "gabriela@contoso.com"} };
System.out.println("before creating table people xxxxxxxxxxxxxxxx");
HTable table = new HTable(config, "people1");
System.out.println("After creating table people");
// Add each person to the table
// Use the `name` column family for the name
// Use the `contactinfo` column family for the email
for (int i = 0; i< people.length; i++) {
Put person = new Put(Bytes.toBytes(people[i][0]));
person.add(Bytes.toBytes("name"), Bytes.toBytes("first"), Bytes.toBytes(people[i][1]));
person.add(Bytes.toBytes("name"), Bytes.toBytes("last"), Bytes.toBytes(people[i][2]));
person.add(Bytes.toBytes("contactinfo"), Bytes.toBytes("email"), Bytes.toBytes(people[i][3]));
table.put(person);
}
// flush commits and close the table
table.flushCommits();
table.close();
}
当我从windows运行java客户端时,消息&#34;在创建表人33333&#34;之前打印出来,但是在创建表人4444&#34;之前的消息&#34;没有打印出来。
打开调试后,在Windows上运行的java客户端程序打印出此消息
2015-09-02 15:41:25,737 INFO [main] client.HConnectionManager$HConnectionImplementation: getMaster attempt 2 of 35 failed; retrying after sleep of 200, exception=com.google.protobuf.ServiceException:org.apache.hadoop.hbase.ipc.RpcClient$FailedServerException: This server is in the failed servers list: localhost/127.0.0.1:48285
我用google搜索并将ubuntu上的/ etc / hosts文件更改为喜欢这个
10.154.14.5 localhost cju-linux
我重新启动了hbase,它仍然无效。
如何调试此问题?
答案 0 :(得分:0)
看起来当您在Windows上运行它时,无法连接到群集或说出正确的协议。确保您的Windows机器能够连接到群集中的所有计算机(检查zookeeper,hmaster和区域服务器主机和端口)。如果它可以正常连接,请验证客户端和服务器是否都使用兼容版本(即0.98.x)。您也可以尝试单步执行createTable命令。如果你让它运行了很长时间,你可能会在放弃重试时看到异常,这可能会给你更多线索。您可以减少客户端重试以尝试尽快实现。祝你好运。