다음 hbase 커맨드는 다음 의사 자바 코드와 같다.


<hbase 커맨드>

scan 'table', { COLUMNS => 'colFam:colQualifier', LIMIT => 3 }



<java psudeo code>

    Scan scan = new Scan();

    scan.addFamily(Bytes.toBytes(familyName));

    filters.addFilter(pageFilter);

    scan.setFilter(filters);






다음 hbase 커맨드는 다음 의사 자바 코드와 같다.


<hbase 커맨드>
scan 'table', { COLUMNS => 'colFam:colQualifier', LIMIT => 3, FILTER => "ValueFilter( =, 'value1' )" }


<java psudeo code>
        Scan scan = new Scan();
        FilterList filters = new FilterList(FilterList.Operator.MUST_PASS_ALL);
        Filter pageFilter = new PageFilter(fetchSize);
        
        SingleColumnValueFilter qualifierFilter = new SingleColumnValueFilter(
                COLUMN_FAMILY,
                COLUMN_QUALIFIER,
                CompareFilter.CompareOp.EQUAL,
                new BinaryComparator(Bytes.toBytes("value1"))
        );

        filters.addFilter(pageFilter);
        filters.addFilter(qualifierFilter);

        scan.setFilter(filters);


Posted by '김용환'
,



Hbase Scan 결과에 대해 디버깅을 하려 했다.


예전 쿼리를 Result에 대해서 keyvalue를 얻어오는 부분을 날 쿼리를 이용해 사용했다.


                    for (KeyValue kv : result.raw()) {

                        System.out.printf("row: %d, qualifier: %s, value: %s\n",

                                Bytes.toLong(Bytes.padHead(kv.getRow(), 8)),

                                new String(kv.getQualifier()),

                                new String(kv.getValue()));

                    }




그러나, CellUtil을 사용하면 좀 고급스럽게 디버깅할 수 있다.




import org.apache.hadoop.hbase.Cell;

import org.apache.hadoop.hbase.CellUtil;



                    List<Cell> cells = result.listCells();

                    final String TABS = "\t";

                    for (Cell cell : cells) {

                        System.out.printf("%s%scolumn=%s:%s, timestamp=%d, value=%s\n",

                                Bytes.toStringBinary(CellUtil.cloneRow(cell)),

                                TABS,

                                Bytes.toString(CellUtil.cloneFamily(cell)),

                                Bytes.toString(CellUtil.cloneQualifier(cell)),

                                cell.getTimestamp(),

                                Bytes.toString(CellUtil.cloneValue(cell)));

                    }

                    



Posted by '김용환'
,



opentsdb의 hbase 스키마는 다음 url에서 확인할 수 있다.

특이한 점은 데이터는 역순(증분)으로 되어 있고 마지막 uid 정보를 0x00에 저장한다는 점이다. 

따라서 scanning할 때 무척 편하게 할 수 있다. 


http://opentsdb.net/docs/build/html/user_guide/backends/hbase.html


UID Table Schema

A separate, smaller table called tsdb-uid stores UID mappings, both forward and reverse. Two columns exist, one named name that maps a UID to a string and another id mapping strings to UIDs. Each row in the column family will have at least one of three columns with mapping values. The standard column qualifiers are:

  • metrics for mapping metric names to UIDs
  • tagk for mapping tag names to UIDs
  • tagv for mapping tag values to UIDs.

The name family may also contain additional meta-data columns if configured.

id Column Family

Row Key - This will be the string assigned to the UID. E.g. for a metric we may have a value of sys.cpu.user or for a tag value it may be 42.

Column Qualifiers - One of the standard column types above.

Column Value - An unsigned integer encoded on 3 bytes by default reflecting the UID assigned to the string for the column type. If the UID length has been changed in the source code, the width may vary.

name Column Family

Row Key - The unsigned integer UID encoded on 3 bytes by default. If the UID length has been changed in the source code, the width may be different.

Column Qualifiers - One of the standard column types above OR one of metrics_metatagk_meta or tagv_meta.

