2012-06-26 33 views
5

我的HBase集群的负载不平衡,所以我想从一个区域服务器的一些区域的表移动到其他,但似乎需要一个区域服务器的startcode这样做,我怎么能得到这个开始代码?如何在HBase集群中获取regionservers的startcode?

我注意到,有人的主状态页面是这样的: other's master-status page

,但我的是这样的: my master-status page

我在哪里可以得到起始码?

实际上,我想从RegionServer的K3移动区域RegionServer的K2和K3上的区域是: regions on k3

我怎么能做到这一点?详细:)

回答

7

好吧,最后我解决了它。

/* 
* Copyright: Copyright (c) 2012 Kaliumn 
* 
* @Description: get regionservers' startcode in a hbase cluster 
* 
*/ 

package test.hbase; 

import java.util.Collection; 

import org.apache.hadoop.conf.Configuration; 
import org.apache.hadoop.hbase.HServerInfo; 
import org.apache.hadoop.hbase.MasterNotRunningException; 
import org.apache.hadoop.hbase.ServerName; 
import org.apache.hadoop.hbase.ZooKeeperConnectionException; 
import org.apache.hadoop.hbase.client.HBaseAdmin; 
import org.apache.hadoop.hbase.ipc.HMasterInterface; 
import org.gfg.kalium.server.hbaseutil.HConfUtils; 

/** 
* class <code> GetStartcode </code> is used to get regionservers' startcode 
* 
* @author <a href="mailto:[email protected]">Meilong Huang</a> 
* @version v1.0.0 
* @date 2012-6-26 05:24:10 
* 
*/ 

public class GetStartcode { 

    /** 
    * get regionservers' startcode 
    * 
    * @param args 
    * @throws ZooKeeperConnectionException 
    * @throws MasterNotRunningException 
    */ 
    public static void main(String[] args) throws MasterNotRunningException, 
      ZooKeeperConnectionException { 
     Configuration conf = HConfUtils 
       .setHbaseConf("k2.ccntgrid.org,k3.ccntgrid.org,k4.ccntgrid.org"); 
     HBaseAdmin admin = new HBaseAdmin(conf); 
     HMasterInterface master = admin.getMaster(); 
     Collection<ServerName> rs = master.getClusterStatus().getServerInfo(); 
     for (ServerName r : rs) { 
      System.out.println(r.getHostname()); 
      System.out.println(r.getServerName()); 
      System.out.println(r.getStartcode()); 
      System.out.println("+++++++++++++++++"); 
     } 
    } 
} 

实际上,startcode是'servername'的最后一部分。

这些命令将完成从一个RegionServer的移动区域,以其他:

> [email protected] bin % pwd 
> /opt/kalium/hbase/bin 


> [email protected] bin % echo "move '3504a80cd4047f78834bcf58bf169e62', 'k4.ccntgrid.org,60020,1340682441023'" | ./hbase shell 
> HBase Shell; enter 'help<RETURN>' for list of supported commands. 
Type "exit<RETURN>" to leave the HBase Shell 
Version 0.92.1, r1298924, Fri Mar 9 16:58:34 UTC 2012 

> move '3504a80cd4047f78834bcf58bf169e62', 'k4.ccntgrid.org,60020,1340682441023' 
0 row(s) in 0.5380 seconds 

u需要的区域码来完成这一点。区域代码是区域名称的最后一部分(在点(。)后面)。
region code

2

可以使用命令状态在HBase的外壳:

hbase(main):001:0> status 'simple' 

它将打印区域的服务器列表与他们的服务器名称,端口和起始码。

相关问题