Hbase配置之-单机模式

HBase 的运行模式包括单机、伪分布式和分布式三种。 单机模式使用本地文件系统,所有进程运行在一个 JVM 上,单机模式一 般只用于测试,HBase 需要结合 Hadoop 才能展现出其分布式存储的能力。

HBase单机模式是不需要自己额外再安装hadoop 和 zookeeper

1.关闭防火墙、关闭 SELinux

[root@localhost Desktop]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Jun 10 17:12:07 localhost.localdomain systemd[1]: Starting firewalld - dynami...
Jun 10 17:12:08 localhost.localdomain systemd[1]: Started firewalld - dynamic...
Jun 10 17:20:36 localhost.localdomain systemd[1]: Stopping firewalld - dynami...
Jun 10 17:20:37 localhost.localdomain systemd[1]: Stopped firewalld - dynamic...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost Desktop]# 
[root@localhost Desktop]# 
[root@localhost Desktop]# sestatus
SELinux status:                 disabled
[root@localhost Desktop]# 

2 配置JDK

[root@localhost Desktop]# which java
/export/servers/jdk1.8.0_311/bin/java

3 解压hbase

[root@localhost servers]# tar -xzvf /export/software/hbase-1.2.6-bin.tar.gz -C /export/servers/
[root@localhost servers]# cd /export/servers/
[root@localhost servers]# ls -ll
total 8
drwxr-xr-x. 9 root  root  4096 Aug 17  2016 hadoop-2.7.3
drwxr-xr-x  7 root  root   150 Jun 10 17:51 hbase-1.2.6
drwxr-xr-x. 8 10143 10143 4096 Sep 27  2021 jdk1.8.0_311

4 配置hbase环境变量

[root@localhost servers]# vi /etc/profile
#在这里插入代码片
export JAVA_HOME=/export/servers/jdk1.8.0_311
export HADOOP_HOME=/export/servers/hadoop-2.7.3
export HBASE_HOME=/export/servers/hbase-1.2.6
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin

5.配置hbase

5.1 $HBASE_HOME/conf/hbase-env.sh

由于HBase依赖JAVA_HOME环境变量,所以要编辑$HBASE_HOME/conf/hbase-env.sh文件,并取消注释以#export JAVA_HOME =开头的行,然后将其设置为Java安装路径。

[root@localhost conf]# vi $HBASE_HOME/conf/hbase-env.sh
#取消JAVA_HOME的注释,并设置JAVA_HOME
export JAVA_HOME=/export/servers/jdk1.8.0_311

hbase 默认使用内置 zookeeper

# Tell HBase whether it should manage it's own instance of Zookeeper or not.
# export HBASE_MANAGES_ZK=true

语句【export HBASE_MANAGES_ZK=true】表示采用HBase自带的ZooKeeper管理。如果想用外部ZooKeeper管理HBase,可以自行安装、配置ZooKeeper,再把该句删除。

5.2 $HBASE_HOME/conf/hbase-site.xml

在本地文件系统上指定HBase和ZooKeeper写入数据的目录并确认一些风险。默认情况下,在/export/data下创建一个新目录habase。默认位置/tmp,但是许多服务器配置为在重新引导时删除/ tmp的内容,因此您应该将数据存储在其他位置。

[root@localhost conf]# vi $HBASE_HOME/conf/hbase-site.xml
<configuration>
  <!-- hbase存放数据目录 -->
  <property>
    <name>hbase.rootdir</name>
    <value>file:///export/data/hbase/hbase</value>
  </property>

  <!-- ZooKeeper数据文件路径 -->
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/export/data/hbase/zookeeper</value>
  </property>
</configuration>

6.启动HBASE

6.1 启动

[root@localhost conf]# start-hbase.sh
starting master, logging to /export/servers/hbase-1.2.6/logs/hbase-root-master-localhost.localdomain.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

6.2 查看进程

[root@localhost conf]# jps
6211 Jps
6138 HMaster

HMaster进程就是HBase的主进程。HMaster进程启动表明HBase单机模式启动成功。

6.3 访问HBase的web界面

http://192.168.121.150:16010/master-status

在这里插入图片描述

6.4 关闭

[root@localhost conf]# stop-hbase.sh
stopping hbase................

7.常用HBase shell基本操作

7.1启动HBase Shell命令行

[root@localhost conf]# start-hbase.sh
starting master, logging to /export/servers/hbase-1.2.6/logs/hbase-root-master-localhost.localdomain.out
[root@localhost conf]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/export/servers/hbase-1.2.6/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/export/servers/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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.6, rUnknown, Mon May 29 02:25:32 CDT 2017

