HBase 완전분산 설치

■ HBase를 완전분산 모드로 설치하기 전에 먼저 Hadoop과 Zookeeper가 설치되어 있어야 한다. Hadoop 완전분산 설치Zookeeper 설치를 참조한다.

HBase 설치 대상 서버 정보
Host Name IP 용도
centos01 192.168.192.128 Master Server
centos02 192.168.192.130 Region Server 1
centos03 192.168.192.133 Region Server 2
centos04 192.168.192.132 Region Server 3
centos05 192.168.192.131 Region Server 4

 

■ HBase 다운로드
http://hbase.apache.org/의 mirror site에서 hbase stable 버전의 다운로드 링크를 복사한다. 현재 HBase의 stable version은 hbase-1.1.3이다.
 

■ 리눅스에서 wget을 이용해서 hbase 다운로드 및 압축을 풀고 ln -s를 이용해서 링크를 생성한다. 설치하는 위치는 편의상 /usr/local디렉토리에 생성한다.

[nextman@centos01 program]$ wget http://apache.mirror.cdnetworks.com/hbase/stable/hbase-1.1.3-bin.tar.gz
[nextman@centos01 program]$ mv hbase-1.1.3 /usr/local/
[nextman@centos01 program]$ cd /usr/local/
[nextman@centos01 local]$ ln -s hbase-1.1.3/ hbase

 

■ $HBASE_HOME/bin(/usr/local/hbase-1.1.3/bin) 디렉토리를 path에 추가, 사용자의 ~/.bash_profile을 수정하여 HBase의 실행 파일들을 path에 추가한다.

[nextman@centos01 local]$ vi ~/.bash_profile
# .bash_profile

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

# User specific environment and startup programs

alias tstart='/usr/local/tomcat/bin/catalina.sh start'
alias tstop='/usr/local/tomcat/bin/catalina.sh stop'
alias tstat='ps ax | grep tomcat'
alias tlog='tail -f /usr/local/tomcat/logs/catalina.out &'

export JAVA_HOME=/usr/local/java
export TOMCAT_HOME=/usr/local/tomcat
export MAVEN_HOME=/usr/local/maven
export HADOOP_HOME=/usr/local/hadoop
export ZOOKEEPER_HOME=/usr/local/zookeeper
export HBASE_HOME=/usr/local/hbase

PATH=$HBASE_HOME/bin:$ZOOKEEPER_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$MAVEN_HOME/bin:$TOMCAT_HOME/bin:$JAVA_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin

export PATH

 

■ $HBASE_HOME/bin(/usr/local/hbase-1.1.3/bin) 디렉토리를 실행 환경에 적용

[nextman@centos01 local]$ source ~/.bash_profile

 

■ data 디렉토리 생성 – 실제 HBase 데이터가 저장될 디렉토리를 각각의 서버(centos01, centos02, centos03, centos04, centos05)에 생성한다.

[nextman@centos01 local]$ mkdir -p /home/data/hbase/data

 

■ $HBASE_HOME/conf/hbase-site.xml 편집 ( hbase.rootdir 정보 등록 )

[nextman@centos01 conf]$ vi /usr/local/hbase/conf/hbase-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
        <property>
                <name>hbase.rootdir</name
                <value>hdfs://centos01:9000/hbase</value>
        </property>
        <property>
                <name>hbase.master</name
                <value>centos01:6000</value>
        </property>
        <property>
                <name>hbase.zookeeper.quorum</name
                <value>centos01,centos02,centos03</value>
        </property>
        <property>
                <name>hbase.zookeeper.property.dataDir</name
                <value>/home/data/zookeeper</value>
        </property>
        <property>
                <name>hbase.cluster.distributed</name
                <value>true</value>
        </property>
        <property>
                <name>dfs.datanode.max.xcievers</name
                <value>4096</value>
        </property>
</configuration>

 

■ $HBASE_HOME/conf/hbase-env.sh 편집 – zookeeper는 별도로 설치되었고 및 관리되므로 false로 지정한다.

export HBASE_MANAGES_ZK=false

 

■ $HBASE_HOME/conf/regionservers파일에 리전서 버로 등록할 서버 리스트를 등록한다. centos01 서버는 hbase master서버로 사용할 계획이므로 등록하지 않는다. master 서버는 예전(hbase 버전 0.20.x 이전)에 masters라는 파일에 관리하였으나 현재 버전에는 없다. 현재 master 서버는 시작할 때 스스로 주키퍼에 등록한다.(HBase 완벽 가이드 116페이지 참조)

[nextman@centos01 conf]$ vi /usr/local/hbase/conf/regionservers
centos02
centos03
centos04
centos05

 

■ HBase 배포 – 이제까지 centos01에서 설정한 HBase파일을 압축하여 각 리전서버(centos02, centos03, centos04, centos05)로 배포한고 ~/.bash_profile도 수정하였으므로 같이 배포한다.

[nextman@centos01 conf]$ cd /usr/local
[nextman@centos01 local]$ tar zcvf hbase.tar.gz hbase-1.1.3/
[nextman@centos01 local]$ scp hbase.tar.gz nextman@centos02:/usr/local/
[nextman@centos01 local]$ scp hbase.tar.gz nextman@centos03:/usr/local/
[nextman@centos01 local]$ scp hbase.tar.gz nextman@centos04:/usr/local/
[nextman@centos01 local]$ scp hbase.tar.gz nextman@centos05:/usr/local/

[nextman@centos01 local]$ scp /home/nextman/.bash_profile nextman@centos02:/home/nextman
[nextman@centos01 local]$ scp /home/nextman/.bash_profile nextman@centos03:/home/nextman
[nextman@centos01 local]$ scp /home/nextman/.bash_profile nextman@centos04:/home/nextman
[nextman@centos01 local]$ scp /home/nextman/.bash_profile nextman@centos05:/home/nextman

 

