企业项目实战hadoop篇---HBase高可用集群部署(四)

HBase高可用集群部署

一.Hbase 分布式部署

hbase 配置
解压hbase压缩包

tar zxf hbase-1.2.4-bin.tar.gz

配置hbase环境变量,加入java、hadoop路径

vim hbase-env.sh

在这里插入图片描述
由于已经配置好zk集群,因此不采用hbase提供的zk ,设置为false
在这里插入图片描述
配置 regionservers 文件,加入集群节点

[hadoop@server1 conf]$ cat regionservers 
172.25.3.2
172.25.3.3
172.25.3.4

配置hbase-site.xml

[hadoop@server1 conf]$ cat hbase-site.xml
<configuration>

<!-- 指定 region server 的共享目录,用来持久化 HBase。这里指定的 HDFS 地址
     是要跟 core-site.xml 里面的 fs.defaultFS 的 HDFS 的 IP 地址或者域名、端口必须一致。 -->
<property>
<name>hbase.rootdir</name>
<value>hdfs://masters/hbase</value>
</property>
<!-- 启用 hbase 分布式模式 -->
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<!-- Zookeeper 集群的地址列表,用逗号分割。默认是 localhost,是给伪分布式用
     的。要修改才能在完全分布式的情况下使用。 -->
<property>
<name>hbase.zookeeper.quorum</name>
<value>172.25.3.2,172.25.3.3,172.25.3.4</value>
</property>
<!-- 指定 hbase 的 master -->
<property>
<name>hbase.master</name>
<value>h1</value>
</property>
</configuration>

执行启动脚本,启动hbase

[hadoop@server1 hbase-1.2.4]$ bin/start-hbase.sh
starting master, logging to /home/hadoop/hbase-1.2.4/bin/../logs/hbase-hadoop-master-server1.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
172.25.3.2: starting regionserver, logging to /home/hadoop/hbase-1.2.4/bin/../logs/hbase-hadoop-regionserver-server2.out
172.25.3.3: starting regionserver, logging to /home/hadoop/hbase-1.2.4/bin/../logs/hbase-hadoop-regionserver-server3.out
172.25.3.4: starting regionserver, logging to /home/hadoop/hbase-1.2.4/bin/../logs/hbase-hadoop-regionserver-server4.out
172.25.3.2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
172.25.3.2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
172.25.3.3: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
172.25.3.3: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
172.25.3.4: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
172.25.3.4: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0

查看server1/5 主节点信息 HMaster

[hadoop@server1 hbase-1.2.4]$ jps
17602 DFSZKFailoverController
17779 NameNode
20483 Jps
20330 HMaster
19372 ResourceManager

查看server2/3/4节点信息 HRegionServer

[hadoop@server3 ~]$ jps
4338 QuorumPeerMain
5111 DataNode
6185 Jps
5931 HRegionServer
4940 JournalNode
5551 NodeManager

进入 bin/hbase shell,插入数据

[hadoop@server1 hbase-1.2.4]$ bin/hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/hbase-1.2.4/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/hadoop-3.2.1/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.4, r67592f3d062743907f8c5ae00dbbe1ae4f69e5af, Tue Oct 25 18:10:20 CDT 2016

hbase(main):001:0> create 'test', 'cf'
0 row(s) in 2.4580 seconds

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

=> ["test"]
hbase(main):003:0> put 'test', 'row1', 'cf:a', 'value1'
0 row(s) in 0.1580 seconds

hbase(main):004:0> put 'test', 'row2', 'cf:b', 'value2'
0 row(s) in 0.0160 seconds

hbase(main):005:0> put 'test', 'row3', 'cf:c', 'value3'
0 row(s) in 0.0200 seconds

hbase(main):006:0> scan 'test'
ROW                                          COLUMN+CELL                                                                                                                     
 row1                                        column=cf:a, timestamp=1629022054722, value=value1                                                                              
 row2                                        column=cf:b, timestamp=1629022060634, value=value2                                                                              
 row3                                        column=cf:c, timestamp=1629022066509, value=value3                                                                              
3 row(s) in 0.0630 seconds

执行ls命令,插入数据可以在hadoop内查看到

[hadoop@server5 ~]$ cd hadoop
[hadoop@server5 hadoop]$ bin/hdfs dfs -ls /
Found 2 items
drwxr-xr-x   - hadoop supergroup          0 2021-08-15 06:04 /hbase
drwxr-xr-x   - hadoop supergroup          0 2021-08-15 04:16 /user

访问 172.25.3.1:16010,可以看到 masterserver1 backupserver5 regions serverserver2/3/4
在这里插入图片描述

二.故障切换

关闭hmaster进程

[hadoop@server1 hbase-1.2.4]$ jps
17602 DFSZKFailoverController
20882 Jps
17779 NameNode
20330 HMaster
19372 ResourceManager
[hadoop@server1 hbase-1.2.4]$ kill 20330

查看切换,master切换为server5
在这里插入图片描述
启动server1节点

[hadoop@server1 hbase-1.2.4]$ bin/hbase-daemon.sh  start master
starting master, logging to /home/hadoop/hbase-1.2.4/bin/../logs/hbase-hadoop-master-server1.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

jps查看 HMaster


[hadoop@server1 hbase-1.2.4]$ jps
17602 DFSZKFailoverController
21170 Jps
17779 NameNode
19372 ResourceManager
21055 HMaster

backup master 显示为 server1
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值