Column Value - For the standard qualifiers above, the string assigned to the UID. For a *_meta column, the value will be a UTF-8 encoded, JSON formatted UIDMeta Object as a string. Do not modify the column value outside of OpenTSDB. The order of the fields is important, affecting CAS calls.

UID Assignment Row

Within the id column family is a row with a single byte key of \x00. This is the UID row that is incremented for the proper column type (metrics, tagk or tagv) when a new UID is assigned. The column values are 8 byte signed integers and reflect the maximum UID assigned for each type. On assignment, OpenTSDB calls HBase's atomic increment command on the proper column to fetch a new UID.


Posted by '김용환'
,




DATE 타입 값에 대해서 where.. between을 사용하려면 TO_TIMESTAMP를 사용한다


where service_tag = 'google_plus' and log_time between TO_TIMESTAMP('2017-12-19 10:00:24.000') and TO_TIMESTAMP('2017-12-19 10:05:24.000') order by timestamp 


https://phoenix.apache.org/language/functions.html#to_timestamp



current_time()과 now()의 결과는 동일하다.


> select current_time();

+---------------------------------+

| TIME '2017-12-19 03:05:53.873'  |

+---------------------------------+

| 2017-12-19 03:05:53.873         |

+---------------------------------+

1 row selected (0.006 seconds)


> select now();

+---------------------------------+

| DATE '2017-12-19 03:05:56.345'  |

+---------------------------------+

| 2017-12-19 03:05:56.345         |

+---------------------------------+






1분전, 2분전 결과를 보고 싶다면 다음 결과를 확인한다.


> select now(), now() - (1.0 / (60 * 24));


+---------------------------------+---------------------------------+

| DATE '2017-12-19 03:10:39.428'  | DATE '2017-12-19 03:09:39.429'  |

+---------------------------------+---------------------------------+

| 2017-12-19 03:10:39.428         | 2017-12-19 03:09:39.429         |

+---------------------------------+---------------------------------+

1 row selected (0.005 seconds)



> select now(), now() - (2.0 / (60 * 24));

+---------------------------------+---------------------------------+

| DATE '2017-12-19 03:10:42.772'  | DATE '2017-12-19 03:08:42.772'  |

+---------------------------------+---------------------------------+

| 2017-12-19 03:10:42.772         | 2017-12-19 03:08:42.772         |

+---------------------------------+---------------------------------+










시간과 날짜 함수는 다음과 같이 지원한다.


Time and Date Functions

TO_DATE
TO_TIME
TO_TIMESTAMP
CURRENT_TIME
CONVERT_TZ
TIMEZONE_OFFSET
NOW
YEAR
MONTH
WEEK
DAYOFYEAR
DAYOFMONTH
DAYOFWEEK
HOUR
MINUTE
SECOND



Posted by '김용환'
,

[Phoenix] describe

hbase 2017. 12. 19. 11:49



Phoenix 테이블 정보를 보려면 다음과 같이 느낌표를 먼저 입력하고 describe를 입력한다. 




> !describe <테이블 이름>

+------------+--------------+------------------+--------------+------------+------------+--------------+----------------+-----------------+-----------------+-----------+----------+-------------+----------------+-------------------+-------------+

| TABLE_CAT  | TABLE_SCHEM  |    TABLE_NAME    | COLUMN_NAME  | DATA_TYPE  | TYPE_NAME  | COLUMN_SIZE  | BUFFER_LENGTH  | DECIMAL_DIGITS  | NUM_PREC_RADIX  | NULLABLE  | REMARKS  | COLUMN_DEF  | SQL_DATA_TYPE  | SQL_DATETIME_SUB  | CHAR_OCTET_ |

+------------+--------------+------------------+--------------+------------+------------+--------------+----------------+-----------------+-----------------+-----------+----------+-------------+----------------+-------------------+-------------+










모르면 > !help를 입력한다.


!help

!all                Execute the specified SQL against all the current

                    connections

!autocommit         Set autocommit mode on or off

