2012-06-26 10 views
5

carico del mio cluster HBase sbilanciato, quindi voglio spostare alcune regioni di tabella da un server di regioni ad un altro, ma sembra che sia necessario un codice di avviamento di un server di regioni per fare questo, come posso ottenere questo codice di avviamento?Come ottenere il codice di avviamento di regionerver in un cluster HBase?

ho notato che pagina master-stato di una persona è come questo: other's master-status page

ma il mio è come questo: my master-status page

dove posso ottenere lo startcode?

in realtà, voglio spostare una regione da regionserver k3 a regionserver k2, e le regioni di k3 sono: regions on k3

come posso fare questo? in dettaglio :)

risposta

7

ok, finalmente l'ho risolto.

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

in realtà, il codice di avviamento è l'ultima parte del "nomeserver".

questi comandi concretizzare regioni spostano da un regionserver all'altro:

> [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 

bisogno di u il codice regione per finire questo. il codice area è l'ultima parte del nome della regione (dietro un punto (.)).
region code

2

È possibile utilizzare lo stato del comando nella shell HBase:

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

Sarà stampare l'elenco dei server regione con i loro nomi di server, porti e startcodes.

Problemi correlati