大数据全系列 教程
1869个小节阅读:467.7k
目录
408考研
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
搭建方式:独立模式、伪分布式、完全分布式
实际上,您需要完全分布式配置才能完全测试HBase并在实际场景中使用它。在分布式配置中,群集包含多个节点,每个节点运行一个或多个HBase守护程序。其中包括主要和备用Master,多个Zookeeper节点和多个RegionServer节点。
规划如下:
NodeName | Master | Zookeeper | RegionServer |
---|---|---|---|
node1 | yes | no | no |
node2 | backup | yes | yes |
node3 | no | yes | yes |
node4 | no | yes | yes |
下载网址:https://archive.apache.org/dist/hbase/
具体操作:
1、配置四台主机,实现彼此之间的免密钥登录。为四台虚拟机分别拍摄快照。
2、将安装包上传到node1的/opt/apps下,然后解压到的/opt
xxxxxxxxxx
[root@node1 apps]# ls
hbase-2.0.5-bin.tar.gz
[root@node1 apps]# tar -zxvf hbase-2.0.5-bin.tar.gz -C /opt/
3、 四个节点:在/etc/profile中配置HBASE_HOME,并将HBase的bin目录添加到PATH中
xxxxxxxxxx
# 配置HBase的环境变量
[root@node1 conf]# vim /etc/profile
export HBASE_HOME=/opt/hbase-2.0.5
export PATH=$PATH:$HBASE_HOME/bin
[root@node1 conf]# source /etc/prifile
4、 进入conf,编辑regionservers
配置如下:
xxxxxxxxxx
node2
node3
node4
5、 配置node2为backup master
在conf中添加一个文件backup-masters,并配置如下
xxxxxxxxxx
[root@node1 conf]# echo "node2" >> backup-masters
[root@node1 conf]# chown itbaizhan:itbaizhan backup-masters
6、 在conf/hbase-env.sh中设置JAVA_HOME和pid目录
xxxxxxxxxx
# The java implementation to use. Java 1.8+ required.
export JAVA_HOME=/usr/java/default
# The directory where pid files are stored. /tmp by default.
export HBASE_PID_DIR=/opt/hbase-2.0.5/pids
7、 配置zookeeper
a) 设置使用外部的zookeeper
在conf/hbase-env.sh中设置
xxxxxxxxxx
# Tell HBase whether it should manage it's own instance of ZooKeeper or not.
export HBASE_MANAGES_ZK=false
b) 要么将zoo.cfg拷贝到HBASE的CLASSPATH,要么在hbase-site.xml中配置zookeeper的信息。hbase会优先使用zoo.cfg的配置。在hbase-site.xml中配置如下:
xxxxxxxxxx
<configuration>
<!-- 指定hbase在HDFS文件系统上的根路径 -->
<property>
<name>hbase.rootdir</name>
<value>hdfs://mycluster/hbase_ha</value>
</property>
<!-- 使用hbase集群分布式 -->
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<!-- 指定hbase使用到的zk集群 -->
<property>
<name>hbase.zookeeper.quorum</name>
<value>node2,node3,node4</value>
</property>
</configuration>
8、 拷贝hdfs-site.xml到HBASE_HOME/conf,当然,最好是做一个符号链接。
xxxxxxxxxx
[root@node1 conf]# ln /opt/hadoop-3.1.3/etc/hadoop/hdfs-site.xml hdfs-site.xml
9、 将/opt/hbase-2.0.5拷贝到node2,node3和node4。
xxxxxxxxxx
[root@node1 opt]# scp -r hbase-2.0.5/ root@node2:/opt/
[root@node1 opt]# scp -r hbase-2.0.5/ root@node3:/opt/
[root@node1 opt]# scp -r hbase-2.0.5/ root@node4:/opt/
10、 启动hadoop集群(包含Zookeeper集群)
xxxxxxxxxx
[root@node1 opt]# startha.sh