……

安装HBase之前先安装zookeeper。

官方下载地址:

1
http://archive.apache.org/dist/hbase/1.2.1/

清华下载地址:

1
http://mirror.bit.edu.cn/apache/hbase/

 

配置DNS解析:

1
2
3
4
5
6
7
8
9
10
cat /etc/hosts <<EOF
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.51 zookeeper1
192.168.0.52 zookeeper2
192.168.0.53 zookeeper3
192.168.0.54 hadoop-master
192.168.0.55 hadoop-node1
192.168.0.56 hadoop-node2
EOF

 

下载安装包:

1
wget http://archive.apache.org/dist/hbase/1.2.1/hbase-1.2.1-bin.tar.gz

解压安装:

1
2
3
tar -xf hbase-1.2.1-bin.tar.gz -C /usr/local/
cd /usr/local/
ln -sv hbase-1.2.1/ hbase

环境变量:

1
2
3
4
5
cat /etc/profile.d/hbase.sh <<EOF
export HBASE_HOME=/usr/local/hbase
export PATH=\$PATH:\$HBASE_HOME/bin
EOF
/etc/profile.d/hbase.sh

创建日志目录:

1
2
mkdir /usr/local/hbase/logs
chmod g+w /usr/local/hbase/logs

 

修改配置:

1
2
vim /usr/local/hbase/conf/hbase-env.sh
export HBASE_MANAGES_ZK=false  # 不使用hbase自带的zookeeper

复制core-site.xml和hdfs-site.xml到hbase的conf目录:

1
2
3
cd /usr/local/hadoop/etc/hadoop/
cp core-site.xml hdfs-site.xml ../../../hbase/conf/
cd ../../../hbase/conf/

hbase-site.xml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<configuration>
    <!-- 指定hbase在HDFS上存储的路径, 端口要和Hadoop的fs.defaultFS端口一致 -->
    <property>
    <name>hbase.rootdir</name>
    <value>hdfs://hadoop-master:8020/hbase</value>
    </property>
    <!-- 指定hbase是分布式的 -->
    <property>
    <name>hbase.cluster.distributed</name>
    <value>true</value>
    </property>
    <!-- 指定zk的地址,多个用“,”分割 -->
    <property>
    <name>hbase.zookeeper.quorum</name>
    <value>zookeeper1,zookeeper2,zookeeper3</value>
    </property>
</configuration>

配置regionservers:

1
2
3
4
5
cat > regionservers <<EOF
hadoop-master
hadoop-node1
hadoop-node2
EOF

设置备份主节点:可略

1
2
3
cat > backup-masters <<EOF
hadoop-node1
EOF

配置:

1
2
scp ./* root@hadoop-node1:/usr/local/hbase/conf/
scp ./* root@hadoop-node2:/usr/local/hbase/conf/

修改属组属主:

1
2
cd /usr/local
chown -R hadoop.hadoop hbase/ hbase

 

启动集群:在哪台启动哪台就是HMaster

1
2
3
4
5
6
7
8
9
10
11
12
~]$ start-hbase.sh 
starting master, logging to /usr/local/hbase/logs/hbase-hadoop-master-hadoop-master.out
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
hadoop-node2: starting regionserver, logging to /usr/local/hbase/bin/../logs/hbase-hadoop-regionserver-hadoop-node2.out
hadoop-node1: starting regionserver, logging to /usr/local/hbase/bin/../logs/hbase-hadoop-regionserver-hadoop-node1.out
hadoop-master: starting regionserver, logging to /usr/local/hbase/logs/hbase-hadoop-regionserver-hadoop-master.out
hadoop-node2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
hadoop-node2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
hadoop-node1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
hadoop-node1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
hadoop-node1: starting master, logging to /usr/local/hbase/bin/../logs/hbase-hadoop-master-hadoop-node1.out

主节点的HMaster和HRegionServer:

1
2
3
4
~]$ jps
2932 HRegionServer
2794 HMaster
...

普通节点就是HRegionServer:

1
2
3
]$ jps
1839 HRegionServer
...

启动backup-master:可实现高可用。

1
hbase-daemon.sh start master

浏览web概览页面:

1
http://192.168.0.54:16010/master-status

image.png

可以查看hdfs中已近有hbase数据写入了

1
~]$ hdfs dfs -ls -R /

停止集群:

1
2
~]$ stop-hbase.sh 
stopping hbase....................

命令行工具:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
~]$ hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase-1.2.1/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop-2.10.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.1, r8d8a7107dc4ccbf36a92f64675dc60392f85c015, Wed Mar 30 11:19:21 CDT 2016
 
hbase(main):001:0> status
1 active master, 0 backup masters, 3 servers, 0 dead, 0.6667 average load
 
hbase(main):002:0> quit
 posted on 2020-10-09 09:21  大码王  阅读(249)  评论(0编辑  收藏  举报
复制代码