HBase의 간단한 명령어를 학습하기 위하여 HBase를 로컬에 세팅하는 방법이다.
우선 아파치 HBase 릴리즈 사이트에서 최신 HBase 파일을 내려받는다.(링크)
적당한 폴더에 압축을 풀면 OK!
$ tar -zxvf hbase-0.94.8.tar.gz |
압축해제한 디렉토리
이제 로컬에서 HDFS역할을 해줄 데이터 디렉토리를 설정해주어야 한다.
이를 위해 설정파일 conf/hbase-site.xml파일을 수정해준다.
$ vi conf/hbase-site.xml |
아래구문을 configuration에 추가해준다.
<property> <name>hbase.rootdir</name> <value>file:///{yourpath}/hbase</value> </property> |
※ 체크포인트 : 쓰기권한
HBase 실행
$ bin/start-hbase.sh starting master, logging to /opt/hbase-0.94.8/bin/../logs/hbase-root-master-pooh.out |
HBase shell 접근
$ bin/hbase shell HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 0.94.8, r1485407, Wed May 22 20:53:13 UTC 2013 |
테이블 생성 시 아래와 같은 에러가 발생할 경우
hbase(main):002:0> create 'testtable', 'colfam1' ERROR: org.apache.hadoop.hbase.PleaseHoldException: org.apache.hadoop.hbase.PleaseHoldException: Master is initializing |
HBase는 127.0.0.1를 사용하여 로컬 호스트에 연결할 수 없기 때문에 hosts 파일은 아래와 같이 편집해줘야 한다.
$ vi /etc/hosts |
127.0.0.1 localhost 127.0.0.1 {user machine} 127.0.1.1 localhost 127.0.1.1 {user machine} |
설정 후 HBase를 재시작한다.
아래는 HBase 재시작 후 컬럼패밀리를 하나 가진 테이블을 생성하였으며 에러없이 정상적으로 동작한다.
$ bin/stop-hbase.sh stopping hbase.................................................................................... $ bin/start-hbase.sh starting master, logging to /opt/hbase-0.94.8/bin/../logs/hbase-root-master-pooh.out $ bin/hbase shell HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 0.94.8, r1485407, Wed May 22 20:53:13 UTC 2013 hbase(main):002:0> create 'testtable', 'colfam1' 0 row(s) in 1.1650 seconds |
테이블 생성 후 데이터 디렉토리로 모습
참고 : HBase 완벽가이드