!batch              Start or execute a batch of statements

!brief              Set verbose mode off

!call               Execute a callable statement

!close              Close the current connection to the database

!closeall           Close all current open connections

!columns            List all the columns for the specified table

!commit             Commit the current transaction (if autocommit is off)

!connect            Open a new connection to the database.

!dbinfo             Give metadata information about the database

!describe           Describe a table

!dropall            Drop all tables in the current database

!exportedkeys       List all the exported keys for the specified table

!go                 Select the current connection

!help               Print a summary of command usage

!history            Display the command history

!importedkeys       List all the imported keys for the specified table

!indexes            List all the indexes for the specified table

!isolation          Set the transaction isolation for this connection

!list               List the current connections

!manual             Display the SQLLine manual

!metadata           Obtain metadata information

!nativesql          Show the native SQL for the specified statement

!outputformat       Set the output format for displaying results

                    (table,vertical,csv,tsv,xmlattrs,xmlelements)

!primarykeys        List all the primary keys for the specified table

!procedures         List all the procedures

!properties         Connect to the database specified in the properties file(s)

!quit               Exits the program

!reconnect          Reconnect to the database

!record             Record all output to the specified file

!rehash             Fetch table and column names for command completion

!rollback           Roll back the current transaction (if autocommit is off)

!run                Run a script from the specified file

!save               Save the current variabes and aliases

!scan               Scan for installed JDBC drivers

!script             Start saving a script to a file

!set                Set a sqlline variable


Variable        Value      Description

=============== ========== ================================

Posted by '김용환'
,


아파치 피닉스(Apache Phoenix)에 실시간 로그를 저장해보고 있다.

sqlline에서 로그가 너무 많을 때는 테이블에서 로그가 보이지도 않는다. 


데이터를 보는 뷰가 horizontal, vertical로 되어 있다. 기본 뷰는 horizontal이다. 


로그가 길면 볼 방법이 없다. 그러나 outputformat을 사용하면 유용하다.



> !outputformat vertical 


> select now(), now() - (2.0 / (60 * 24));

DATE '2017-12-19 03:12:39.899'  2017-12-19 03:12:39.899

DATE '2017-12-19 03:10:39.899'  2017-12-19 03:10:39.899






다시 원래 기본 뷰를 사용하려면 다음 커맨드를 실행한다.


> !outputformat table

select now(), now() - (2.0 / (60 * 24));

+---------------------------------+---------------------------------+

| DATE '2017-12-19 03:12:20.209'  | DATE '2017-12-19 03:10:20.209'  |

+---------------------------------+---------------------------------+

| 2017-12-19 03:12:20.209         | 2017-12-19 03:10:20.209         |

+---------------------------------+---------------------------------+




이외 여러 결과 포맷을 사용할 수 있다. 


> !outputformat csv

> select now(), now() - (2.0 / (60 * 24));

'DATE '2017-12-19 05:06:44.272'','DATE '2017-12-19 05:04:44.272''

'2017-12-19 05:06:44.272','2017-12-19 05:04:44.272'




> !outputformat tsv

> select now(), now() - (2.0 / (60 * 24));

'DATE '2017-12-19 05:07:23.258'' 'DATE '2017-12-19 05:05:23.258''

'2017-12-19 05:07:23.258' '2017-12-19 05:05:23.258'



>!outputformat xmlattr

> select now(), now() - (2.0 / (60 * 24));

<resultset>

  <result DATE '2017-12-19 05:09:30.500'="2017-12-19 05:09:30.500" DATE '2017-12-19 05:07:30.500'="2017-12-19 05:07:30.500"/>

</resultset>



> !outputformat xmlelements

> select now(), now() - (2.0 / (60 * 24));

<resultset>

  <result>

    <DATE '2017-12-19 05:09:53.013'>2017-12-19 05:09:53.013</DATE '2017-12-19 05:09:53.013'>

    <DATE '2017-12-19 05:07:53.013'>2017-12-19 05:07:53.013</DATE '2017-12-19 05:07:53.013'>

  </result>

