SlideShare une entreprise Scribd logo
1  sur  9
HBase Canary Tool
2012/10/22 Scott Miao
Another way to monitor HBase processes

  • org.apache.hadoop.hbase.tool.Canary
     – Be used to do "canary monitoring" of a running HBase cluster.
     – For each region tries to get one row per column family and
       outputs some information about failure or latency

Usage: bin/hbase org.apache.hadoop.hbase.tool.Canary [opts] [table 1 [table 2...]]
where [opts] are:
 -help       Show this help and exit.
 -daemon        Continuous check at defined intervals. # 6sec
 -interval <N> Interval between checks (sec) # specify how many secs you want

  https://issues.apache.org/jira/browse/HBASE-4393
Canary Tool study
private void sniff() throws Exception {
   for (HTableDescriptor table : admin.listTables()) {
     sniff(table);
   }
 }                  private void sniff(HTableDescriptor tableDesc) throws Exception {
                         HTable table = null;

                         try {
                           table = new HTable(admin.getConfiguration(), tableDesc.getName());
                         } catch (TableNotFoundException e) {
                           return;
                         }

                         for (HRegionInfo region : admin.getTableRegions(tableDesc.getName())) {
                           try {
                             sniffRegion(region, table);
                           } catch (Exception e) {
                             sink.publishReadFailure(region);
                           }
                         }
                     }
Canary Tool study
private void sniffRegion(HRegionInfo region, HTable table) throws Exception {
   HTableDescriptor tableDesc = table.getTableDescriptor();
   for (HColumnDescriptor column : tableDesc.getColumnFamilies()) {
    Get get = new Get(region.getStartKey());
    get.addFamily(column.getName());

         try {
           long startTime = System.currentTimeMillis();
           table.get(get);
           long time = System.currentTimeMillis() - startTime;

           sink.publishReadTiming(region, column, time);
         } catch (Exception e) {
           sink.publishReadFailure(region, column);
         }
     }
 }
Canary Tool study
public interface Sink {
   public void publishReadFailure(HRegionInfo region);
   public void publishReadFailure(HRegionInfo region, HColumnDescriptor column);
   public void publishReadTiming(HRegionInfo region, HColumnDescriptor
column, long msTime);
 }
   public static class StdOutSink implements Sink {
     public void publishReadFailure(HRegionInfo region) {
       LOG.error(String.format("read from region %s failed", region.getRegionNameAsString()));
     }

     public void publishReadFailure(HRegionInfo region, HColumnDescriptor column) {
       LOG.error(String.format("read from region %s column family %s failed",
             region.getRegionNameAsString(), column.getNameAsString()));
     }

      public void publishReadTiming(HRegionInfo region, HColumnDescriptor column, long
   msTime) {
        LOG.info(String.format("read from region %s column family %s in %dms",
             region.getRegionNameAsString(), column.getNameAsString(), msTime));
      }
    }
Canary Tool study


    //constructors
    public Canary() {
        this(new StdOutSink());
      }

     public Canary(Sink sink) {
       this.sink = sink;
     }
Canary Tool in Circus
                                                   Send mail if any
                        Fix problem
                                                   abnormal




     Canary-tool




Start here                                               Nagios Server
             Tm-puppet
             operation server


                                      hbase-
                   Write to           canary.log   Read from
                   /var/log/hbase/
Canary Tool in Circus
com.trendmicro.spn.ops.hbase.RunCanaryTool
private static class CustomSink implements Canary.Sink {
 public void publishReadFailure(HRegionInfo regionInfo) {
   //...
   LOG.error(String.format("Read from table:%s, region:%s failed", tableName, regionName));
 }

