Updated on 2022-09-14 GMT+08:00

Shell

You can directly perform operations on HBase using shell on the server. HBase shell APIs are consistent with those in an open source community. For details, see http://learnhbase.wordpress.com/2013/03/02/hbase-shell-commands/.

Methods of running shell commands:

  1. Go to any directory of the HBase client.
  2. Run the following command to initialize environment variables:

    source /opt/client/bigdata_env

  3. If the Kerberos authentication is enabled for the current cluster, run the following command to authenticate the user. If the Kerberos authentication is disabled for the current cluster, skip this step. The current user is the development user added in Preparing a Development User.

    Human-machine user: kinit MRS cluster user

    For example, kinit hbaseuser.

    Machine-machine user: kinit -kt Authentication credential path MRS cluster user

    Example: kinit -kt /opt/user.keytab hbaseuser

  4. Run the hbase shell command.

    Access the running mode of the HBase command line interface (also called CLI client connection).

    hbase(main):001:0> 

    Run the help command to obtain help information about the HBase command parameters.

Commands to Obtain HBase Replication Metrics

Run the status shell command to obtain all required metrics.

  • Run the following command to view the replication source metric:

    hbase(main):019:0> status 'replication', 'source'

    The command output is as follows: (The actual node output is used.)

    version 1.0.2
    1 live servers
    BLR1000006595:
    SOURCE: PeerID=1, SizeOfLogQueue=0, ShippedBatches=0, ShippedOps=0, ShippedBytes=0, LogReadInBytes=1389, LogEditsRead=4, LogEditsFiltered=4, SizeOfLogToReplicate=0, TimeForLogToReplicate=0, ShippedHFiles=0, 
    SizeOfHFileRefsQueue=0, AgeOfLastShippedOp=0, TimeStampsOfLastShippedOp=Wed May 25 20:44:42 CST 2016, Replication Lag=0 PeerID=3, SizeOfLogQueue=0, ShippedBatches=0, ShippedOps=0, ShippedBytes=0, LogReadInBytes=1389, LogEditsRead=4, LogEditsFiltered=4, SizeOfLogToReplicate=0, TimeForLogToReplicate=0, ShippedHFiles=0,
    SizeOfHFileRefsQueue=0, AgeOfLastShippedOp=0, TimeStampsOfLastShippedOp=Wed May 25 20:44:42 CST 2016, Replication Lag=0 FailedReplicationAttempts=0
  • Run the following command to view the replication sink metric:

    hbase(main):020:0> status 'replication', 'sink'

    The command output is as follows: (The actual node output is used.)

    version 1.0.2
    1 live servers
    BLR1000006595:
    SINK : AppliedBatches=0, AppliedOps=0, AppliedHFiles=0, AgeOfLastAppliedOp=0, TimeStampsOfLastAppliedOp=Wed May 25 17:55:21 CST 2016
  • Run the following command to view both replication source and replication sink metrics at the same time:

    hbase(main):018:0> status 'replication'

    The command output is as follows: (The actual node output is used.)

    version 1.0.2
    1 live servers
    BLR1000006595:
    SOURCE: PeerID=1, SizeOfLogQueue=0, ShippedBatches=0, ShippedOps=0, ShippedBytes=0, LogReadInBytes=1389, LogEditsRead=4, LogEditsFiltered=4, SizeOfLogToReplicate=0, TimeForLogToReplicate=0, ShippedHFiles=0, 
    SizeOfHFileRefsQueue=0, AgeOfLastShippedOp=0, TimeStampsOfLastShippedOp=Wed May 25 20:43:24 CST 2016, Replication Lag=0 PeerID=3, SizeOfLogQueue=0, ShippedBatches=0, ShippedOps=0, ShippedBytes=0, LogReadInBytes=1389, LogEditsRead=4, LogEditsFiltered=4, SizeOfLogToReplicate=0, TimeForLogToReplicate=0, ShippedHFiles=0,
    SizeOfHFileRefsQueue=0, AgeOfLastShippedOp=0, TimeStampsOfLastShippedOp=Wed May 25 20:43:24 CST 2016, Replication Lag=0 FailedReplicationAttempts=0
    SINK  : AppliedBatches=0, AppliedOps=0, AppliedHFiles=0, AgeOfLastAppliedOp=0, TimeStampsOfLastAppliedOp=Wed May 25 17:55:21 CST 2016