我的HBase集群的负载不平衡,所以我想将表的某些区域从一个regionserver移动到另一个,但是看起来需要一个regionserver的起始码来完成这个,我怎样才能得到这个起始码?
我注意到有人的主状态页面是这样的:

但我的是这样的:

我在哪里可以得到起始码?
实际上,我想将一个区域从regionserver k3移动到regionserver k2,而k3上的区域是:

我怎样才能做到这一点?详细地 :)
好的,最后我解决了.
/*
* 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:ml.huang@kaliumn.com">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("+++++++++++++++++");
}
}
}
Run Code Online (Sandbox Code Playgroud)
实际上,startcode是'servername'的最后一部分.
这些命令将完成从一个regionserver到另一个regionserver的移动区域:
> ka@k1 bin % pwd
> /opt/kalium/hbase/bin
> ka@k1 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
Run Code Online (Sandbox Code Playgroud)
你需要区域代码来完成这个.区域代码是区域名称的最后一部分(在点(.)后面).

| 归档时间: |
|
| 查看次数: |
1727 次 |
| 最近记录: |