1. 程式人生 > >hadoop生態搭建(3節點)-06.hbase配置

hadoop生態搭建(3節點)-06.hbase配置

校驗 stc shutdown name daemon 配置環境 val main ica

# http://archive.apache.org/dist/hbase/1.2.4/

# ==================================================================安裝 hbase

tar -zxvf ~/hbase-1.2.4-bin.tar.gz -C /usr/local
rm –r ~/hbase-1.2.4-bin.tar.gz

# 配置環境變量
# ==================================================================node1 node2 node3

vi /etc/profile

# 在export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL下添加
export JAVA_HOME=/usr/java/jdk1.8.0_111
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.12
export HADOOP_HOME=/usr/local/hadoop-2.7.6
export MYSQL_HOME=/usr/local/mysql
export HBASE_HOME=/usr/local/hbase-1.2.4

export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$ZOOKEEPER_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$MYSQL_HOME/bin:$HBASE_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native

# ==================================================================node1

# 使環境變量生效
source /etc/profile


# 查看配置結果
echo $HBASE_HOME


vi $HBASE_HOME/conf/hbase-env.sh

export JAVA_HOME=/usr/java/jdk1.8.0_111

#export HBASE_CLASSPATH=/usr/local/hbase-1.2.4/conf #flume需要
export JAVA_CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export HADOOP_HOME=/usr/local/hadoop-2.7.6
export HADOOP_CONF_DIR=/usr/local/hadoop-2.7.6/etc/hadoop

#export HBASE_OPTS="-XX:+UseConcMarkSweepGC"
export HBASE_OPTS="$HBASE_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode"

export HBASE_LOG_DIR=/usr/local/hbase-1.2.4/logs

export HBASE_PID_DIR=/usr/local/hbase-1.2.4/pids

export HBASE_MANAGES_ZK=false

# export TZ="Asia/Shanghai"


vi $HBASE_HOME/conf/regionservers
node1
node2
node3


mkdir $HBASE_HOME/tmp

cp $HADOOP_HOME/etc/hadoop/hdfs-site.xml $HBASE_HOME/conf/
cp $HADOOP_HOME/etc/hadoop/core-site.xml $HBASE_HOME/conf/


rm -r $HBASE_HOME/lib/slf4j-log4j12-1.7.5.jar
# 配置 hbase-site.xml
vi $HBASE_HOME/conf/hbase-site.xml
<configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://appcluster/hbase</value>
    </property>
    <property> 
        <name>hbase.cluster.distributed</name>
<value>true</value> </property> <property > <name>hbase.master.port</name> <value>16000</value> </property> <!--默認HMaster HTTP訪問端口--> <property> <name>hbase.master.info.port</name> <value>16010</value> </property> <property> <name>hbase.regionserver.port</name> <value>16020</value> </property> <!--默認HRegionServer HTTP訪問端口--> <property> <name>hbase.regionserver.info.port</name> <value>16030</value> </property> <property> <name>hbase.tmp.dir</name> <value>/usr/local/hbase-1.2.4/tmp</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>node1,node2,node3</value> </property> <!--跟zookeeper配置的dataDir一致--> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/usr/local/zookeeper-3.4.12/data</value> </property> <property> <name>dfs.replication</name> <value>2</value> </property> </configuration>

# ==================================================================node1

scp -r $HBASE_HOME node2:/usr/local/
scp -r $HBASE_HOME node3:/usr/local/

# ==================================================================node2 node3

# 使環境變量生效
source /etc/profile


# 查看配置結果
echo $HBASE_HOME

# 啟動

# ==================================================================node1 node2 node3
# 啟動 zookeeper
zkServer.sh start
zkServer.sh status


# ==================================================================node1
# 啟動hadoop所有進程
$HADOOP_HOME/sbin/start-all.sh

$HADOOP_HOME/sbin/hadoop-daemon.sh start zkfc


# ==================================================================node2
$HADOOP_HOME/sbin/yarn-daemon.sh start resourcemanager
$HADOOP_HOME/sbin/hadoop-daemon.sh start zkfc


# ==================================================================node1
# 要實現Hbase的HA(High Availablity)
$HBASE_HOME/bin/hbase-daemon.sh start master

# 啟動Hbase(start-hbase.sh)
$HBASE_HOME/bin/start-hbase.sh


# ==================================================================node2
# 開啟Hbase的HA
$HBASE_HOME/bin/hbase-daemon.sh start master


# 校驗HA是否啟動成功
jps

# ==================================================================node1
jps

#2785 DataNode
#3377 DFSZKFailoverController
#2515 QuorumPeerMain
#3158 ResourceManager
#4328 Jps
#3788 HMaster
#2685 NameNode
#2973 JournalNode
#3261 NodeManager


# ==================================================================node2
jps

#2547 NodeManager
#2758 ResourceManager
#2409 JournalNode
#2170 QuorumPeerMain
#2315 DataNode
#2987 HRegionServer
#3196 HMaster
#3341 Jps
#2686 DFSZKFailoverController
#2255 NameNode

# 網頁訪問

# http://node1:16010

# http://node2:16010/master-status

# http://node2:16030/rs-status

# http://node3:16030/rs-status

# 高可用
# kill namenode
kill -9 2255


$HBASE_HOME/bin/hbase shell


# hbase shell
# 創建表
> create ‘test‘,‘address‘

# 添加記錄
> put ‘test‘,‘row1‘,‘address:province‘,‘sichuan‘
> put ‘test‘,‘row2‘,‘address:city‘,‘chengdu‘

# 查看記錄
> get ‘test‘,‘row1‘

# 查看表中的記錄總數
> count ‘test‘

# 刪除記錄
> delete ‘test‘,‘row1‘,‘address‘

# 刪除一張表
> disable ‘test‘
> drop ‘test‘

# 查看所有記錄
scan ‘test‘


# ==================================================================node1
# stop已經啟動的進程
$HBASE_HOME/bin/stop-hbase.sh


$HADOOP_HOME/sbin/stop-all.sh


# ==================================================================node1 node2 node3
# 停止 zookeeper
zkServer.sh stop


# ==================================================================node1
$HADOOP_HOME/sbin/hadoop-daemon.sh stop zkfc


# ==================================================================node2
$HADOOP_HOME/sbin/yarn-daemon.sh stop resourcemanager
$HADOOP_HOME/sbin/hadoop-daemon.sh stop zkfc



shutdown -h now
# 快照 hbase

hadoop生態搭建(3節點)-06.hbase配置