如何在 Kubernetes 部署 HBase 数据库

公众号关注 「奇妙的 Linux 世界」

设为「星标」,每天带你玩转 Linux !

fe1d8e9dbe687b0dd8863bb571bc628e.png

一、概述

HBase 是一个面向列式存储的分布式数据库,其设计思想来源于 Google 的 BigTable 论文。HBase 底层存储基于 HDFS 实现,集群的管理基于 ZooKeeper 实现。HBase 良好的分布式架构设计为海量数据的快速存储、随机访问提供了可能,基于数据副本机制和分区机制可以轻松实现在线扩容、缩容和数据容灾,是大数据领域中 Key-Value 数据结构存储最常用的数据库方案。

823d3ac6498d172dc46c3b9d26272ffb.png

二、开始编排部署(非高可用HDFS)

地址:https://artifacthub.io/packages/helm/hbase/hbase

1)下载chart 包

helm repo add hbase https://itboy87.github.io/bigdata-charts/

# hbase version 2.4.13
helm pull hbase/hbase --version 0.1.7

2)构建镜像

在下面连接hadoop高可用会重新构建镜像,这里就不重新构建镜像了,只是把远程的包推送到本地harbor仓库

docker pull ghcr.io/fleeksoft/hbase/hbase-base:2.4.13.2

# tag
docker tag ghcr.io/fleeksoft/hbase/hbase-base:2.4.13.2 myharbor.com/bigdata/hbase-base:2.4.13.2

# push
docker push myharbor.com/bigdata/hbase-base:2.4.13.2

3)修改yaml编排(非高可用HDFS)

  • hbase/values.yaml

image:
  repository: myharbor.com/bigdata/hbase-base
  tag: 2.4.13.2
  pullPolicy: IfNotPresent

...

conf:
  hadoopUserName: admin
  hbaseSite:
    hbase.rootdir:  "hdfs://hadoop-hadoop-hdfs-nn.hadoop:9000/hbase"
    hbase.zookeeper.quorum:  "zookeeper.zookeeper:2181"

...

hbase:
  master:
    replicas: 2

  regionServer:
    replicas: 2

# 禁用内部的hadoop
hadoop:
  enabled: false

# 禁用内部的zookeeper
zookeeper:
  enabled: false
  • hbase/templates/hbase-configmap.yaml

if [ {{ .Values.hadoop.enabled }} = true ];then
  NAMENODE_URL={{- printf "http://%s-hadoop-hdfs-nn:9870/index.html" .Release.Name }}
else
  hadoop_url={{ index .Values.conf.hbaseSite "hbase.rootdir" }}
  hadoop_url=`echo $hadoop_url|awk -F '/' '{print $3}'|awk -F':' '{print $1}'`
  NAMENODE_URL=http://${hadoop_url}:9870/index.html
fi

4)开始部署

# 先检查语法
helm lint ./hbase

# 开始安装
helm install hbase ./hbase -n hbase --create-namespace

NOTES

NAME: hbase
LAST DEPLOYED: Sat Nov  5 15:44:14 2022
NAMESPACE: hbase
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. You can get an HBASE Shell by running this command:
   kubectl exec -n hbase -it hbase-hbase-master-0 -- hbase shell

2. Inspect hbase master service ports with:
   kubectl exec -n hbase describe service hbase-hbase-master

3. Create a port-forward to the hbase manager UI:
   kubectl port-forward -n hbase svc/hbase-hbase-master 16010:16010

   Then open the ui in your browser:

   open http://localhost:16010

4. Create a port-forward to the hbase thrift manager UI:
   kubectl port-forward -n hbase svc/hbase-hbase-master 9095:9095

   Then open the ui in your browser:

   open http://localhost:9095

3c4b23875a82d9a2dd273129162ef72c.png
HDFS
d8b88a924906ea08c0a3aa6e0c78560b.png
查看

kubectl get pods,svc -n hbase -owide

cc4410c9781124bc03c2f8049252b6ae.png
10e6adc02e9c38f1b98772f5d1519fb4.png

5)测试验证

测试主备切换,重启当前active master pod

kubectl delete pod hbase-hbase-master-0 -n hbase

主备能正常切换
7f874118bfbb492f9d8144b3f518b246.png

6)卸载

helm uninstall hbase -n hbase
# delete ns 
kubectl delete ns hbase --force

三、开始编排部署(高可用 HDFS)

1)下载chart 包

helm repo add hbase https://itboy87.github.io/bigdata-charts/

# hbase version 2.4.13
helm pull hbase/hbase --version 0.1.7

2)构建镜像

这里是基于上面的镜像进行构建,只是把hadoop打包到镜像中,主要用的hadoop配置文件是core-site.yamlhdfs-site.yaml

Dockerfile

FROM myharbor.com/bigdata/hbase-base:2.4.13.2