</resultset>

Posted by '김용환'
,



hadoop & hbase간의 의존성/연관성(compatible) 버전 찾기.



https://hbase.apache.org/book.html#hadoop


Hadoop version support matrix
  • "S" = supported

  • "X" = not supported

  • "NT" = Not tested




Posted by '김용환'
,

[공부] Hbase compaction

hbase 2016. 12. 16. 20:23


발로 번역해서 공부한 내용이다.

Hbase compaction을 공부하기 위해 여러 군데 흩어져 있는 내용을 짬뽕한 내용이다. 



hbase에 데이터가 바뀌면 commit log로 저장되는데, WAL(Write-Ahead Log)에 존재한다. 데이터는 이후 메모리 상의 Memstore에 저장된다. 메모리 상의 데이터가 설정된 최대값을 넘어서면 디스크에 HFile로 저장된다. 

이를 compaction(컴팩션)이라고 한다. 읽는 관점도 동일하게, 읽기 쉽게 저장되는 형태이기도 하다.



또한, 데이터가 변경/삭제되면서 이미 저장된 HFile에 필요 없는 데이터가 삭제 마킹(tombstone marking)이 되면서 지울 것은 지우고 합칠 것은 합치는 작업(compaction)을 진행한다.  하나의 리전(region)에서 한 저장소에서 HFile을 모아 병합한다. 


참고로, compaction은 두 가지 종류가 있다. 

- minor compaction : 작고 많은 HFile을 소수의 큰 HFile로 결합한다. compaction할 HFile 개수와 빈도를 제어할 수 있다. 특정 로우를 읽다가 디스크 읽기를 많이 하다가 전반적인 성능이 저하될 수 있기 때문이다...

- major compaction  : Region의 모든 Store 파일을 읽고 하나의 Store 파일에 저장한다.



CDH 4/HBase 0.96 이전의 기본 정책은 HFile의 목록을 살펴보고 전체 파일 수에 hbase.store.compaction.ratio를 곱한 값보다 작은 크기를 가진 파 중 첫 번째를 찾으려 한다. 만약 해당 파일을 찾으면 HFile과 그보다 작은 id를 가진 모든 파일이 컴팩션되도록 선택된다. 기본 정책은 RatioBasedCompactionPolicy이다(사실 이거 하나였다). 오래된 HFiles부터 시작된다. 하지만, 파일의 age와 size를 기반한 일부 가정이 잘못되었다.



CDH 5/HBase 0.96에서 https://issues.apache.org/jira/browse/HBASE-7516를 통해 사용자가 원하는 compaction(ExploringCompactionPolicy)을 진행할 수 있게 되었다. 모든 파일이 지정된 compaction 비율내에 있음을 보장한다. 그리고 compaction 비율 내에서 첫 번째 파일 집합만 선택하지 않고, 규칙을 위반하지 않은채 가장 IO가 적을 것 같은 것만 선택한다. compaction할 파일을 찾은 후 크기가 작은 파일이 대상이 된다. 그래서 IO 부하를 최소화하는 전략으로 변경했다. 벌크 로딩이 필요한 작업에서는 엄청난 성능 향상이 있다고 한다. 


ExploringCompactionPolicy을 사용하면 minor compaction이 효율적이라서 major compaction이 덜 발생해서 성능이 좋다고 한다. 그래서 기본 compaction 정책으로 사용되어 지금까지 쓰고 있다고 한다. 




ExploringCompactionPolicy에 대한 소스는 https://github.com/apache/hbase/blob/master/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/ExploringCompactionPolicy.java에 있으니 참고할 수 있다. 


