HBase 도구와 유틸리티
HBase 도구와 유틸리티 (HBase Tools and Utilities)
HBase가 제공하는 관리·분석·디버깅용 도구들을 소개하는 페이지예요. 대부분의 도구는 bin/hbase 명령으로 진입하며 일부는 dev-support/ 디렉토리에 있어요. Canary, RegionSplitter, CopyTable, Export/Import, HBCK2, ImportTsv, WALPlayer 같은 유용한 도구들을 자세히 다룬답니다.
출처: 문서
본문
HBase는 클러스터의 관리, 분석, 디버깅을 위한 여러 도구를 제공해요. 대부분의 도구의 진입점은 bin/hbase 명령이며, 일부 도구는 dev-support/ 디렉토리에서 사용할 수 있어요.
bin/hbase 명령의 사용 지침을 보려면 인자 없이 실행하거나 -h 인자로 실행하세요. 다음은 HBase 0.98.x의 사용 지침이에요. version, pe, ltt, clean 같은 일부 명령은 이전 버전에는 없어요.
$ bin/hbase
Usage: hbase [<options>] <command> [<args>]
Options:
--config DIR Configuration direction to use. Default: ./conf
--hosts HOSTS Override the list in 'regionservers' file
--auth-as-server Authenticate to ZooKeeper using servers configuration
Commands:
Some commands take arguments. Pass no args or -h for usage.
shell Run the HBase shell
hbck Run the HBase 'fsck' tool. Defaults read-only hbck1.
Pass '-j /path/to/HBCK2.jar' to run hbase-2.x HBCK2.
snapshot Tool for managing snapshots
wal Write-ahead-log analyzer
hfile Store file analyzer
zkcli Run the ZooKeeper shell
master Run an HBase HMaster node
regionserver Run an HBase HRegionServer node
zookeeper Run a ZooKeeper server
rest Run an HBase REST server
thrift Run the HBase Thrift server
thrift2 Run the HBase Thrift2 server
clean Run the HBase clean up script
jshell Run a jshell with HBase on the classpath
classpath Dump hbase CLASSPATH
mapredcp Dump CLASSPATH entries required by mapreduce
pe Run PerformanceEvaluation
ltt Run LoadTestTool
canary Run the Canary tool
version Print the version
backup Backup tables for recovery
restore Restore tables from existing backup image
regionsplitter Run RegionSplitter tool
rowcounter Run RowCounter tool
cellcounter Run CellCounter tool
CLASSNAME Run the class named CLASSNAME
아래 도구·유틸리티 중 일부는 사용 지침의 마지막 줄에서 언급한 것처럼 bin/hbase 명령에 직접 전달되는 Java 클래스예요. 그 외에 hbase shell(The Apache HBase Shell), hbase upgrade(Upgrading), hbase thrift(Thrift API and Filter Language) 같은 것은 이 가이드의 다른 곳에 문서화되어 있어요.
Canary
Canary 도구는 사용자가 HBase 클러스터 상태를 "canary-test"하는 데 도움을 줘요. 기본 "region mode"는 모든 region의 모든 column-family에서 행 하나를 가져와요. "regionserver mode"에서는 Canary 도구가 클러스터의 각 RegionServer의 임의 region에서 행 하나를 가져와요. "zookeeper mode"에서는 Canary가 zookeeper 앙상블의 각 member에서 루트 znode를 읽어요.
사용법을 보려면 -help 파라미터를 전달하세요(파라미터를 전달하지 않으면 Canary 도구는 기본 region "mode"로 실행을 시작해 클러스터의 모든 region에서 행 하나를 가져와요).
2018-10-16 13:11:27,037 INFO [main] tool.Canary: Execution thread count=16
Usage: canary [OPTIONS] [<TABLE1> [<TABLE2]...] | [<REGIONSERVER1> [<REGIONSERVER2]..]
Where [OPTIONS] are:
-h,-help show this help and exit.
-regionserver set 'regionserver mode'; gets row from random region on server
-allRegions get from ALL regions when 'regionserver mode', not just random one.
-zookeeper set 'zookeeper mode'; grab zookeeper.znode.parent on each ensemble member
-daemon continuous check at defined intervals.
-interval <N> interval between checks in seconds
-e consider table/regionserver argument as regular expression
-f <B> exit on first error; default=true
-failureAsError treat read/write failure as error
-t <N> timeout for canary-test run; default=600000ms
-writeSniffing enable write sniffing
-writeTable the table used for write sniffing; default=hbase:canary
-writeTableTimeout <N> timeout for writeTable; default=600000ms
-readTableTimeouts <tableName>=<read timeout>,<tableName>=<read timeout>,...
comma-separated list of table read timeouts (no spaces);
logs 'ERROR' if takes longer. default=600000ms
-permittedZookeeperFailures <N> Ignore first N failures attempting to
connect to individual zookeeper nodes in ensemble
-D<configProperty>=<value> to assign or override configuration params
-Dhbase.canary.read.raw.enabled=<true/false> Set to enable/disable raw scan; default=false
Canary는 region(기본), regionserver, zookeeper의 세 가지 모드 중 하나로 실행돼요. 모든 region을 스니핑/프로빙하려면 인자 없이 실행하세요. 테이블의 모든 region을 스니핑하려면 테이블 이름을 전달하세요. regionserver를 스니핑하려면 -regionserver 등을 전달하세요. Canary 문서는 https://hbase.apache.org/docs/operational-management/tools#canary 를 참고하세요.
Sink 클래스는 hbase.canary.sink.class 설정 속성을 사용해서 인스턴스화돼요.
이 도구는 Nagios 같은 다른 모니터링 도구와 협업하기 위해 사용자에게 0이 아닌 오류 코드를 반환해요. 오류 코드 정의는 다음과 같아요:
private static final int USAGE_EXIT_CODE = 1;
private static final int INIT_ERROR_EXIT_CODE = 2;
private static final int TIMEOUT_ERROR_EXIT_CODE = 3;
private static final int ERROR_EXIT_CODE = 4;
private static final int FAILURE_EXIT_CODE = 5;
다음과 같은 경우를 예시로 몇 가지를 들어볼게요. 두 개의 Table 객체 test-01과 test-02가 각각 cf1, cf2 두 개의 column family를 가지고 3개의 RegionServer에 배포된 경우요. 다음 표를 확인하세요.
| RegionServer | test-01 | test-02 |
|---|---|---|
| rs1 | r1 | r2 |
| rs2 | r2 | |
| rs3 | r2 | r1 |
다음은 앞선 경우에 기반한 몇 가지 예시 출력이에요.
모든 테이블의 모든 region의 모든 column family(store)에 대한 Canary 테스트
$ ${HBASE_HOME}/bin/hbase canary
3/12/09 03:26:32 INFO tool.Canary: read from region test-01,,1386230156732.0e3c7d77ffb6361ea1b996ac1042ca9a. column family cf1 in 2ms
13/12/09 03:26:32 INFO tool.Canary: read from region test-01,,1386230156732.0e3c7d77ffb6361ea1b996ac1042ca9a. column family cf2 in 2ms
13/12/09 03:26:32 INFO tool.Canary: read from region test-01,0004883,1386230156732.87b55e03dfeade00f441125159f8ca87. column family cf1 in 4ms
13/12/09 03:26:32 INFO tool.Canary: read from region test-01,0004883,1386230156732.87b55e03dfeade00f441125159f8ca87. column family cf2 in 1ms
...
13/12/09 03:26:32 INFO tool.Canary: read from region test-02,,1386559511167.aa2951a86289281beee480f107bb36ee. column family cf1 in 5ms
13/12/09 03:26:32 INFO tool.Canary: read from region test-02,,1386559511167.aa2951a86289281beee480f107bb36ee. column family cf2 in 3ms
13/12/09 03:26:32 INFO tool.Canary: read from region test-02,0004883,1386559511167.cbda32d5e2e276520712d84eaaa29d84. column family cf1 in 31ms
13/12/09 03:26:32 INFO tool.Canary: read from region test-02,0004883,1386559511167.cbda32d5e2e276520712d84eaaa29d84. column family cf2 in 8ms
보시다시피 test-01 테이블은 2개 region과 2개 column family가 있으므로 기본 "region mode"의 Canary 도구는 4개(2 region * 2 store) 서로 다른 store에서 4개의 작은 데이터 조각을 고를 거예요. 이것이 기본 동작이에요.
특정 테이블의 모든 region의 모든 column family(store)에 대한 Canary 테이스트
테이블 이름을 전달해서 하나 이상의 특정 테이블도 테스트할 수 있어요.
$ ${HBASE_HOME}/bin/hbase canary test-01 test-02
RegionServer 단위의 Canary 테스트
"regionserver mode"에서 Canary 도구는 각 RegionServer에서 작은 데이터 조각 하나를 골라요("regionserver mode"에서 canary-test 인자로 하나 이상의 RegionServer 이름을 전달할 수도 있어요).
$ ${HBASE_HOME}/bin/hbase canary -regionserver
13/12/09 06:05:17 INFO tool.Canary: Read from table:test-01 on region server:rs2 in 72ms
13/12/09 06:05:17 INFO tool.Canary: Read from table:test-02 on region server:rs3 in 34ms
13/12/09 06:05:17 INFO tool.Canary: Read from table:test-01 on region server:rs1 in 56ms
정규 표현식 패턴의 Canary 테스트
"region mode"에서는 테이블 이름에, "regionserver mode"에서는 서버 이름에 정규식을 전달할 수 있어요. 아래는 test-01과 test-02 테이블을 모두 테스트해요.
$ ${HBASE_HOME}/bin/hbase canary -e test-0[1-2]
"daemon"으로 Canary 테스트 실행
-interval 옵션으로 정의된 간격(기본값 60초)으로 반복 실행해요. 이 daemon은 오류가 발생하면 스스로 멈추고 0이 아닌 오류 코드를 반환해요. daemon이 오류를 지나서 계속 실행되게 하려면 -f 플래그를 값 false로 전달하세요(위 사용법 참고).
$ ${HBASE_HOME}/bin/hbase canary -daemon
5초 간격으로 반복 실행하고 오류에도 멈추지 않게 하려면 다음처럼 하세요.
$ ${HBASE_HOME}/bin/hbase canary -daemon -interval 5 -f false
Canary 테스트가 멈추면 강제 타임아웃
어떤 경우 요청이 멈추고 클라이언트에 응답이 돌아오지 않아요. master가 아직 알아차리지 못한 죽은 RegionServer에서 이런 일이 생길 수 있어요. 그래서 canary 테스트를 종료하고 0이 아닌 오류 코드를 반환하는 타임아웃 옵션을 제공해요. 아래는 타임아웃 값을 60초로 설정한 예시예요(기본값은 600초).
$ ${HBASE_HOME}/bin/hbase canary -t 60000
canary에서 write sniffing 활성화
기본적으로 canary 도구는 읽기 연산만 확인해요. write sniffing을 활성화하려면 -writeSniffing 옵션을 설정해서 canary를 실행할 수 있어요. write sniffing이 활성화되면 canary 도구가 hbase 테이블을 만들고 테이블의 region들이 모든 region server에 분산되도록 해요. 각 스니핑 주기에 canary는 이 region들에 데이터를 put해서 각 region server의 쓰기 가용성을 확인해요.
$ ${HBASE_HOME}/bin/hbase canary -writeSniffing
기본 write table은 hbase:canary이고 -writeTable 옵션으로 지정할 수 있어요.
$ ${HBASE_HOME}/bin/hbase canary -writeSniffing -writeTable ns:canary
각 put의 기본 값 크기는 10바이트예요. hbase.canary.write.value.size 설정 키로 설정할 수 있어요.
읽기/쓰기 실패를 오류로 처리
기본적으로 canary 도구는 예: RetriesExhaustedException 등으로 인한 읽기 실패만 로그하고 '정상' 종료 코드를 반환해요. 읽기/쓰기 실패를 오류로 처리하려면 -treatFailureAsError 옵션으로 canary를 실행할 수 있어요. 활성화되면 읽기/쓰기 실패가 오류 종료 코드가 되어요.
$ ${HBASE_HOME}/bin/hbase canary -treatFailureAsError
Kerberos 활성 클러스터에서 Canary 실행
Kerberos 활성 클러스터에서 Canary를 실행하려면 hbase-site.xml에 다음 두 속성을 구성하세요:
hbase.client.keytab.filehbase.client.kerberos.principal
Kerberos 자격 증명은 Canary가 daemon 모드로 실행될 때 30초마다 갱신돼요.
클라이언트의 DNS 인터페이스를 구성하려면 hbase-site.xml에 다음 선택적 속성을 구성하세요.
hbase.client.dns.interfacehbase.client.dns.nameserver
Kerberos 활성 클러스터에서의 Canary 예
이 예는 각 속성을 유효한 값과 함께 보여줘요.
<property>
<name>hbase.client.kerberos.principal</name>
<value>hbase/[email protected]</value>
</property>
<property>
<name>hbase.client.keytab.file</name>
<value>/etc/hbase/conf/keytab.krb5</value>
</property>
<property>
<name>hbase.client.dns.interface</name>
<value>default</value>
</property>
<property>
<name>hbase.client.dns.nameserver</name>
<value>default</value>
</property>
RegionSplitter
usage: bin/hbase regionsplitter <TABLE> <SPLITALGORITHM>
SPLITALGORITHM is the java class name of a class implementing
SplitAlgorithm, or one of the special strings
HexStringSplit or DecimalStringSplit or
UniformSplit, which are built-in split algorithms.
HexStringSplit treats keys as hexadecimal ASCII, and
DecimalStringSplit treats keys as decimal ASCII, and
UniformSplit treats keys as arbitrary bytes.
-c <region count> Create a new table with a pre-split number of
regions
-D <property=value> Override HBase Configuration Settings
-f <family:family:...> Column Families to create with new table.
Required with -c
--firstrow <arg> First Row in Table for Split Algorithm
-h Print this usage help
--lastrow <arg> Last Row in Table for Split Algorithm
-o <count> Max outstanding splits that have unfinished
major compactions
-r Perform a rolling split of an existing region
--risky Skip verification steps to complete
quickly. STRONGLY DISCOURAGED for production
systems.
추가 세부 사항은 Manual Region Splitting을 참고하세요.
Health Checker
HBase를 정기적으로 스크립트를 실행하고 N번(설정 가능) 실패하면 서버가 종료되도록 구성할 수 있어요. 설정과 세부 사항은 HBASE-7351 Periodic health check script를 참고하세요.
Driver
자주 접근되는 여러 유틸리티가 Driver 클래스로 제공되고 bin/hbase 명령으로 실행돼요. 이 유틸리티들은 클러스터에서 실행되는 MapReduce 작업을 나타내요. 실행하려는 유틸리티 이름으로 UtilityName을 바꿔 다음 방식으로 실행해요. 이 명령은 환경 변수 HBASE_HOME을 서버에서 HBase가 압축 해제된 디렉토리로 설정했다고 가정해요.
${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.mapreduce.UtilityName
사용 가능한 유틸리티는 다음과 같아요:
LoadIncrementalHFiles
벌크 데이터 로드를 완료해요.
CopyTable
로컬 클러스터에서 피어 클러스터로 테이블을 내보내요.
Export
테이블 데이터를 HDFS에 써요.
Import
이전 Export 작업이 쓴 데이터를 가져와요.
ImportTsv
TSV 형식 데이터를 가져와요.
RowCounter
HBase 테이블의 행을 세요.
CellCounter
HBase 테이블의 셀을 세요.
replication.VerifyReplication
두 개의 서로 다른 클러스터에 있는 테이블의 데이터를 비교해요. 경고: 타임스탬프가 변경되므로 incrementColumnValues된 셀에는 작동하지 않아요. 이 명령은 다른 명령들과 다른 패키지에 있다는 점에 주의하세요.
RowCounter와 CellCounter를 제외한 각 명령은 사용 지침을 출력하는 단일 --help 인자를 받아들여요.
HBase hbck
hbase-1.x에 포함된 hbck 도구는 hbase-2.x에서 읽기 전용으로 바뀌었어요. hbase 내부가 변경되었으므로 hbase-2.x 클러스터를 복구할 수 없어요. 또한 hbase-2.x 동작을 이해하지 못하므로 읽기 전용 모드의 평가도 신뢰해서는 안 돼요.
다음 섹션에서 설명하는 새 도구 HBase HBCK2가 hbck를 대체해요.
HBase HBCK2
HBCK2는 HBase HBCK의 후속작이에요. hbase-1.x 수정 도구(일명 hbck1)죠. hbase-2.x 설치에 대한 복구를 수행할 때 hbck1 대신 사용하세요.
HBCK2는 hbase의 일부로 제공되지 않아요. 동반 hbase-operator-tools 저장소의 하위 프로젝트인 Apache HBase HBCK2 Tool에서 찾을 수 있어요. HBCK2는 hbase 코어와 다른 주기로 발전할 수 있도록 hbase에서 분리되었어요.
HBCK2가 hbck1과 어떻게 다른지, 어떻게 빌드하고 사용하는지는 HBCK2 홈페이지를 참고하세요.
빌드가 끝나면 HBCK2를 다음과 같이 실행할 수 있어요:
$ hbase hbck -j /path/to/HBCK2.jar
그러면 명령과 옵션을 설명하는 HBCK2 사용법이 생성돼요.
HFile 도구 (HFile Tool)
HFile Tool 참고.
WAL 도구 (WAL Tools)
WAL 파일이나 recovered.edits 파일을 벌크로 재생하려면 WALPlayer를 참고하세요. 개별 파일을 읽거나 검증하려면 계속 읽어보세요.
WALPrettyPrinter
WALPrettyPrinter는 WAL 또는 recovered.edits 파일의 내용을 출력하는 설정 가능한 옵션을 가진 도구예요. 'wal' 명령으로 HBase cli를 통해 호출할 수 있어요.
$ ./bin/hbase wal hdfs://example.org:9000/hbase/WALs/example.org,60020,1283516293161/10.10.21.10%3A60020.1283973724012
WAL Printing in older versions of HBase2.0 이전 버전에서 WALPrettyPrinter는 HBase의 write ahead log의 내부 이름을 따서 HLogPrettyPrinter라고 불렸어요. 그 버전들에서는 위와 같은 구성으로 'hlog' 명령을 사용해서 WAL 내용을 출력할 수 있어요. $ ./bin/hbase hlog hdfs://example.org:9000/hbase/.logs/example.org,60020,1283516293161/10.10.21.10%3A60020.1283973724012
압축 도구 (Compression Tool)
compression.test 참고.
CopyTable
CopyTable은 테이블의 일부 또는 전체를 같은 클러스터나 다른 클러스터로 복사할 수 있는 유틸리티예요. 대상 테이블은 먼저 존재해야 해요. 사용법은 다음과 같아요:
$ ./bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --help
/bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --help
Usage: CopyTable [general options] [--starttime=X] [--endtime=Y] [--new.name=NEW] [--peer.adr=ADR] <tablename>
Options:
rs.class hbase.regionserver.class of the peer cluster,
specify if different from current cluster
rs.impl hbase.regionserver.impl of the peer cluster,
startrow the start row
stoprow the stop row
starttime beginning of the time range (unixtime in millis)
without endtime means from starttime to forever
endtime end of the time range. Ignored if no starttime specified.
versions number of cell versions to copy
new.name new table's name
peer.uri The URI of the peer cluster
peer.adr Address of the peer cluster given in the format
hbase.zookeeer.quorum:hbase.zookeeper.client.port:zookeeper.znode.parent
Do not take effect if peer.uri is specified
Deprecated, please use peer.uri instead
families comma-separated list of families to copy
To copy from cf1 to cf2, give sourceCfName:destCfName.
To keep the same name, just give "cfName"
all.cells also copy delete markers and deleted cells
Args:
tablename Name of the table to copy
Examples:
To copy 'TestTable' to a cluster that uses replication for a 1 hour window:
$ bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --starttime=1265875194289 --endtime=1265878794289 --peer.adr=server1,server2,server3:2181:/hbase --families=myOldCf:myNewCf,cf2,cf3 TestTable
성능을 위해 다음 일반 옵션을 고려하세요:
다음 값들을 >=100으로 설정하는 것을 권장해요. 값이 높을수록 메모리를 더 쓰지만
서버 왕복 시간이 줄어들어 성능이 좋아질 수 있어요.
-Dhbase.client.scanner.caching=100
다음은 항상 false로 설정해서 데이터가 두 번 쓰이는 것을 방지해야 해요. 부정확한 결과를
만들 수 있으니까요.
-Dmapred.map.tasks.speculative.execution=false
3.0.0부터 peer.uri 옵션을 도입해서 peer.adr 옵션은 deprecated되었어요. HBase 클러스터를 지정할 때 연결 URI를 사용하세요. 모든 이전 버전에서는 계속 peer.adr 옵션을 사용해야 해요.
Scanner Caching입력 Scan의 캐싱은 작업
설정의 hbase.client.scanner.caching으로 구성돼요.
Versions기본적으로 CopyTable 유틸리티는 명령에서 --versions=n을
명시적으로 지정하지 않는 한 행 셀의 최신 버전만 복사해요.
Data LoadCopyTable은 diff를 수행하지 않아요. 지정된 startrow/stoprow starttime/endtime 범위 사이의 모든 Cell을 복사하죠. 즉 이미 존재하는 같은 값의 셀도 계속 복사된다는 뜻이에요.
CopyTable에 대한 자세한 내용은 Jonathan Hsieh의 Online HBase Backups with CopyTable 블로그 게시물을 참고하세요.
HashTable/SyncTable
HashTable/SyncTable은 테이블 데이터를 동기화하는 두 단계 도구예요. 각 단계는 MapReduce 작업으로 구현돼요. CopyTable과 비슷하게, 같은 클러스터나 원격 클러스터에서 테이블 데이터의 일부 또는 전체를 동기화하는 데 사용할 수 있어요. 하지만 CopyTable보다 더 효율적인 방식으로 동기화를 수행해요. 지정된 row key/시간 기간 범위의 모든 셀을 복사하는 대신, HashTable(첫 번째 단계)은 소스 테이블의 셀 배치에 대해 해시 인덱스를 만들어 이를 결과로 출력해요. 다음 단계에서 SyncTable은 소스 테이블을 스캔하고 이제 테이블 셀의 해시 인덱스를 계산해 이 해시들을 HashTable의 출력과 비교한 다음, 해시가 다른 셀만 스캔(및 비교)해서 일치하지 않는 셀만 업데이트해요. 이렇게 하면 네트워크 트래픽/데이터 전송이 줄어드는데, 원격 클러스터에서 큰 테이블을 동기화할 때 영향력이 커요.
1단계, HashTable
먼저 소스 테이블 클러스터(그 상태가 대응 테이블로 복사될 테이블)에서 HashTable을 실행하세요.
사용법:
$ ./bin/hbase org.apache.hadoop.hbase.mapreduce.HashTable --help
Usage: HashTable [options] <tablename> <outputpath>
Options:
batchsize the target amount of bytes to hash in each batch
rows are added to the batch until this size is reached
(defaults to 8000 bytes)
numhashfiles the number of hash files to create
if set to fewer than number of regions then
the job will create this number of reducers
(defaults to 1/100 of regions — at least 1)
startrow the start row
stoprow the stop row
starttime beginning of the time range (unixtime in millis)
without endtime means from starttime to forever
endtime end of the time range. Ignored if no starttime specified.
scanbatch scanner batch size to support intra row scans
versions number of cell versions to include
families comma-separated list of families to include
ignoreTimestamps if true, ignores cell timestamps
Args:
tablename Name of the table to hash
outputpath Filesystem path to put the output data
Examples:
To hash 'TestTable' in 32kB batches for a 1 hour window into 50 files:
$ bin/hbase org.apache.hadoop.hbase.mapreduce.HashTable --batchsize=32000 --numhashfiles=50 --starttime=1265875194289 --endtime=1265878794289 --families=cf2,cf3 TestTable /hashes/testTable
batchsize 속성은 주어진 region에 대해 얼마나 많은 셀 데이터가 단일 해시 값으로 함께 해시될지 정의해요. 이 값을 적절히 조정하면 동기화 효율에 직접적인 영향을 줘요. SyncTable(프로세스의 다음 단계)의 mapper 작업이 수행하는 스캔 수를 줄일 수 있으니까요. 경험 법칙상, 동기화되지 않는 셀 수가 적을수록(diff를 찾을 확률이 낮을수록) 더 큰 batch size 값을 정할 수 있어요.
2단계, SyncTable
소스 클러스터에서 HashTable이 완료되면 대상 클러스터에서 SyncTable을 실행할 수 있어요. 복제 및 다른 동기화 작업처럼, 소스 클러스터의 모든 RegionServer/DataNode가 대상 클러스터(SyncTable 작업 태스크가 실행될)의 NodeManager에서 접근 가능해야 해요.
사용법:
$ ./bin/hbase org.apache.hadoop.hbase.mapreduce.SyncTable --help
Usage: SyncTable [options] <sourcehashdir> <sourcetable> <targettable>
Options:
sourceuri Cluster connection uri of the source table
(defaults to cluster in classpath's config)
sourcezkcluster ZK cluster key of the source table
(defaults to cluster in classpath's config)
Do not take effect if sourceuri is specifie
Deprecated, please use sourceuri instead
targeturi Cluster connection uri of the target table
(defaults to cluster in classpath's config)
targetzkcluster ZK cluster key of the target table
(defaults to cluster in classpath's config)
Do not take effect if targeturi is specified
Deprecated, please use targeturi instead
dryrun if true, output counters but no writes
(defaults to false)
doDeletes if false, does not perform deletes
(defaults to true)
doPuts if false, does not perform puts
(defaults to true)
ignoreTimestamps if true, ignores cells timestamps while comparing
cell values. Any missing cell on target then gets
added with current time as timestamp
(defaults to false)
Args:
sourcehashdir path to HashTable output dir for source table
(see org.apache.hadoop.hbase.mapreduce.HashTable)
sourcetable Name of the source table to sync from
targettable Name of the target table to sync to
Examples:
For a dry run SyncTable of tableA from a remote source cluster
to a local target cluster:
$ bin/hbase org.apache.hadoop.hbase.mapreduce.SyncTable --dryrun=true --sourcezkcluster=zk1.example.com,zk2.example.com,zk3.example.com:2181:/hbase hdfs://nn:9000/hashes/tableA tableA tableA
3.0.0부터 sourceuri와 targeturi 옵션을 도입해서 sourcezkcluster와 targetzkcluster는 deprecated되었어요. HBase 클러스터를 지정할 때 연결 URI를 사용하세요. 모든 이전 버전에서는 계속 sourcezkcluster와 targetzkcluster를 사용해야 해요.
셀 비교는 동등성을 위해 ROW/FAMILY/QUALIFIER/TIMESTAMP/VALUE를 고려해요. 대상에서 동기화할 때 누락된 셀은 소스의 원본 타임스탬프 값으로 추가돼요. 이는 SyncTable 완료 후 예기치 않은 결과를 초래할 수 있어요. 예를 들어 대상의 누락된 셀에 타임스탬프 T2(예: 실수로 수행한 벌크 삭제)의 delete marker가 있지만 소스 셀 타임스탬프가 더 오래된 값 T1이라면, 이 셀들은 더 새로운 delete marker 타임스탬프 때문에 대상에서 여전히 사용할 수 없게 돼요. 셀 타임스탬프가 모든 사용 사례에 관련이 있는 것은 아니므로, ignoreTimestamps 옵션은 비교에서 셀 타임스탬프를 사용하지 않는 유연성을 제공해요. ignoreTimestamps를 true로 사용할 때는 이 옵션을 HashTable과 SyncTable 두 단계 모두에서 지정해야 해요.
dryrun 옵션은 읽기 전용 diff 보고서만 원할 때 유용해요. 차이를 나타내는 COUNTERS만 생성하고 실제 변경을 수행하지 않으니까요. VerifyReplication 도구의 대안으로 사용할 수 있어요.
기본적으로 SyncTable은 대상 테이블을 소스 테이블의 정확한 복사본(지정된 startrow/stoprow 또는/및 starttime/endtime에 대해 적어도)이 되게 해요.
doDeletes를 false로 설정하면 대상에서 소스에 없는 셀을 삭제하지 않도록 기본 동작을 변경해요. 비슷하게 doPuts를 false로 설정하면 대상에 누락된 셀을 추가하지 않도록 기본 동작을 변경해요. doDeletes와 doPuts를 모두 false로 설정하면 dryrun을 true로 설정한 것과 같은 효과를 줘요.
Additional info on doDeletes/doPuts"doDeletes/doPuts"는 HBASE-20305에 의해서만 추가되었으므로 모든 릴리스 버전에서 사용할 수 있지 않을 수 있어요. 1.x 주요 버전의 경우 이 기능을 포함한 최소 마이너 릴리스는 1.4.10이에요. 2.x 주요 버전의 경우 최소 마이너 릴리스는 2.1.5예요.
Additional info on ignoreTimestamps"ignoreTimestamps"는 HBASE-24302에 의해서만 추가되었으므로 모든 릴리스 버전에서 사용할 수 있지 않을 수 있어요. 1.x 주요 버전의 경우 최소 마이너 릴리스는 1.4.14이에요. 2.x 주요 버전의 경우 최소 마이너 릴리스는 2.2.5예요.
Set doDeletes to false on Two-Way Replication scenarios양방향 복제나 소스와 대상 클러스터 모두에 데이터가 유입될 수 있는 다른 시나리오에서는 항상 doDeletes 옵션을 false로 설정하는 것이 좋아요. SyncTable 대상 클러스터에 삽입되어 아직 소스로 복제되지 않은 추가 셀이 삭제되어 잠재적으로 영구적으로 손실될 수 있으니까요.
Set sourcezkcluster to the actual source cluster ZK quorum필수는 아니지만, sourcezkcluster를 설정하지 않으면 SyncTable은 소스와 대상 모두 로컬 HBase 클러스터에 연결하는데, 이는 의미 있는 결과를 주지 않아요.
Remote Clusters on different Kerberos Realms종종 원격 클러스터가 서로 다른 Kerberos 영역에 배포될 수 있어요. HBASE-20586은 크로스 영역 인증을 위한 SyncTable 지원을 추가해서, 대상 클러스터에서 실행되는 SyncTable 프로세스가 소스 클러스터에 연결해 HashTable 출력 파일과 주어진 HBase 테이블을 필요한 비교를 수행할 때 모두 읽을 수 있게 해요.
Export
Export는 테이블 내용을 sequence 파일로 HDFS에 덤프하는 유틸리티예요. Export는 Coprocessor Endpoint 또는 MapReduce로 실행할 수 있어요. 호출 방법은:
mapreduce 기반 Export
$ bin/hbase org.apache.hadoop.hbase.mapreduce.Export TABLENAME OUTPUTDIR [VERSIONS [STARTTIME [ENDTIME]]]
endpoint 기반 Export
org.apache.hadoop.hbase.coprocessor.Export를
hbase.coprocessor.region.classes에 추가해서 Export 코프로세서가 활성화되어 있는지 확인하세요.
$ bin/hbase org.apache.hadoop.hbase.coprocessor.Export TABLENAME OUTPUTDIR [VERSIONS [STARTTIME [ENDTIME]]]
outputdir는 export 전에 존재하지 않는 HDFS 디렉토리예요. 완료되면 내보낸 파일은 export 명령을 호출한 사용자가 소유해요.
Endpoint 기반 Export와 Mapreduce 기반 Export의 비교
| Endpoint-based Export | Mapreduce-based Export |
|---|---|
| HBase version requirement | 2.0+ |
| Maven dependency | hbase-endpoint |
| Requirement before dump | mount the endpoint. Export on the target table |
| Read latency | low, directly read the data from region |
| Read Scalability | depend on number of regions |
| Timeout | operation timeout. configured by hbase.client.operation.timeout |
| Permission requirement | READ, EXECUTE |
| Fault tolerance | no |
사용 지침을 보려면 옵션 없이 명령을 실행하세요. 사용 가능한 옵션에는 export 중 column families 지정과 필터 적용이 포함돼요.
기본적으로 Export 도구는 저장된 버전 수와 무관하게 주어진 셀의 최신 버전만 내보내요. 한 버전 이상을 내보내려면 <versions>를 원하는 버전 수로 바꾸세요.
mapreduce 기반 Export의 경우 셀 태그를 내보내려면 hbase.client.rpc.codec 설정 속성을 org.apache.hadoop.hbase.codec.KeyValueCodecWithTags로 설정하세요.
참고: 입력 Scan의 캐싱은 작업 구성의 hbase.client.scanner.caching으로 설정돼요.
Import
Import는 내보낸 데이터를 HBase에 다시 로드하는 유틸리티예요. 호출 방법:
$ bin/hbase -Dhbase.import.version=0.94 org.apache.hadoop.hbase.mapreduce.Import <tablename> <inputdir>
사용 지침을 보려면 옵션 없이 명령을 실행하세요.
0.94에서 내보낸 파일을 0.96 이상 클러스터에 가져오려면 import 명령을 실행할 때 시스템 속성 "hbase.import.version"을 아래처럼 설정해야 해요:
$ bin/hbase -Dhbase.import.version=0.94 org.apache.hadoop.hbase.mapreduce.Import TABLENAME INPUTDIR
셀 태그를 가져오려면 hbase.client.rpc.codec 설정 속성을 org.apache.hadoop.hbase.codec.KeyValueCodecWithTags로 설정하세요.
ImportTsv
ImportTsv는 TSV 형식 데이터를 HBase로 로드하는 유틸리티예요. 두 가지 구분된 용법이 있어요: HDFS의 TSV 형식 데이터를 Puts를 통해 HBase로 로드하는 것과, completebulkload를 통해 로드할 StoreFiles를 준비하는 것이에요.
Puts를 통해 데이터를 로드하려면(즉 비-벌크 로딩):
$ bin/hbase org.apache.hadoop.hbase.mapreduce.ImportTsv -Dimporttsv.columns=a,b,c <tablename> <hdfs-inputdir>
벌크 로딩용 StoreFiles를 생성하려면:
$ bin/hbase org.apache.hadoop.hbase.mapreduce.ImportTsv -Dimporttsv.columns=a,b,c -Dimporttsv.bulk.output=hdfs://storefile-outputdir <tablename> <hdfs-data-inputdir>
이렇게 생성된 StoreFiles는 completebulkload를 통해 HBase에 로드할 수 있어요.
ImportTsv 옵션
인자 없이 ImportTsv를 실행하면 간단한 사용 정보가 출력돼요:
Usage: importtsv -Dimporttsv.columns=a,b,c TABLENAME INPUTDIR
Imports the given input directory of TSV data into the specified table.
The column names of the TSV data must be specified using the -Dimporttsv.columns
option. This option takes the form of comma-separated column names, where each
column name is either a simple column family, or a columnfamily:qualifier. The special
column name HBASE_ROW_KEY is used to designate that this column should be used
as the row key for each imported record. You must specify exactly one column
to be the row key, and you must specify a column name for every column that exists in the
input data.
By default importtsv will load data directly into HBase. To instead generate
HFiles of data to prepare for a bulk data load, pass the option:
-Dimporttsv.bulk.output=/path/for/output
Note: the target table will be created with default column family descriptors if it does not already exist.
Other options that may be specified with -D include:
-Dimporttsv.skip.bad.lines=false - fail if encountering an invalid line
'-Dimporttsv.separator=|' - eg separate on pipes instead of tabs
-Dimporttsv.timestamp=currentTimeAsLong - use the specified timestamp for the import
-Dimporttsv.mapper.class=my.Mapper - A user-defined Mapper to use instead of org.apache.hadoop.hbase.mapreduce.TsvImporterMapper
ImportTsv 예
예를 들어 'd'라는 ColumnFamily와 두 컬럼 "c1"과 "c2"를 가진 'datatsv'라는 테이블에 데이터를 로드한다고 가정해 보세요.
입력 파일이 다음과 같이 존재한다고 가정해요:
row1 c1 c2
row2 c1 c2
row3 c1 c2
row4 c1 c2
row5 c1 c2
row6 c1 c2
row7 c1 c2
row8 c1 c2
row9 c1 c2
row10 c1 c2
ImportTsv가 이 입력 파일을 사용하려면 명령줄이 이렇게 생겨야 해요:
HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-mapreduce-VERSION.jar importtsv -Dimporttsv.columns=HBASE_ROW_KEY,d:c1,d:c2 -Dimporttsv.bulk.output=hdfs://storefileoutput datatsv hdfs://inputfile
그리고 이 예에서 첫 번째 컬럼은 rowkey이므로 HBASE_ROW_KEY가 사용돼요. 파일의 두 번째와 세 번째 컬럼은 각각 "d:c1"과 "d:c2"로 가져와져요.
ImportTsv 경고
벌크 로딩할 많은 데이터를 준비한다면 대상 HBase 테이블이 적절히 사전 분할되어 있는지 확인하세요.
더 보기 (See Also)
HFiles를 HBase에 벌크 로딩하는 방법에 대한 자세한 내용은 arch.bulk.load를 참고하세요.
CompleteBulkLoad
completebulkload 유틸리티는 생성된 StoreFiles를 HBase 테이블로 이동해요. 이 유틸리티는 종종 importtsv의 출력과 함께 사용돼요.
이 유틸리티를 호출하는 방법은 두 가지, 명시적 클래스 이름과 드라이버를 통한 방법이 있어요:
명시적 클래스 이름 (Explicit Classname)
$ bin/hbase org.apache.hadoop.hbase.tool.LoadIncrementalHFiles hdfs://storefileoutput TABLENAME
드라이버 (Driver)
HADOOP_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ${HADOOP_HOME}/bin/hadoop jar ${HBASE_HOME}/hbase-mapreduce-VERSION.jar completebulkload hdfs://storefileoutput TABLENAME
CompleteBulkLoad 경고
MapReduce로 생성된 데이터는 실행 중인 HBase 프로세스와 호환되지 않는 파일 권한으로 만들어지는 경우가 많아요. 권한이 활성화된 HDFS를 실행한다고 가정하면, CompleteBulkLoad를 실행하기 전에 그 권한들을 업데이트해야 해요.
HFiles를 HBase에 벌크 로딩하는 방법에 대한 자세한 내용은 arch.bulk.load를 참고하세요.
WALPlayer
WALPlayer는 WAL 파일을 HBase에 재생하는 유틸리티예요.
WAL은 테이블 집합이나 모든 테이블에 대해 재생될 수 있고, 시간 범위(밀리초)를 제공할 수 있어요. WAL은 이 테이블 집합으로 필터링돼요. 출력은 선택적으로 다른 테이블 집합에 매핑될 수 있어요.
WALPlayer는 나중에 벌크 임포트할 HFiles를 생성할 수도 있는데, 그 경우 단일 테이블만 지정할 수 있고 매핑은 불가능해요.
마지막으로 WALPlayer를 사용해서 Region의 recovered.edits 디렉토리의 내용(recovered.edits 디렉토리 아래 파일은 WAL 파일과 같은 형식)을 재생할 수 있어요.
WALPrettyPrinter단일 WAL 파일이나 recovered.edits 파일을 읽거나 검증하려면(WAL 형식을 공유하므로) WAL Tools를 참고하세요.
호출 방법:
$ bin/hbase org.apache.hadoop.hbase.mapreduce.WALPlayer [options] <WAL inputdir> [<tables> <tableMappings>]>
예를 들어:
$ bin/hbase org.apache.hadoop.hbase.mapreduce.WALPlayer /backuplogdir oldTable1,oldTable2 newTable1,newTable2
WALPlayer는 기본적으로 mapreduce 작업으로 실행돼요. 클러스터에서 WALPlayer를 mapreduce 작업으로 실행하지 않으려면 명령줄에 -Dmapreduce.jobtracker.address=local 플래그를 추가해서 모두 로컬 프로세스에서 실행되게 하세요.
WALPlayer 옵션
인자 없이 WALPlayer를 실행하면 간단한 사용 정보가 출력돼요:
Usage: WALPlayer [options] <WAL inputdir> [<tables> <tableMappings>]
<WAL inputdir> directory of WALs to replay.
<tables> comma separated list of tables. If no tables specified,
all are imported (even hbase:meta if present).
<tableMappings> WAL entries can be mapped to a new set of tables by passing
<tableMappings>, a comma separated list of target tables.
If specified, each table in <tables> must have a mapping.
To generate HFiles to bulk load instead of loading HBase directly, pass:
-Dwal.bulk.output=/path/for/output
Only one table can be specified, and no mapping allowed!
To specify a time range, pass:
-Dwal.start.time=[date|ms]
-Dwal.end.time=[date|ms]
The start and the end date of timerange (inclusive). The dates can be
expressed in milliseconds-since-epoch or yyyy-MM-dd'T'HH:mm:ss.SS format.
E.g. 1234567890120 or 2009-02-13T23:32:30.12
Other options:
-Dmapreduce.job.name=jobName
Use the specified mapreduce job name for the wal player
-Dwal.input.separator=' '
Change WAL filename separator (WAL dir names use default ','.)
For performance also consider the following options:
-Dmapreduce.map.speculative=false
-Dmapreduce.reduce.speculative=false
RowCounter
RowCounter는 테이블의 모든 행을 세는 mapreduce 작업이에요. 메타데이터 불일치에 대한 우려가 있을 때 HBase가 테이블의 모든 블록을 읽을 수 있는지 확인하는 sanity check로 좋은 유틸리티예요. mapreduce를 모두 단일 프로세스에서 실행하지만, 활용할 MapReduce 클러스터가 있으면 더 빨리 실행돼요. 스캔할 데이터의 시간 범위를 --starttime=[starttime]과 --endtime=[endtime] 플래그로 제한할 수 있어요. 스캔된 데이터는 --range=[startKey],[endKey][;[startKey],[endKey]...] 옵션으로 키를 기준으로 제한할 수 있어요.
$ bin/hbase rowcounter [options] <tablename> [--starttime=<start> --endtime=<end>] [--range=[startKey],[endKey][;[startKey],[endKey]...]] [<column1> <column2>...]
RowCounter는 셀당 한 버전만 셉니다.
성능을 위해 -Dhbase.client.scanner.caching=100과 -Dmapreduce.map.speculative=false 옵션을 사용하는 것을 고려하세요.
CellCounter
HBase는 CellCounter라는 또 다른 진단 mapreduce 작업을 제공해요. RowCounter처럼 테이블에 대한 더 세밀한 통계를 수집해요. CellCounter가 수집하는 통계는 더 세밀하며 다음을 포함해요:
- 테이블의 총 행 수.
- 모든 행에 걸친 총 CF 수.
- 모든 행에 걸친 총 qualifiers 수.
- 각 CF의 총 발생 횟수.
- 각 qualifier의 총 발생 횟수.
- 각 qualifier의 총 버전 수.
프로그램은 실행 범위를 제한할 수 있어요. 분석할 행을 제한하는 row 정규식 또는 접두사를 제공하세요. --starttime=<starttime>과 --endtime=<endtime> 플래그를 사용해서 테이블을 스캔할 시간 범위를 지정하세요.
단일 column family 스캔을 지정하려면 hbase.mapreduce.scan.column.family를 사용하세요.
$ bin/hbase cellcounter TABLENAME OUTPUT_DIR [reportSeparator] [regex or prefix] [--starttime=STARTTIME --endtime=ENDTIME]
참고: RowCounter와 마찬가지로 입력 Scan의 캐싱은 작업 구성의 hbase.client.scanner.caching으로 설정돼요.
mlockall
과잉 할당된 환경에서 서버가 스왑 아웃될 가능성을 줄이기 위해 서버가 시작 시 mlockall을 호출하도록 선택적으로 서버를 물리 메모리에 고정(pin)할 수 있어요. 선택적 라이브러리를 빌드하고 시작 시 실행하게 하는 방법은 HBASE-4391 Add ability to start RS as root and call mlockall을 참고하세요.
오프라인 컴팩션 도구 (Offline Compaction Tool)
CompactionTool은 RegionServer와 별개의 프로세스로 컴팩션(minor 또는 major)을 실행하는 방법을 제공해요. RegionServer 컴팩션 기능이 실행하는 것과 같은 내부 구현 클래스를 재사용해요. 하지만 완전히 별개의 독립 java 프로세스로 실행되므로, 지연 시간에 민감한 사용 사례에 중요할 수 있는 일련의 hfile 재작성 오버헤드에서 RegionServer를 해방시켜 줘요.
사용법:
$ ./bin/hbase org.apache.hadoop.hbase.regionserver.CompactionTool
Usage: java org.apache.hadoop.hbase.regionserver.CompactionTool \
[-compactOnce] [-major] [-mapred] [-D<property=value>]* files...
Options:
mapred Use MapReduce to run compaction.
compactOnce Execute just one compaction step. (default: while needed)
major Trigger major compaction.
Note: -D properties will be applied to the conf used.
For example:
To stop delete of compacted file, pass -Dhbase.compactiontool.delete=false
To set tmp dir, pass -Dhbase.tmp.dir=ALTERNATE_DIR
Examples:
To compact the full 'TestTable' using MapReduce:
$ hbase org.apache.hadoop.hbase.regionserver.CompactionTool -mapred hdfs://hbase/data/default/TestTable
To compact column family 'x' of the table 'TestTable' region 'abc':
$ hbase org.apache.hadoop.hbase.regionserver.CompactionTool hdfs://hbase/data/default/TestTable/abc/x
위 사용 옵션에서 보듯이 CompactionTool은 독립 실행 클라이언트 또는 mapreduce 작업으로 실행될 수 있어요. mapreduce 작업으로 실행할 때 각 family 디렉토리는 입력 split으로 처리되고 별도의 map 작업으로 처리돼요.
compactionOnce 파라미터는 CompactionTool 프로그램이 작업을 끝내기로 결정할 때까지 몇 번의 컴팩션 주기를 수행할지 제어해요. 생략하면 지정된 각 family에서 설정된 컴팩션 정책에 따라 정해진 대로 컴팩션을 계속 실행한다고 가정해요. 컴팩션 정책에 대한 자세한 내용은 compaction을 참고하세요.
major 컴팩션을 원하면 major 플래그를 지정할 수 있어요. 생략하면 CompactionTool은 기본적으로 minor 컴팩션을 원한다고 가정해요.
-D 플래그로 설정 오버라이드를 허용하기도 해요. 위 사용 섹션에서 예를 들어 -Dhbase.compactiontool.delete=false 옵션은 컴팩션 엔진이 temp 폴더에서 원본 파일을 삭제하지 않도록 지시해요.
컴팩션 대상 파일은 상위 hdfs 디렉토리로 지정해야 해요. 각 디렉토리가 family, region, table 디렉토리 중 하나인 한 여러 디렉토리 정의를 허용해요. table 또는 region 디렉토리가 전달되면 프로그램은 관련 하위 폴더를 재귀적으로 순회해서 table/region 수준 아래에서 발견되는 각 family에 대한 컴팩션을 효과적으로 실행해요.
이 디렉토리들은 hbase hdfs 디렉토리 트리 아래에 중첩되어 있으므로, CompactionTool은 필요한 hfile에 접근하려면 hbase 슈퍼 유저 권한이 필요해요.
Running in MapReduce modeMapReduce 모드는 각 family 디렉토리를 별도의 map 작업으로 병렬로 처리하는 기능을 제공해요. 일반적으로 컴팩션 대상으로 하나 이상의 table 디렉토리를 지정할 때 이 모드로 실행하는 것이 합리적이에요. 단, 컴팩션할 family 수가 너무 많아지면 관련 mapreduce 작업이 RegionServers 성능에 간접적으로 영향을 줄 수 있다는 점을 유의하세요. NodeManagers는 보통 RegionServers와 함께 배치되므로, 큰 작업이 RegionServers와 IO/대역폭 자원을 경합할 수 있어요.
MajorCompaction completely disabled on RegionServers due performance impactsMajor compactions은 비용이 큰 작업일 수 있고(compaction 참고) RegionServers 성능에 실제로 영향을 줄 수 있어서, 운영자들이 중요하고 지연 시간이 낮은 애플리케이션을 위해 완전히 비활성화하기도 해요. 그런 시나리오에서 CompactionTool을 대안으로 사용할 수 있지만, 주어진 컴팩션 실행을 위한 테이블/region/family 대상을 결정하는 스케줄링과 선택 같은 추가 커스텀 애플리케이션 로직을 구현해야 해요.
CompactionTool에 대한 추가 세부 사항은 CompactionTool도 참고하세요.
hbase clean
hbase clean 명령은 ZooKeeper, HDFS 또는 둘 다에서 HBase 데이터를 정리해요. 테스트에 사용하기 적합해요. 사용 지침은 옵션 없이 실행하세요. hbase clean 명령은 HBase 0.98에서 도입되었어요.
$ bin/hbase clean
Usage: hbase clean (--cleanZk|--cleanHdfs|--cleanAll)
Options:
--cleanZk cleans hbase related data from zookeeper.
--cleanHdfs cleans hbase related data from hdfs.
--cleanAll cleans hbase related data from both zookeeper and hdfs.
hbase pe
hbase pe 명령은 테스트에 사용되는 PerformanceEvaluation 도구를 실행해요.
PerformanceEvaluation 도구는 많은 다양한 옵션과 명령을 받아들여요. 사용 지침은 옵션 없이 명령을 실행하세요.
PerformanceEvaluation 도구는 최근 HBase 릴리스에서 많은 업데이트를 받았어요. 네임스페이스 지원, 태그 지원, 셀 수준 ACL과 가시성 라벨, RPC 호출용 multiget, 샘플링 크기 증가, 테스트 중 임의 수면 옵션, 테스트 시작 전 클러스터를 "warm up"하는 기능을 포함해요.
hbase ltt
hbase ltt 명령은 테스트에 사용되는 LoadTestTool 유틸리티를 실행해요.
-init_only 또는 -write, -update, -read 중 적어도 하나를 지정해야 해요. 일반 사용 지침은 -h 옵션을 전달하세요.
LoadTestTool은 최근 HBase 릴리스에서 많은 업데이트를 받았어요. 네임스페이스 지원, 태그 지원, 셀 수준 ACL과 가시성 라벨, 보안 관련 기능 테스트, 서버당 region 수 지정 기능, multi-get RPC 호출 테스트, 복제 관련 테스트를 포함해요.
업그레이드 전 검증기 (Pre-Upgrade validator)
Pre-Upgrade validator 도구는 HBase 1에서 HBase 2로 업그레이드하기 전에 클러스터의 알려진 비호환성을 확인하는 데 사용할 수 있어요.
$ bin/hbase pre-upgrade command ...
코프로세서 검증 (Coprocessor validation)
HBase는 오랫동안 코프로세서를 지원해 왔지만, 코프로세서 API는 주요 릴리스 사이에 변경될 수 있어요. 코프로세서 검증기는 기존 코프로세서가 실제 HBase 버전과 여전히 호환되는지 판단하려고 시도해요.
$ bin/hbase pre-upgrade validate-cp [-jar ...] [-class ... | -table ... | -config]
Options:
-e Treat warnings as errors.
-jar <arg> Jar file/directory of the coprocessor.
-table <arg> Table coprocessor(s) to check.
-class <arg> Coprocessor class(es) to check.
-config Scan jar for observers.
코프로세서 클래스는 -class 옵션으로 명시적으로 선언하거나, -config 옵션으로 HBase 설정에서 얻을 수 있어요. 테이블 수준 코프로세서는 -table 옵션으로도 확인할 수 있어요. 도구는 자체 classpath에서 코프로세서를 찾지만 -jar 옵션으로 확장될 수 있어요. 여러 -class로 여러 클래스를, 여러 -table 옵션으로 여러 테이블을 테스트하고 여러 -jar 옵션으로 classpath에 여러 jar를 추가하는 것이 가능해요.
도구는 오류와 경고를 보고할 수 있어요. 오류는 현재 HBase 버전과 호환되지 않아 HBase가 코프로세서를 로드할 수 없다는 뜻이에요. 경고는 코프로세서를 로드할 수는 있지만 예상대로 작동하지 않을 것이라는 뜻이에요. -e 옵션이 주어지면 경고에서도 도구가 실패해요.
이 도구는 jar 파일의 모든 측면을 검증할 수는 없고 정적 검사만 수행한다는 점에 유의하세요.
예를 들어:
$ bin/hbase pre-upgrade validate-cp -jar my-coprocessor.jar -class MyMasterObserver -class MyRegionObserver
my-coprocessor.jar에 있는 MyMasterObserver와 MyRegionObserver 클래스를 검증해요.
$ bin/hbase pre-upgrade validate-cp -table .*
테이블 이름이 .* 정규식과 일치하는 모든 테이블 수준 코프로세서를 검증해요.
DataBlockEncoding 검증 (DataBlockEncoding validation)
HBase 2.0은 column family에서 PREFIX_TREE Data Block Encoding을 제거했어요. 자세한 내용은 prefix-tree encoding removed를 확인하세요. 클러스터의 어떤 column family도 호환되지 않는 Data Block Encoding을 사용하지 않는지 검증하려면 다음 명령을 실행하세요.
$ bin/hbase pre-upgrade validate-dbe
이 검사는 모든 column family를 검증하고 비호환성을 출력해요. 예를 들어:
2018-07-13 09:58:32,028 WARN [main] tool.DataBlockEncodingValidator: Incompatible DataBlockEncoding for table: t, cf: f, encoding: PREFIX_TREE
이는 테이블 t의 column family f의 Data Block Encoding이 호환되지 않는다는 뜻이에요. 고치려면 HBase 셸에서 alter 명령을 사용하세요:
alter 't', { NAME => 'f', DATA_BLOCK_ENCODING => 'FAST_DIFF' }
다음 섹션에서 설명하는 HFiles도 검증하세요.
HFile 내용 검증 (HFile Content validation)
Data Block Encoding이 PREFIX_TREE에서 변경되었더라도 그렇게 인코딩된 데이터를 포함한 HFiles가 있을 수 있어요. HFiles가 HBase 2에서 읽을 수 있는지 검증하려면 HFile content validator를 사용하세요.
$ bin/hbase pre-upgrade validate-hfile
도구는 손상된 HFiles와 근본 원인에 대한 세부 정보를 로그로 기록해요. 문제가 PREFIX_TREE 인코딩에 관한 것이라면 HBase 2로 업그레이드하기 전에 인코딩을 변경해야 해요.
다음 로그 메시지는 잘못된 HFiles의 예를 보여줘요.
2018-06-05 16:20:46,976 WARN [hfilevalidator-pool1-t3] hbck.HFileCorruptionChecker: Found corrupt HFile hdfs://example.com:9000/hbase/data/default/t/72ea7f7d625ee30f959897d1a3e2c350/prefix/7e6b3d73263c4851bf2b8590a9b3791e
org.apache.hadoop.hbase.io.hfile.CorruptHFileException: Problem reading HFile Trailer from file hdfs://example.com:9000/hbase/data/default/t/72ea7f7d625ee30f959897d1a3e2c350/prefix/7e6b3d73263c4851bf2b8590a9b3791e
...
Caused by: java.io.IOException: Invalid data block encoding type in file info: PREFIX_TREE
...
Caused by: java.lang.IllegalArgumentException: No enum constant org.apache.hadoop.hbase.io.encoding.DataBlockEncoding.PREFIX_TREE
...
2018-06-05 16:20:47,322 INFO [main] tool.HFileContentValidator: Corrupted file: hdfs://example.com:9000/hbase/data/default/t/72ea7f7d625ee30f959897d1a3e2c350/prefix/7e6b3d73263c4851bf2b8590a9b3791e
2018-06-05 16:20:47,383 INFO [main] tool.HFileContentValidator: Corrupted file: hdfs://example.com:9000/hbase/archive/data/default/t/56be41796340b757eb7fff1eb5e2a905/f/29c641ae91c34fc3bee881f45436b6d1
PREFIX_TREE 오류 수정 (Fixing PREFIX_TREE errors)
Data Block Encoding을 지원되는 것으로 변경한 후 PREFIX_TREE 오류가 발생할 수 있어요. 아직 PREFIX_TREE로 인코딩된 HFiles가 있거나 여전히 스냅샷이 있기 때문일 수 있어요.
HFiles를 고치려면 테이블에서 major compaction을 실행하세요(로그 메시지에 따르면 default:t였어요):
major_compact 't'
HFiles는 스냅샷에서도 참조될 수 있어요. HFile이 archive/data 아래에 있는 경우가 그렇죠. 첫 단계는 어느 스냅샷이 그 HFile을 참조하는지 결정하는 거예요(로그에 따르면 파일 이름은 29c641ae91c34fc3bee881f45436b6d1이었어요):
for snapshot in $(hbase snapshotinfo -list-snapshots 2> /dev/null | tail -n -1 | cut -f 1 -d \|);
do
echo "checking snapshot named '${snapshot}'";
hbase snapshotinfo -snapshot "${snapshot}" -files 2> /dev/null | grep 29c641ae91c34fc3bee881f45436b6d1;
done
이 셸 스크립트의 출력은:
checking snapshot named 't_snap'
1.0 K t/56be41796340b757eb7fff1eb5e2a905/f/29c641ae91c34fc3bee881f45436b6d1 (archive)
즉 t_snap 스냅샷이 호환되지 않는 HFile을 참조한다는 뜻이에요. 스냅샷이 여전히 필요하다면 HBase 셸로 다시 만들어야 해요:
# creating a new namespace for the cleanup process
create_namespace 'pre_upgrade_cleanup'
# creating a new snapshot
clone_snapshot 't_snap', 'pre_upgrade_cleanup:t'
alter 'pre_upgrade_cleanup:t', { NAME => 'f', DATA_BLOCK_ENCODING => 'FAST_DIFF' }
major_compact 'pre_upgrade_cleanup:t'
# removing the invalid snapshot
delete_snapshot 't_snap'
# creating a new snapshot
snapshot 'pre_upgrade_cleanup:t', 't_snap'
# removing temporary table
disable 'pre_upgrade_cleanup:t'
drop 'pre_upgrade_cleanup:t'
drop_namespace 'pre_upgrade_cleanup'
자세한 내용은 HBASE-20649를 참고하세요.
데이터 블록 인코딩 도구 (Data Block Encoding Tool)
기존 HFile에서 키 압축을 위한 다양한 압축 알고리즘과 서로 다른 데이터 블록 인코더를 테스트해요. 테스트, 디버깅, 벤치마킹에 유용해요.
HFile의 전체 경로인 -f를 지정해야 해요.
결과는 압축/압축 해제와 인코딩/디코딩의 성능(MB/s)과 HFile의 데이터 절약량을 모두 보여줘요.
$ bin/hbase org.apache.hadoop.hbase.regionserver.DataBlockEncodingTool
Usages: hbase org.apache.hadoop.hbase.regionserver.DataBlockEncodingTool
Options:
-f HFile to analyse (REQUIRED)
-n Maximum number of key/value pairs to process in a single benchmark run.
-b Whether to run a benchmark to measure read throughput.
-c If this is specified, no correctness testing will be done.
-a What kind of compression algorithm use for test. Default value: GZ.
-t Number of times to run each benchmark. Default value: 12.
-omit Number of first runs of every benchmark to omit from statistics. Default value: 2.
HBase Conf 도구 (HBase Conf Tool)
HBase Conf 도구는 설정의 현재 값을 출력하는 데 사용할 수 있어요. 명령줄에 설정 키를 전달해서 사용할 수 있어요.
$ bin/hbase org.apache.hadoop.hbase.util.HBaseConfTool <configuration_key>