• 安装配置HBase


    HBase集群需要整个集群所有节点安装的HBase版本保持一致,并且拥有相同的配置,具体配置步骤如下:

    1. 解压缩HBase的压缩包

    2. 配置HBase的环境变量

    3. 修改HBase的配置文件,HBase的配置文件存放在HBase安装目录下的conf中

    4. 首先在一台节点对整个HBase集群进行配置,再将此节点的配置发送到集群的其它节点上。

    5. 具体需要修改的HBase的配置文件包括 hbase-site.xml、hbase-env.sh、regionservers、backup-masters、

    HBase版本选择

    安装HBase(在node1上安装配置HBase,然后再使用【scp】命令分发到其他节点)

    • 项目中使用的HBase安装包,已经存放在/opt/software目录下,直接解压使用即可:
    [root@node1 ~]# tar -xzf /opt/software/hbase.tar.gz -C /opt/module/
    • 通过【vi】命令编辑/etc/profile文件
    [root@node1 ~]# vi /etc/profile
    • 设置HBase环境变量,在/etc/profile 文件的末尾添加如下内容:
    1. export HBASE_HOME=/opt/module/hbase
    2. export PATH=$PATH:$HBASE_HOME/bin

    • 使用【scp】将环境变量分发至其它节点
    1. [root@node1 ~]# scp -rq /etc/profile node2:/etc/
    2. [root@node1 ~]# scp -rq /etc/profile node3:/etc/

    解释

    部分参数说明: -p:保留原文件的修改时间,访问时间和访问权限。 -q: 不显示传输进度条。 -r: 递归复制整个目录。 所以,如果使用scp命令只复制单个文件,可以不添加-rq参数。

    • 使用【source】命令,使配置文件生效
    [root@node1 ~]# source  /etc/profile

    配置HBase

    • 配置hbase-env.sh文件
    1. [root@node1 ~]# cd $HBASE_HOME/conf
    2. [root@node1 ~]# vi hbase-env.sh

    在文件末尾添加如下配置:

    1. export JAVA_HOME=/opt/module/jdk1.8.0_301/
    2. export HBASE_MANAGES_ZK=false

    • 配置 hbase-site.xml文件,该文件存放在$HBASE_HOME/conf目录下
    [root@node1 conf]# vi hbase-site.xml

    之间配置内容如下:

    1. <property>
    2. <name>hbase.rootdir</name>
    3. <value>hdfs://node1:9000/hbase</value>
    4. </property>
    5. <property>
    6. <name>hbase.unsafe.stream.capability.enforce</name>
    7. <value>false</value>
    8. </property>
    9. <property>
    10. <name>hbase.cluster.distributed</name>
    11. <value>true</value>
    12. </property>
    13. <property>
    14. <name>hbase.zookeeper.quorum</name>
    15. <value>node1:2181,node2:2181,node3:2181</value>
    16. </property>

    配置完成后完整内容如下:

    1. <?xml version="1.0"?>
    2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
    3. <!--
    4. /**
    5. *
    6. * Licensed to the Apache Software Foundation (ASF) under one
    7. * or more contributor license agreements. See the NOTICE file
    8. * distributed with this work for additional information
    9. * regarding copyright ownership. The ASF licenses this file
    10. * to you under the Apache License, Version 2.0 (the
    11. * "License"); you may not use this file except in compliance
    12. * with the License. You may obtain a copy of the License at
    13. *
    14. * http://www.apache.org/licenses/LICENSE-2.0
    15. *
    16. * Unless required by applicable law or agreed to in writing, software
    17. * distributed under the License is distributed on an "AS IS" BASIS,
    18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    19. * See the License for the specific language governing permissions and
    20. * limitations under the License.
    21. */
    22. -->
    23. <configuration>
    24. <property>
    25. <name>hbase.rootdir</name>
    26. <value>hdfs://node1:9000/hbase</value>
    27. </property>
    28. <property>
    29. <name>hbase.unsafe.stream.capability.enforce</name>
    30. <value>false</value>
    31. </property>
    32. <property>
    33. <name>hbase.cluster.distributed</name>
    34. <value>true</value>
    35. </property>
    36. <property>
    37. <name>hbase.zookeeper.quorum</name>
    38. <value>node1:2181,node2:2181,node3:2181</value>
    39. </property>
    40. </configuration>

    配置regionservers文件

    [root@node1 conf]# vi regionservers

    配置内容如下:

    1. node1
    2. node2
    3. node3
    • 将Hadoop的配置文件拷贝到HBase的conf目录
    1. [root@node1 conf]# cp $HADOOP_HOME/etc/hadoop/core-site.xml $HBASE_HOME/conf/
    2. [root@node1 conf]# cp $HADOOP_HOME/etc/hadoop/hdfs-site.xml $HBASE_HOME/conf/
    • 将node1的HBase分发至整个集群的其他节点:
    1. [root@node1 ~]# cd /opt/module/
    2. [root@node1 module]# scp -rq hbase node2:/opt/module/
    3. [root@node1 module]# scp -rq hbase node3:/opt/module/

    启动集群并测试

    • 在node1上启动HBase集群并,并在client节点上通过浏览器访问 http://node1:16010 查看HBase的Web监控页面
    [root@node1 ~]# start-hbase.sh

    • 新建一个名为test的表,使其只包含一个名为data的列,表和列族属性都为默认值
    1. [root@node1 ~]# hbase shell
    2. hbase(main):001:0> create 'test','data'
    3. 0 row(s) in 0.4150 seconds

    • 通过键入help查看帮助命令,运行list查看新建的表是否存在

    解释

    hbase(main):003:0> list TABLE test 1 row(s) in 0.0230 seconds

    • 在列族data中二个不同的行和列上插入数据,然后列出表内容
    1. hbase(main):004:0> put 'test','row1','data:1','values1'
    2. 0 row(s) in 0.1280 seconds
    3. hbase(main):005:0> put 'test','row2','data:2','values2'
    4. 0 row(s) in 0.0090 seconds
    5. hbase(main):006:0> scan 'test'
    6. ROW COLUMN+CELL
    7. row1 column=data:1, timestamp=1473585137461, value=values1
    8. row2 column=data:2, timestamp=1473585158072, value=values2
    9. 2 row(s) in 0.0200 seconds
    • 删除刚创建的表test,需要先设为禁用,然后删除,不设置会报错:
    1. hbase(main):008:0> drop 'test'
    2. ERROR: Table test is enabled. Disable it first.
    3. hbase(main):009:0> disable 'test'
    4. 0 row(s) in 1.1800 seconds
    5. hbase(main):010:0> drop 'test'
    6. 0 row(s) in 0.1570 seconds

    • 查看一下,是否删除成功

    • 输入【quit】命令,即可退出Base Shell命令行模式
    hbase(main):007:0> quit()
  • 相关阅读:
    构建基于深度学习神经网络协同过滤模型(NCF)的视频推荐系统(Python3.10/Tensorflow2.11)
    JAVA中的集合类型的理解及应用
    计算机毕业设计Java小动物领养网站(源码+系统+mysql数据库+Lw文档)
    PSI-BLAST位点特异性矩阵PSSM和ProteinMPNN中氨基酸顺序映射
    node写登录
    中国DevOps平台市场,华为云再次位居领导者位置
    数据库锁介绍
    docker安装Elasticsearch
    “先导杯”来啦!召唤科学计算界的最强大脑,36万奖池等你来拿!
    flume+es+kibana日志系统
  • 原文地址:https://blog.csdn.net/2201_75642955/article/details/136639110