■ ssh로 각 리전서버(centos02, centos03, centos04, centos05)로 접속해서 데이터 디렉토리(mkdir -p /home/data/hbase/data)를 만들고 링크(ln -s hbase-1.1.3/ hbase)를 만든다.

[nextman@centos01 local]$ ssh centos02
[nextman@centos02 ~]$ mkdir -p /home/data/hbase/data
[nextman@centos02 ~]$ cd /usr/local
[nextman@centos02 local]$ tar zxvf hbase.tar.gz
[nextman@centos02 local]$ ln -s hbase-1.1.3/ hbase

 

■ hadoop 시작 및 zookeeper 시작 – hbase가 시작되기전에 먼저 hadoop hdfs와 zookeeper가 시작되어 있어야 한다. hadoop은 master node(centos01)에서 한 번만 시작(start-dfs.sh, start-yarn.sh)하면 되고 zookeeper는 zookeeper가 설치된 각각의 서버에서 실행스크립트(zkServer.sh start)를 실행해야한다.

nextman@centos01 ~]$ jps
11546 Jps
1688 Bootstrap
[nextman@centos01 ~]$ hostname
centos01
[nextman@centos01 ~]$ start-dfs.sh
Starting namenodes on [centos01]
centos01: starting namenode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-nextman-namenode-centos01.out
centos04: starting datanode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-nextman-datanode-centos04.out
centos05: starting datanode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-nextman-datanode-centos05.out
centos03: starting datanode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-nextman-datanode-centos03.out
centos02: starting datanode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-nextman-datanode-centos02.out
Starting secondary namenodes [centos02]
centos02: starting secondarynamenode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-nextman-secondarynamenode-centos02.out
[nextman@centos01 ~]$ start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /usr/local/hadoop-2.6.0/logs/yarn-nextman-resourcemanager-centos01.out
centos03: starting nodemanager, logging to /usr/local/hadoop-2.6.0/logs/yarn-nextman-nodemanager-centos03.out
centos02: starting nodemanager, logging to /usr/local/hadoop-2.6.0/logs/yarn-nextman-nodemanager-centos02.out
centos04: starting nodemanager, logging to /usr/local/hadoop-2.6.0/logs/yarn-nextman-nodemanager-centos04.out
centos05: starting nodemanager, logging to /usr/local/hadoop-2.6.0/logs/yarn-nextman-nodemanager-centos05.out
[nextman@centos01 ~]$ jps
11653 NameNode
11906 ResourceManager
11973 Jps
1688 Bootstrap

[nextman@centos01 ~]$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

[nextman@centos01 ~]$ ssh centos02
Last login: Sun Mar  6 00:57:19 2016 from centos01
[nextman@centos02 ~]$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

[nextman@centos02 ~]$ ssh centos03
Last login: Sat Mar  5 23:33:32 2016 from 192.168.192.1
[nextman@centos03 ~]$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

 

■ HBase 시작 – HBase Master가 될 centos01서버에서 start-hbase.sh 스크립트를 시작한다.

[nextman@centos01 hbase]$ start-hbase.sh 
starting master, logging to /usr/local/hbase/logs/hbase-nextman-master-centos01.out
centos05: starting regionserver, logging to /usr/local/hbase/bin/../logs/hbase-nextman-regionserver-centos05.out
centos04: starting regionserver, logging to /usr/local/hbase/bin/../logs/hbase-nextman-regionserver-centos04.out
centos03: starting regionserver, logging to /usr/local/hbase/bin/../logs/hbase-nextman-regionserver-centos03.out
centos02: starting regionserver, logging to /usr/local/hbase/bin/../logs/hbase-nextman-regionserver-centos02.out
[nextman@centos01 hbase]$ 
[nextman@centos01 hbase]$ 
[nextman@centos01 hbase]$ jps
12183 QuorumPeerMain
11653 NameNode
11906 ResourceManager
1688 Bootstrap
12480 Jps
12377 HMaster
[nextman@centos01 hbase]$ 
[nextman@centos01 hbase]$ 
[nextman@centos01 hbase]$ ssh centos02
Last login: Sun Mar  6 01:23:11 2016 from centos01
[nextman@centos02 ~]$ jps
7448 Jps
6889 DataNode
7196 QuorumPeerMain
7051 NodeManager
7319 HRegionServer
6952 SecondaryNameNode

최종적으로 jps 명령어로 확인하면 centos01서버에는 QuorumPeerMain(zookeeper daemon), NameNode(hadoop hdfs daemon), ResourceManager(hadoop yarn daemon), HMaster(hbase daemon)이 정상적으로 떠 있는것을 확인할 수있다. 그리고 centos02서버에는 DataNode(hadoop hdfs daemon), SecondaryNameNode(hadoop hdfs daemon), QuorumPeerMain(zookeeper daemon), NodeManager(hadoop yarn daemon), HRegionServer(hbase region daemon)가 떠 있는것을 확인할 수 있다.
 

■ hbase shell(client?) 접속 – hbase shell명령어로 hbase에 접속하고 help 명령어로 도움말을 확인할 수 있다.

[nextman@centos01 hbase]$ hbase shell
...
hbase(main):002:0> help
...

 

■ web UI 인터페이스 접속
– HBase의 Master 서버는 http://[HBase Master 서버 IP]:16010으로 접속 가능하고, HBase의 각각의 Region 서버는 http://[HBase Region 서버 IP]:16030으로 접속 가능하다.
hbase 완전분산 00

hbase 완전분산 01

 

답글 남기기

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