  public void publishReadFailure(HRegionInfo regionInfo, HColumnDescriptor colDescriptor) {
    //...
    LOG.error(String.format("Read from table:%s, region:%s, columnFamily:%s
failed", tableName, regionName, colFamilyName));
  }

  public void publishReadTiming(HRegionInfo regionInfo, HColumnDescriptor colDescriptor,
                      long msTime) {
    //...
    LOG.info(String.format("Read from table:%s, region:%s, columnFamily:%s in
%dms", tableName, regionName, colFamilyName, msTime));
  }
}
Canary Tool in Circus
com.trendmicro.spn.ops.hbase.RunCanaryTool
public static void main(String[] args) throws Exception {
  Canary canary = new Canary(new CustomSink());
  int exitCode = ToolRunner.run(canary, args);
  System.exit(exitCode);
}


         hbase-canary-monitor.sh

         su - hbase <<EOF
         kinit -kt /etc/hbase/conf/hbase.keytab hbase/$(hostname -f)
         java -cp $CLASSPATH com.trendmicro.spn.ops.hbase.RunCanaryTool $@
         EOF

Contenu connexe

Tendances

Generating and Analyzing Events
Generating and Analyzing EventsGenerating and Analyzing Events
Generating and Analyzing Eventsztellman
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptUnit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptroot_fibo
 
Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Ahmed El-Arabawy
 
我在豆瓣使用Emacs
我在豆瓣使用Emacs我在豆瓣使用Emacs
我在豆瓣使用Emacs董 伟明
 
bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018AlastairRobertson9
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shellroot_fibo
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongersbrian d foy
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell ScriptingJaibeer Malik
 
Refactoring to symfony components
Refactoring to symfony componentsRefactoring to symfony components
Refactoring to symfony componentsMichael Peacock
 
Using Unix
Using UnixUsing Unix
Using UnixDr.Ravi
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsSudharsan S
 

Tendances (19)

Generating and Analyzing Events
Generating and Analyzing EventsGenerating and Analyzing Events
Generating and Analyzing Events
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptUnit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell script
 
Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities
 
Chap06
Chap06Chap06
Chap06
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
我在豆瓣使用Emacs
我在豆瓣使用Emacs我在豆瓣使用Emacs
我在豆瓣使用Emacs
 
Mysql
MysqlMysql
Mysql
 
Mysql
MysqlMysql
Mysql
 
bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018
 
TRunner
TRunnerTRunner
TRunner
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shell
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
 
extending-php
extending-phpextending-php
extending-php
 
Refactoring to symfony components
Refactoring to symfony componentsRefactoring to symfony components
Refactoring to symfony components
 
Using Unix
Using UnixUsing Unix
Using Unix
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
V23 function-2
V23 function-2V23 function-2
V23 function-2
 

Similaire à 20121022 tm hbasecanarytool

Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108Mathias Herberts
 
Store and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraStore and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraDeependra Ariyadewa
 
Stata Programming Cheat Sheet
Stata Programming Cheat SheetStata Programming Cheat Sheet
Stata Programming Cheat SheetLaura Hughes
 
Apache Hadoop Java API
Apache Hadoop Java APIApache Hadoop Java API
Apache Hadoop Java APIAdam Kawa
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in CassandraJairam Chandar
 
Hi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdfHi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdfaniyathikitchen
 
deepjs - tools for better programming
deepjs - tools for better programmingdeepjs - tools for better programming
deepjs - tools for better programmingnomocas
 
Stata cheatsheet programming
Stata cheatsheet programmingStata cheatsheet programming
Stata cheatsheet programmingTim Essam
 
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...Codemotion
 
The... Wonderful? World of Lambdas
The... Wonderful? World of LambdasThe... Wonderful? World of Lambdas
The... Wonderful? World of LambdasEsther Lozano
 
Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner codeMite Mitreski
 
Ti1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesTi1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesEelco Visser
 
C# I need assitance on my code.. Im getting an error message Us.pdf
C# I need assitance on my code.. Im getting an error message Us.pdfC# I need assitance on my code.. Im getting an error message Us.pdf
C# I need assitance on my code.. Im getting an error message Us.pdfeyezoneamritsar
 

Similaire à 20121022 tm hbasecanarytool (20)

Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108Artimon - Apache Flume (incubating) NYC Meetup 20111108
Artimon - Apache Flume (incubating) NYC Meetup 20111108
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
Store and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraStore and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and Cassandra
 
Hadoop
HadoopHadoop
Hadoop
 
Stata Programming Cheat Sheet
Stata Programming Cheat SheetStata Programming Cheat Sheet
Stata Programming Cheat Sheet
 
Apache Hadoop Java API
Apache Hadoop Java APIApache Hadoop Java API
Apache Hadoop Java API
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
Hi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdfHi,I have updated your code. It is working fine now. Highllighted .pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdf
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
 
deepjs - tools for better programming
deepjs - tools for better programmingdeepjs - tools for better programming
deepjs - tools for better programming
 
Stata cheatsheet programming
Stata cheatsheet programmingStata cheatsheet programming
Stata cheatsheet programming
 
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
Matteo Collina | Take your HTTP server to Ludicrous Speed | Codmeotion Madrid...
 
H base programming
H base programmingH base programming
H base programming
 
Java VS Python
Java VS PythonJava VS Python
Java VS Python
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 
The... Wonderful? World of Lambdas
The... Wonderful? World of LambdasThe... Wonderful? World of Lambdas
The... Wonderful? World of Lambdas
 
Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner code
 
Ti1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesTi1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and Scopes
 
C# I need assitance on my code.. Im getting an error message Us.pdf
C# I need assitance on my code.. Im getting an error message Us.pdfC# I need assitance on my code.. Im getting an error message Us.pdf
C# I need assitance on my code.. Im getting an error message Us.pdf
 

Plus de Scott Miao

My thoughts for - Building CI/CD Pipelines for Serverless Applications sharing
My thoughts for - Building CI/CD Pipelines for Serverless Applications sharingMy thoughts for - Building CI/CD Pipelines for Serverless Applications sharing
My thoughts for - Building CI/CD Pipelines for Serverless Applications sharingScott Miao
 
20171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v0120171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v01Scott Miao
 
Achieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloudAchieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloudScott Miao
 
analytic engine - a common big data computation service on the aws
analytic engine - a common big data computation service on the awsanalytic engine - a common big data computation service on the aws
analytic engine - a common big data computation service on the awsScott Miao
 
Zero-downtime Hadoop/HBase Cross-datacenter Migration
Zero-downtime Hadoop/HBase Cross-datacenter MigrationZero-downtime Hadoop/HBase Cross-datacenter Migration
Zero-downtime Hadoop/HBase Cross-datacenter MigrationScott Miao
 
Attack on graph
Attack on graphAttack on graph
Attack on graphScott Miao
 
004 architecture andadvanceduse
004 architecture andadvanceduse004 architecture andadvanceduse
004 architecture andadvanceduseScott Miao
 
003 admin featuresandclients
003 admin featuresandclients003 admin featuresandclients
003 admin featuresandclientsScott Miao
 
006 performance tuningandclusteradmin
006 performance tuningandclusteradmin006 performance tuningandclusteradmin
006 performance tuningandclusteradminScott Miao
 
005 cluster monitoring
005 cluster monitoring005 cluster monitoring
005 cluster monitoringScott Miao
 
002 hbase clientapi
002 hbase clientapi002 hbase clientapi
002 hbase clientapiScott Miao
 
001 hbase introduction
001 hbase introduction001 hbase introduction
001 hbase introductionScott Miao
 

Plus de Scott Miao (12)

My thoughts for - Building CI/CD Pipelines for Serverless Applications sharing
My thoughts for - Building CI/CD Pipelines for Serverless Applications sharingMy thoughts for - Building CI/CD Pipelines for Serverless Applications sharing
My thoughts for - Building CI/CD Pipelines for Serverless Applications sharing
 
20171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v0120171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v01
 
Achieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloudAchieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloud
 
analytic engine - a common big data computation service on the aws
analytic engine - a common big data computation service on the awsanalytic engine - a common big data computation service on the aws
analytic engine - a common big data computation service on the aws
 
Zero-downtime Hadoop/HBase Cross-datacenter Migration
Zero-downtime Hadoop/HBase Cross-datacenter MigrationZero-downtime Hadoop/HBase Cross-datacenter Migration
Zero-downtime Hadoop/HBase Cross-datacenter Migration
 
Attack on graph
Attack on graphAttack on graph
Attack on graph
 
004 architecture andadvanceduse
004 architecture andadvanceduse004 architecture andadvanceduse
004 architecture andadvanceduse
 
003 admin featuresandclients
003 admin featuresandclients003 admin featuresandclients
003 admin featuresandclients
 
006 performance tuningandclusteradmin
006 performance tuningandclusteradmin006 performance tuningandclusteradmin
006 performance tuningandclusteradmin
 
005 cluster monitoring
005 cluster monitoring005 cluster monitoring
005 cluster monitoring
 
002 hbase clientapi
002 hbase clientapi002 hbase clientapi
002 hbase clientapi
 
001 hbase introduction
001 hbase introduction001 hbase introduction
001 hbase introduction
 

20121022 tm hbasecanarytool

  • 2. Another way to monitor HBase processes • org.apache.hadoop.hbase.tool.Canary – Be used to do "canary monitoring" of a running HBase cluster. – For each region tries to get one row per column family and outputs some information about failure or latency Usage: bin/hbase org.apache.hadoop.hbase.tool.Canary [opts] [table 1 [table 2...]] where [opts] are: -help Show this help and exit. -daemon Continuous check at defined intervals. # 6sec -interval <N> Interval between checks (sec) # specify how many secs you want https://issues.apache.org/jira/browse/HBASE-4393
  • 3. Canary Tool study private void sniff() throws Exception { for (HTableDescriptor table : admin.listTables()) { sniff(table); } } private void sniff(HTableDescriptor tableDesc) throws Exception { HTable table = null; try { table = new HTable(admin.getConfiguration(), tableDesc.getName()); } catch (TableNotFoundException e) { return; } for (HRegionInfo region : admin.getTableRegions(tableDesc.getName())) { try { sniffRegion(region, table); } catch (Exception e) { sink.publishReadFailure(region); } } }
  • 4. Canary Tool study private void sniffRegion(HRegionInfo region, HTable table) throws Exception { HTableDescriptor tableDesc = table.getTableDescriptor(); for (HColumnDescriptor column : tableDesc.getColumnFamilies()) { Get get = new Get(region.getStartKey()); get.addFamily(column.getName()); try { long startTime = System.currentTimeMillis(); table.get(get); long time = System.currentTimeMillis() - startTime; sink.publishReadTiming(region, column, time); } catch (Exception e) { sink.publishReadFailure(region, column); } } }
  • 5. Canary Tool study public interface Sink { public void publishReadFailure(HRegionInfo region); public void publishReadFailure(HRegionInfo region, HColumnDescriptor column); public void publishReadTiming(HRegionInfo region, HColumnDescriptor column, long msTime); } public static class StdOutSink implements Sink { public void publishReadFailure(HRegionInfo region) { LOG.error(String.format("read from region %s failed", region.getRegionNameAsString())); } public void publishReadFailure(HRegionInfo region, HColumnDescriptor column) { LOG.error(String.format("read from region %s column family %s failed", region.getRegionNameAsString(), column.getNameAsString())); } public void publishReadTiming(HRegionInfo region, HColumnDescriptor column, long msTime) { LOG.info(String.format("read from region %s column family %s in %dms", region.getRegionNameAsString(), column.getNameAsString(), msTime)); } }
  • 6. Canary Tool study //constructors public Canary() { this(new StdOutSink()); } public Canary(Sink sink) { this.sink = sink; }
  • 7. Canary Tool in Circus Send mail if any Fix problem abnormal Canary-tool Start here Nagios Server Tm-puppet operation server hbase- Write to canary.log Read from /var/log/hbase/
  • 8. Canary Tool in Circus com.trendmicro.spn.ops.hbase.RunCanaryTool private static class CustomSink implements Canary.Sink { public void publishReadFailure(HRegionInfo regionInfo) { //... LOG.error(String.format("Read from table:%s, region:%s failed", tableName, regionName)); } public void publishReadFailure(HRegionInfo regionInfo, HColumnDescriptor colDescriptor) { //... LOG.error(String.format("Read from table:%s, region:%s, columnFamily:%s failed", tableName, regionName, colFamilyName)); } public void publishReadTiming(HRegionInfo regionInfo, HColumnDescriptor colDescriptor, long msTime) { //... LOG.info(String.format("Read from table:%s, region:%s, columnFamily:%s in %dms", tableName, regionName, colFamilyName, msTime)); } }
  • 9. Canary Tool in Circus com.trendmicro.spn.ops.hbase.RunCanaryTool public static void main(String[] args) throws Exception { Canary canary = new Canary(new CustomSink()); int exitCode = ToolRunner.run(canary, args); System.exit(exitCode); } hbase-canary-monitor.sh su - hbase <<EOF kinit -kt /etc/hbase/conf/hbase.keytab hbase/$(hostname -f) java -cp $CLASSPATH com.trendmicro.spn.ops.hbase.RunCanaryTool $@ EOF