ExploringCompactionPolicy이 확장되어 Stripe compaction(https://issues.apache.org/jira/browse/HBASE-7667)이 0.98, 0.99에 추가되었다. 또한 tiered-based compaction(https://issues.apache.org/jira/browse/HBASE-7055)은 개발 중이지만,2015년에 쓴 댓글이 마지막이라서 나올지 의문이다.



다음은 compaction 관련으로 Hortonworks에서 발표한 내용이다(동영상은 https://vimeo.com/69989292을 참조한다).


HBaseCon 2013: Compaction Improvements in Apache HBase from Cloudera, Inc.



참고로 https://hbase.apache.org/book.html#compaction을 참조하면, 

0.94의 RatioBasedCompactionPolicy 동작 순서와 0.96의 ExploringCompactionPolicy 동작 순서를 잘 알 수 있을 것이다. 그리고, hbase compaction property를 참조하면 hbase의 compaction를 더욱 이해할 수 있을 것 같다. 





참조 


https://hbase.apache.org/book.html#compaction


http://blog.cloudera.com/blog/2012/06/hbase-write-path/


http://blog.cloudera.com/blog/2013/12/what-are-hbase-compactions/


https://www.linkedin.com/pulse/hbase-minor-major-compaction-explained-jeetendra-gangele


http://engineering.vcnc.co.kr/2013/04/hbase-configuration/




참고


cassandra의 compaction 전략은 다음을 참조한다. hbase의 compaction은 전체 클러스터의 설정이라면, cassandra의 compaction설정은 테이블 단위이다.


http://knight76.tistory.com/entry/cassadra-compaction-%EC%A0%84%EB%9E%B5

Posted by '김용환'
,


hbase 0.94에서 hbase shell을 사용해서 테이블 추가/삭제를 진행하는 예시이다.




$ hbase shell


16/12/16 14:20:08 WARN conf.Configuration: hadoop.native.lib is deprecated. Instead, use io.native.lib.available

HBase Shell; enter 'help<RETURN>' for list of supported commands.

Type "exit<RETURN>" to leave the HBase Shell

Version 0.94.15-cdh4.7.1, rUnknown, Tue Nov 18 08:51:37 PST 2014



table1을 생성한다.


> create 'table1', 'columnfamily1'

=> Hbase::Table - table1




생성된 테이블이 존재하는지 확인한다. 


> list 'table1'

TABLE

table1



table1 테이블을 삭제하기 위해 drop를 사용하려면 먼저 disable을 먼저 사용하라고 알린다. 


> drop 'table1'


ERROR: Table table1 is enabled. Disable it first.'


Here is some help for this command:

Drop the named table. Table must first be disabled: e.g. "hbase> drop 't1'"




table1 테이블을 삭제하기 위해 disable과 drop을 실행한다.



> disable 'table1'

0 row(s) in 1.1150 seconds


> drop 'table1'

0 row(s) in 1.0580 seconds


> list 'table1'

TABLE

0 row(s) in 0.0230 seconds





데이터를 테이블에 저장하는 예시를 진행한다.



먼저 간단한 google 테이블을 생성한다. 테이블의 이름은 google이고, 컬럼패밀리는 vi 이다. 



> create 'google', 'vi'

0 row(s) in 1.0600 seconds

=> Hbase::Table - google



테이블에 row를 추가하기 위해 put을 사용한다. 



> put 'google', 'row1', 'vi:make', '1'

0 row(s) in 0.0360 seconds


> put 'google', 'row2', 'vi:make', '2'

0 row(s) in 0.0060 seconds


> put 'google', 'row3', 'vi:make', '3'

0 row(s) in 0.0050 seconds


> put 'google', 'row1', 'vi:get', '1'

0 row(s) in 0.0030 seconds


> put 'google', 'row2', 'vi:get', '2'

0 row(s) in 0.0030 seconds


> put 'google', 'row3', 'vi:get', '3'

0 row(s) in 0.0030 seconds





저장한 데이터가 존재하는지 scan으로 확인한다. 



> scan 'google'

ROW                              COLUMN+CELL

 row1                            column=vi:get, timestamp=1481865972730, value=1

 row1                            column=vi:make, timestamp=1481865868177, value=1

 row2                            column=vi:get, timestamp=1481865976807, value=2

 row2                            column=vi:make, timestamp=1481865882636, value=2

 row3                            column=vi:get, timestamp=1481865981007, value=3

 row3                            column=vi:make, timestamp=1481865891477, value=3

3 row(s) in 0.0410 seconds



특정 컬럼 패밀리만 보고 싶다면, scan에 COLUMNS를 추가한다. 


> scan 'google', {COLUMNS => ['vi:make']}

ROW                              COLUMN+CELL

 row1                            column=vi:make, timestamp=1481865868177, value=1

 row2                            column=vi:make, timestamp=1481865882636, value=2

 row3                            column=vi:make, timestamp=1481865891477, value=3

3 row(s) in 0.0850 seconds



해당 커맨드에 LIMIT을 이용해 개수를 지정해서 볼 수 있다.



> scan 'google', {COLUMNS => ['vi:make'], LIMIT => 100}

ROW                              COLUMN+CELL

 row1                            column=vi:make, timestamp=1481865868177, value=1

 row2                            column=vi:make, timestamp=1481865882636, value=2

 row3                            column=vi:make, timestamp=1481865891477, value=3

3 row(s) in 0.0170 seconds


> scan 'google', {COLUMNS => ['vi:make'], LIMIT => 2}

ROW                              COLUMN+CELL

 row1                            column=vi:make, timestamp=1481865868177, value=1

 row2                            column=vi:make, timestamp=1481865882636, value=2

2 row(s) in 0.0090 seconds


> scan 'google', {COLUMNS => ['vi:make'], LIMIT => 1}

ROW                              COLUMN+CELL

 row1                            column=vi:make, timestamp=1481865868177, value=1

1 row(s) in 0.0050 seconds




데이터를 얻으려면 get을 사용하는데, 테이블과 로우 키가 중요하다. 테이블과 컬럼패밀리로 검색하면 값을 얻을 수 없다.


> get 'google', 'vi:make'

COLUMN                           CELL

0 row(s) in 0.0110 seconds



테이블과 로우 키로 데이터를 검색한다. 테이블-로우키로 검색 가능하고, 테이블-로우키-컬럼패밀리로 검색할 수 있다.



> get 'google', 'row1'

COLUMN                                        CELL

 vi:get                                       timestamp=1481865972730, value=1

 vi:make                                      timestamp=1481865868177, value=1

2 row(s) in 0.0340 seconds


> get 'google', 'row1', 'vi:get'

COLUMN                                        CELL

 vi:get                                       timestamp=1481865972730, value=1

1 row(s) in 0.0080 seconds




scan 처럼 get도 COLUMN 단위로 검색할 수 있다. (FILTER, TIMERANGE로도 검색할 수 있다)



> get 'google', 'row1', {COLUMN => [ 'vi:make', 'vi:get' ] }

COLUMN                                        CELL

 vi:get                                       timestamp=1481865972730, value=1

 vi:make                                      timestamp=1481865868177, value=1

2 row(s) in 0.0120 seconds


> get 'google', 'row1', {COLUMN => [ 'vi:get' ] }

COLUMN                                        CELL

 vi:get                                       timestamp=1481865972730, value=1

1 row(s) in 0.0050 seconds





삭제하려면 delete를 사용한다.



> scan 'google'

ROW                              COLUMN+CELL

 row1                            column=vi:get, timestamp=1481865972730, value=1

 row1                            column=vi:make, timestamp=1481865868177, value=1

 row2                            column=vi:get, timestamp=1481865976807, value=2

 row2                            column=vi:make, timestamp=1481865882636, value=2

 row3                            column=vi:get, timestamp=1481865981007, value=3

 row3                            column=vi:make, timestamp=1481865891477, value=3




> delete 'google', 'row1', 'vi:make'

0 row(s) in 0.0120 seconds



scan 해보면 데이터가 삭제된 것을 확인할 수 있다. 



> scan 'google'

ROW                          COLUMN+CELL

 row1                        column=vi:get, timestamp=1481865972730, value=1

 row2                        column=vi:get, timestamp=1481865976807, value=2

 row2                        column=vi:make, timestamp=1481865882636, value=2

 row3                        column=vi:get, timestamp=1481865981007, value=3

 row3                        column=vi:make, timestamp=1481865891477, value=3

3 row(s) in 0.0350 seconds




delete할 때는 테이블-로우키-컬럼패밀리에 맞춰 지워야 한다. delete 테이블-로우키, delete 테이블을 실행시 에러가 발생한다.


> delete 'google', 'row2'

//에러 

> delete 'google'

// 에러





데이터 변경(update)는 put을 그대로 사용한다. 



> get 'google', 'row1'

COLUMN                       CELL

 vi:get                      timestamp=1481865972730, value=1

1 row(s) in 0.0080 seconds



> put 'google', 'row1', 'vi:get', 3

0 row(s) in 0.0120 seconds



> get 'google', 'row1'

COLUMN                       CELL

 vi:get                      timestamp=1481868410482, value=3

1 row(s) in 0.0040 seconds




테이블 삭제하려면, disable -> drop 테이블 과정을 거친다.


여기서는 disable과 enable 테이블을 시도해본 후 drop 테이블을 실행한다.



hbase(main):023:0> disable 'google'

0 row(s) in 1.1310 seconds


disable했기 때문에 scan이나 get하면 DoNotRetryIOException 예외가 발생한다. 


hbase(main):024:0> scan 'google'

ROW                          COLUMN+CELL

ERROR: org.apache.hadoop.hbase.DoNotRetryIOException: google is disabled.

hbase(main):025:0> get 'google', 'row1'
COLUMN                       CELL

ERROR: org.apache.hadoop.hbase.DoNotRetryIOException: google is disabled.


하지만, exists를 실행하면 아직 존재하는지 알 수 있다. 기타 list, decribe를 사용시 제대로 동작 중인지 확인할 수 있다. 


> exists 'google'

Table google does exist

0 row(s) in 0.0250 seconds



> describe 'google'

DESCRIPTION                                                             ENABLED

 'google', {NAME => 'vi', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => false

  'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NO

 NE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => '

 false', BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_ON_DISK =>

 'true', BLOCKCACHE => 'true'}

1 row(s) in 0.0460 seconds



> list 'google'

TABLE

google

1 row(s) in 0.0230 seconds



disable 했던 테이블을 다시 사용하려면 enable을 호출한다. 


> enable 'google'

0 row(s) in 1.1450 seconds



> scan 'google'

ROW                          COLUMN+CELL

 row1                        column=vi:get, timestamp=1481868410482, value=3

 row2                        column=vi:get, timestamp=1481865976807, value=2

 row2                        column=vi:make, timestamp=1481865882636, value=2

 row3                        column=vi:get, timestamp=1481865981007, value=3

 row3                        column=vi:make, timestamp=1481865891477, value=3

3 row(s) in 0.0210 seconds




google 테이블을 삭제한다. 



> disable 'google'

0 row(s) in 1.1450 seconds


> drop 'google'

0 row(s) in 1.0570 seconds


Posted by '김용환'
,


hbase 0.94를 사용하고 있다. 


(아주 당연하지만..)

hbase 커맨드 쉘에서는 quote(')의 사용이 반드시 필요한데, 이상하게도 나는 describe 또는 list를 사용할 때면 quote를 사용하지 않으려 하는 습관이 있다. mysql 영향을 받아서 그런 것 같다.



subscribe/list 커맨드를 사용할 때, quote(')를 사용하지 않으면 찾지 못한다. 항상 quote를 사용해야 한다!!!





hbase(main):002:0> list notifications

NameError: undefined local variable or method `notifications' for #<Object:0x3e4eede1>




hbase(main):003:0> list 'notifications'


TABLE

notifications

feed_notifications


2 row(s) in 0.0240 seconds





hbase(main):004:0> list 'not*'


TABLE

notifications

feed_notifications


2 row(s) in 0.0240 seconds



Posted by '김용환'
,