hbase(main):001:0> 

hbase(main):001:0>中的001用来统计用户输入的行数,该数字会随着用户输入的行数自增

7.2 查看HBase shell状态

hbase(main):001:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average load

通过结果可知,目前有1个活跃的主节点,0个备份的节点,1个服务节点。

7.3 查看版本信息

hbase(main):001:0> version
1.2.6, rUnknown, Mon May 29 02:25:32 CDT 2017

7.4 查看用户

hbase(main):002:0> whoami
root (auth:SIMPLE)
    groups: root

7.5 查看帮助

hbase(main):003:0> help
HBase Shell, version 1.2.6, rUnknown, Mon May 29 02:25:32 CDT 2017
Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command.
Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group.

COMMAND GROUPS:
  Group name: general
  Commands: status, table_help, version, whoami

  Group name: ddl
  Commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, locate_region, show_filters

  Group name: namespace
  Commands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables

  Group name: dml
  Commands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserve

  Group name: tools
  Commands: assign, balance_switch, balancer, balancer_enabled, catalogjanitor_enabled, catalogjanitor_run, catalogjanitor_switch, close_region, compact, compact_rs, flush, major_compact, merge_region, move, normalize, normalizer_enabled, normalizer_switch, split, trace, unassign, wal_roll, zk_dump

  Group name: replication
  Commands: add_peer, append_peer_tableCFs, disable_peer, disable_table_replication, enable_peer, enable_table_replication, list_peers, list_replicated_tables, remove_peer, remove_peer_tableCFs, set_peer_tableCFs, show_peer_tableCFs

  Group name: snapshots
  Commands: clone_snapshot, delete_all_snapshot, delete_snapshot, list_snapshots, restore_snapshot, snapshot

  Group name: configuration
  Commands: update_all_config, update_config

  Group name: quotas
  Commands: list_quotas, set_quota

  Group name: security
  Commands: grant, list_security_capabilities, revoke, user_permission

  Group name: procedures
  Commands: abort_procedure, list_procedures

  Group name: visibility labels
  Commands: add_labels, clear_auths, get_auths, list_labels, set_auths, set_visibility

SHELL USAGE:
Quote all names in HBase Shell such as table and column names.  Commas delimit
command parameters.  Type <RETURN> after entering a command to run it.
Dictionaries of configuration used in the creation and alteration of tables are
Ruby Hashes. They look like this:

  {
   'key1' => 'value1', 'key2' => 'value2', ...}

and are opened and closed with curley-braces.  Key/values are delimited by the
'=>' character combination.  Usually keys are predefined constants such as
NAME, VERSIONS, COMPRESSION, etc.  Constants do not need to be quoted.  Type
'Object.constants' to see a (messy) list of all constants in the environment.

If you are using binary keys or values and need to enter them in the shell, use
double-quote'd hexadecimal representation. For example:

  hbase> get 't1', "key\x03\x3f\xcd"
  hbase> get 't1', "key\003\023\011"
  hbase> put 't1', "test\xef\xff", 'f1:', "\x01\x33\x40"

The HBase shell is the (J)Ruby IRB with the above HBase-specific commands added.
For more on the HBase Shell, see http://hbase.apache.org/book.html

在返回的帮助信息中,列出了HBase Shell的所有命令。通过help 'command’命令可以查看command的详细用法。

hbase(main):002:0> help 'status'
Show cluster status. Can be 'summary', 'simple', 'detailed', or 'replication'. The
default is 'summary'. Examples:

  hbase> status
  hbase> status 'simple'
  hbase> status 'summary'
  hbase> status 'detailed'
  hbase> status 'replication'
  hbase> status 'replication', 'source'
  hbase> status 'replication', 'sink'
hbase(main):003:0> help 'version'
Output this HBase version
hbase(main):004:0> status 'simple'
active master:  localhost:37695 1654912011953
0 backup masters
1 live servers
    localhost:36999 1654912013866
        requestsPerSecond=0.0, numberOfOnlineRegions=2, usedHeapMB=15, maxHeapMB=237, numberOfStores=2, numberOfStorefiles=2, storefileUncompressedSizeMB=0, storefileSizeMB=0, memstoreSizeMB=0, storefileIndexSizeMB=0, readRequestsCount=10, writeRequestsCount=1, rootIndexSizeKB=0, totalStaticIndexSizeKB=0, totalStaticBloomSizeKB=
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值