RUN mkdir -p /opt/apache

ENV HADOOP_VERSION=3.3.2

ADD hadoop-${HADOOP_VERSION}.tar.gz /opt/apache

ENV HADOOP_HOME=/opt/apache/hadoop

RUN ln -s /opt/apache/hadoop-${HADOOP_VERSION} $HADOOP_HOME

ENV HADOOP_CONF_DIR=${HADOOP_HOME}/et/hadoop

ENV PATH=${HADOOP_HOME}/bin:$PATH

开始构建

docker build -t myharbor.com/bigdata/hbase-hdfs-ha:2.4.13.2 . --no-cache

### 参数解释
# -t:指定镜像名称
# . :当前目录Dockerfile
# -f:指定Dockerfile路径
#  --no-cache:不缓存

# 推送到harbor
docker push myharbor.com/bigdata/hbase-hdfs-ha:2.4.13.2

3)修改配置

  • hbase-hdfs-ha/values.yaml

image:
  repository: myharbor.com/bigdata/hbase-hdfs-ha
  tag: 2.4.13.2
  pullPolicy: IfNotPresent

...

conf:
  hadoopUserName: admin
  hbaseSite:
    hbase.rootdir: "hdfs://myhdfs/hbase"
    hbase.zookeeper.quorum: "zookeeper.zookeeper:2181"
  • hbase-hdfs-ha/templates/hbase-configmap.yaml

if [ {{ .Values.hadoop.enabled }} = true ];then
  NAMENODE_URL={{- printf "http://%s-hadoop-hdfs-nn:9870/index.html" .Release.Name }}
else
  NAMENODE_URL=http://hadoop-ha-hadoop-hdfs-nn-1.hadoop-ha:9870:9870/index.html
fi
# 先检查语法
helm lint ./hbase-hdfs-ha

# 开始安装
helm install hbase-hdfs-ha ./hbase-hdfs-ha -n hbase-hdfs-ha --create-namespace

NOTES

NAME: hbase-hdfs-ha
LAST DEPLOYED: Sat Nov  5 17:23:20 2022
NAMESPACE: hbase-hdfs-ha
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. You can get an HBASE Shell by running this command:
   kubectl exec -n hbase-hdfs-ha -it hbase-hdfs-ha-hbase-master-0 -- hbase shell

2. Inspect hbase master service ports with:
   kubectl exec -n hbase-hdfs-ha describe service hbase-hdfs-ha-hbase-master

3. Create a port-forward to the hbase manager UI:
   kubectl port-forward -n hbase-hdfs-ha svc/hbase-hdfs-ha-hbase-master 16010:16010

   Then open the ui in your browser:

   open http://localhost:16010

4. Create a port-forward to the hbase thrift manager UI:
   kubectl port-forward -n hbase-hdfs-ha svc/hbase-hdfs-ha-hbase-master 9095:9095

   Then open the ui in your browser:

   open http://localhost:9095

4c2fa138223cd667e954f0f5b5aeaa10.png
HDFS
a3ecf49c61319d87a01405f86bed8de6.png
查看

kubectl get pods,svc -n hbase-hdfs-ha

96a9086d50870a7893158c4094ad84b9.png
97d42dd6dfe63882c44990e78cf18183.png

5)测试验证

测试主备切换,重启当前active master pod

kubectl delete pod hbase-hbase-master-0 -n hbase

主备能正常切换
98e8a702856e17d184f1b763da037b38.png

6)卸载

helm uninstall hbase-hdfs-ha -n hbase-hdfs-ha
# delete ns 
kubectl delete ns hbase-hdfs-ha --force

git 地址:https://gitee.com/hadoop-bigdata/hbase-on-k8s

HBase on k8s 编排部署讲解与实战操作就先到这里了。一搜划划线并转

本文转载自:「大数据与云原生技术分享」,原文:https://tinyurl.com/3y6wkt6v,版权归原作者所有。欢迎投稿,投稿邮箱: editor@hi-linux.com。

029b51af35ea299abd8f12781cf3bd4a.gif

最近,我们建立了一个技术交流微信群。目前群里已加入了不少行业内的大神,有兴趣的同学可以加入和我们一起交流技术,在 「奇妙的 Linux 世界」 公众号直接回复 「加群」 邀请你入群。

16822ee83a457597e4ef6f579ae44a0e.png

你可能还喜欢

点击下方图片即可阅读

40b7616d9583c51cba48d7b0186ddc40.png

Monokle: Lens 之后又一超赞的 Kubernetes 开源桌面管理工具

16f64f06bebfb908de5091e06ebc541c.png
点击上方图片,『美团|饿了么』外卖红包天天免费领

36727667fc7b1d833057c30e58ded188.png

更多有趣的互联网新鲜事,关注「奇妙的互联网」视频号全了解!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值