HBase 기본 설치


HBase 기본 설치(참조:HBase 완벽 가이드)

■ http://hbase.apache.org/에서 hbase 최신 버전을 다운로드한다. 미러 사이트에서 다운로드 링크를 복사한 후  wget 명령어로 hbase를 다운 로드한다.
hbase01
hbase02

hbase03

 

■ 다운로드 받은 hbase 파일의 압축을 풀고 /usr/local폴더로 이동한 다음 링크를 만든다. 그리고 /usr/local/hbase-1.0.1 폴더 아래의 파일 전부를 hadoop사용자.그룹 소유로 변경한다.


# cd /tmp
# tar zxvf hbase-1.0.1-bin.tar.gz
# mv hbase-1.0.1 /usr/local/
# cd /usr/local
# ln -s hbase-1.0.1 hbase

# chown -R hadoop.hadoop /usr/local/hbase-1.0.1

■ hadoop 사용자의 ~/.bash_profile을 아래와 같이 수정하고 실행환경에 반영한다.

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

export JAVA_HOME=/usr/local/java
export MVN_HOME=/usr/local/maven
export TOMCAT_HOME=/usr/local/tomcat
export HBASE_HOME=/usr/local/hbase

PATH=$MVN_HOME/bin:$TOMCAT_HOME/bin:$JAVA_HOME/bin:$HBASE_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin

export PATH

 

# su - hadoop
$ vi ~/.bash_profile
$ source ~/.bash_profile

■ hbase 데이터 디렉토리 설정(/usr/local/hbase-1.0.1/conf/hbase-site.xml) 편집을 아래와 같이 편집하고 데이터디렉토리를 hadoop 사용자 권한으로 생성한다.


<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///data/hbase</value>
</property>
</configuration>
# mkdir -p /data/hbase
# chown -R hadoop.hadoop /data/hbase

 

■ $HBASE_HOME/bin 디렉토리로 이동해서 hbase를 시작하고 대화형 shell을 시작한다. 사용하여 간단한 테이블을 생성하고 데이터를 가진 몇개의 로우를 추가해 본다.

# su - hadoop
$ cd /usr/local/hbase
$ ./bin/start-hbase.sh
starting master, logging to /usr/local/hbase/logs/hbase-hadoop-master-centos02.out

$ ./bin/hbase shell
2015-05-03 10:17:25,193 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.0.1, r66a93c09df3b12ff7b86c39bc8475c60e15af82d, Fri Apr 17 22:14:06 PDT 2015

hbase(main):001:0> 

■ 대화형 shell을 사용하여 간단한 테이블을 생성하고 데이터를 가진 몇개의 로우를 추가해 본다.

hbase(main):001:0> create 'testtable', 'colfam1'
0 row(s) in 22.1380 seconds

=> Hbase::Table - testtable
hbase(main):002:0> list 'testtable'
TABLE                                                                                                                         
testtable                                                                                                                     
1 row(s) in 0.0540 seconds

=> ["testtable"]
hbase(main):003:0> put 'testtable', 'myrow-1','colfam1:q1', 'value-1'
0 row(s) in 0.3110 seconds

hbase(main):007:0> put 'testtable', 'myrow-2','colfam1:q2', 'value-2' 
0 row(s) in 20.7520 seconds

hbase(main):007:0> put 'testtable', 'myrow-3','colfam1:q3', 'value-3' 
0 row(s) in 20.8180 seconds

hbase(main):002:0> scan 'testtable'
ROW                              COLUMN+CELL                                                                                  
 myrow-1                         column=colfam1:q1, timestamp=1430616235677, value=value-1                                    
 myrow-2                         column=colfam1:q2, timestamp=1430616372701, value=value-2                                    
 myrow-3                         column=colfam1:q3, timestamp=1430616515440, value=value-3                                    
3 row(s) in 0.1110 seconds

hbase(main):004:0> get 'testtable', 'myrow-1'
COLUMN                           CELL                                                                                         
 colfam1:q1                      timestamp=1430616235677, value=value-1                                                       
1 row(s) in 0.0830 seconds

hbase(main):005:0> delete 'testtable', 'myrow-2', 'colfam1:q2'
0 row(s) in 0.0340 seconds

hbase(main):006:0> scan 'testtable'
ROW                              COLUMN+CELL                                                                                  
 myrow-1                         column=colfam1:q1, timestamp=1430616235677, value=value-1                                    
 myrow-3                         column=colfam1:q3, timestamp=1430616515440, value=value-3                                    
2 row(s) in 0.0500 seconds

hbase(main):017:0> disable 'testtable'
0 row(s) in 11.7810 seconds

hbase(main):018:0> drop 'testtable'
0 row(s) in 0.2250 seconds

hbase(main):019:0> exit
[hadoop@centos02 hbase]$ 

 

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다