HBase单机版安装部署

1、安装前的环境准备工作,先要一台centos7机器,并安装JDK和Hadoop。

参考:Hadoop2.7.3在centos7上的单机版安装部署
需要注意hadoop的版本和HBase的版本

centos版本:CentOS-7.4-x86_64-DVD-1708.iso
JDK版本:jdk-8u231-linux-x64.tar.gz
Hadoop版本:hadoop-2.7.3.tar.gz
HBase版本:hbase-2.2.6-bin.tar.gz

2、HBase安装包下载

在这里插入图片描述

下载地址:https://mirrors.bfsu.edu.cn/apache/hbase/2.2.6/hbase-2.2.6-bin.tar.gz

3、安装部署HBase

3.1 在/usr/目录下新建一个hbase目录,并将hbase安装包hbase-2.2.6-bin.tar.gz上传到hbase目录下,并解压

tar -zxvf hbase-2.2.6-bin.tar.gz

在这里插入图片描述

3.2 修改/usr/hbase/hbase-2.2.6/conf/hbase-env.sh文件,要导入Java环境变量,在文件最后添加以下内容:

export JAVA_HOME=/usr/java/jdk1.8.0_231

在这里插入图片描述

3.3 执行以下语句,创建相应目录

mkdir -p /usr/hbase/hbase-2.2.6/hbase/
mkdir -p /usr/hbase/hbase-2.2.6/zookeeper/

3.4 修改/usr/hbase/hbase-2.2.6/conf/hbase-site.xml文件内容如下:

<configuration>
  <!-- hbase存放数据目录 -->
  <property>
    <name>hbase.rootdir</name>
    <value>file:///data/soft/hbase-2.2.6/hbase</value>

  </property>

  <!-- ZooKeeper数据文件路径 -->
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/usr/hbase/hbase-2.2.6/zookeeper</value>
  </property>

  <property>
    <name>hbase.unsafe.stream.capability.enforce</name>
    <value>false</value>
    <description>
      Controls whether HBase will check for stream capabilities (hflush/hsync).

      Disable this if you intend to run on LocalFileSystem, denoted by a rootdir
      with the 'file://' scheme, but be mindful of the NOTE below.

      WARNING: Setting this to false blinds you to potential data loss and
      inconsistent system state in the event of process and/or node failures. If
      HBase is complaining of an inability to use hsync or hflush it's most
      likely not a false positive.
    </description>
  </property>

</configuration>

在这里插入图片描述

3.5 将hbase添加到环境变量中,执行vi /etc/profile,将以下内容添加到文件最后,执行source /etc/profile使之生效。

export HBASE_HOME=/usr/hbase/hbase-2.2.6
export PATH=$HBASE_HOME/bin:$PATH   

3.6 启动、停止hbase,进入到/usr/hbase/hbase-2.2.6/目录

# 启动hbase
./bin/start-hbase.sh

# 停止hbase
./bin/stop-hbase.sh

在这里插入图片描述

浏览器中访问:http://192.168.1.9:16010/master-status
在这里插入图片描述

4、使用使用hbase shell客户端连接HBase,进行相关操作

4.1 进入/usr/hbase/hbase-2.2.6/目录,

./bin/hbase shell

在这里插入图片描述

4.2 使用create命令创建一个新表,指定表名称和ColumnFamily名称。

create 'test01', 'che01'

在这里插入图片描述

4.3 使用list命令确认您的表存在

list 'test01'

在这里插入图片描述

4.4 使用describe命令查看详细信息,包括配置默认值

describe 'test01'

在这里插入图片描述

4.5 使用put命令,将数据放到表中

put 'test01', 'row1', 'che01:01', 'value1'
put 'test01', 'row2', 'che01:02', 'value2'
put 'test01', 'row3', 'che01:03', 'value3'

# 
scan 'test01'

在这里插入图片描述

在这里插入图片描述

4.6 查看我某一单条数据

get 'test01', 'row2'

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/ytangdigl/article/details/109139682
今日推荐