How to get the region server start code in an HBase cluster?

my load of the HBase cluster is unbalanced, so I want to move some areas of the table from one region server to another, but it seems that I need the initial code of the register server for this, how can I get this initial code?

I noticed that someone's master status is as follows: other's master-status page

but mine like this: my master-status page

Where can I get the source code?

in fact, I want to move the region from the k3 server registers to the k2 register server, and the region to k3: regions on k3

How can i do this? more details :)

+5
source share
2 answers

Okay, finally, I worked.

/*
 * 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("+++++++++++++++++");
        }
    }
}

in fact, startcode is the last part of "servername".

:

> 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

u , . ( (.)).
region code

+7

hbase:

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

, .

+2

All Articles