deepin 安装 habse
创建软件目录
mkdir -p /home/lhz/opt
cd /home/lhz/opt
下载软件
wget https://dlcdn.apache.org/hbase/2.6.1/hbase-2.6.1-hadoop3-bin.tar.gz
hbase_15">解压 hbase
tar -zxvf hbase-2.6.1-hadoop3-bin.tar.gz
hbase__21">修改 hbase 目录名称
mv hbase-2.6.1-hadoop3 hbase-2
配置环境变量
vim /home/lhz/.bashrc
export HBASE_HOME=/home/lhz/opt/hbase-2
export PATH=$PATH:$HBASE_HOME/bin
完整
export JAVA_HOME=/home/lhz/opt/jdk-8
export M2_HOME=/home/lhz/opt/mavenexport ZOOKEEPER_HOME=/home/lhz/opt/zookeeper-3export HDFS_NAMENODE_USER=lhz
export HDFS_SECONDARYNAMENODE_USER=lhz
export HDFS_DATANODE_USER=lhz
export HDFS_ZKFC_USER=lhz
export HDFS_JOURNALNODE_USER=lhz
export HADOOP_SHELL_EXECNAME=lhzexport YARN_RESOURCEMANAGER_USER=lhz
export YARN_NODEMANAGER_USER=lhzexport HADOOP_HOME=/home/lhz/opt/hadoop-3
export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/nativeexport HBASE_HOME=/home/lhz/opt/hbase-2export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin:$ZOOKEEPER_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin
删除帮助文档
rm -rf /home/lhz/opt/hbase-2/docs
修改配置文件
cd /home/lhz/opt/hbase-2/conf
hbase__82">hbase 环境变量
vim hbase-env.sh
export JAVA_HOME=/home/lhz/opt/jdk-8
export HBASE_CLASSPATH=/home/lhz/opt/hadoop-3/etc/hadoop
export HBASE_MANAGES_ZK=false
export HBASE_HEAPSIZE=1G
export HBASE_DISABLE_HADOOP_CLASSPATH_LOOKUP=true
如果使用jdk21可以使用如下配置
export JAVA_HOME=/home/lhz/opt/jdk-21
export HBASE_CLASSPATH=/home/lhz/opt/hadoop-3/etc/hadoop
export HBASE_MANAGES_ZK=false
export HBASE_HEAPSIZE=1G
export HBASE_DISABLE_HADOOP_CLASSPATH_LOOKUP=true
export HBASE_JSHELL_ARGS="--startup DEFAULT --startup PRINTING --startup hbase_startup.jsh"
hbase__107">hbase 配置文件
vim hbase-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration><!-- mycluster是根据hdfs-site.xml的dfs.nameservices的value进行配置 --><property><name>hbase.rootdir</name><value>hdfs://lihaozhe/hbase</value></property><property><name>hbase.master</name><value>8020</value></property><property><name>hbase.cluster.distributed</name><value>true</value></property><property><name>hbase.zookeeper.quorum</name><value>lihaozhe:2181</value></property><property><name>hbase.unsafe.stream.capability.enforce</name><value>false</value></property>
</configuration>
regionservers
vim regionservers
lihaozhe
hbase_152">启动 hbase
start-hbase.sh
查看 Java 进程
jps
web ui
http://lihaozhe:16010/
hbase_shell_170">hbase shell
基本操作
hbase_shell_174">进入 hbase shell
hbase shell
使用帮助
help
命令
COMMAND GROUPS:Group name: generalCommands: processlist, status, table_help, version, whoamiGroup name: ddlCommands: alter, alter_async, alter_status, clone_table_schema, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, list_regions, locate_region, show_filtersGroup name: namespaceCommands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tablesGroup name: dmlCommands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserveGroup name: toolsCommands: assign, balance_switch, balancer, balancer_enabled, catalogjanitor_enabled, catalogjanitor_run, catalogjanitor_switch, cleaner_chore_enabled, cleaner_chore_run, cleaner_chore_switch, clear_block_cache, clear_compaction_queues, clear_deadservers, clear_slowlog_responses, close_region, compact, compact_rs, compaction_state, compaction_switch, decommission_regionservers, flush, flush_master_store, get_balancer_decisions, get_balancer_rejections, get_largelog_responses, get_slowlog_responses, hbck_chore_run, is_in_maintenance_mode, list_deadservers, list_decommissioned_regionservers, list_liveservers, list_unknownservers, major_compact, merge_region, move, normalize, normalizer_enabled, normalizer_switch, recommission_regionserver, regioninfo, rit, snapshot_cleanup_enabled, snapshot_cleanup_switch, split, splitormerge_enabled, splitormerge_switch, stop_master, stop_regionserver, trace, unassign, wal_roll, zk_dumpGroup name: replicationCommands: add_peer, append_peer_exclude_namespaces, append_peer_exclude_tableCFs, append_peer_namespaces, append_peer_tableCFs, disable_peer, disable_table_replication, enable_peer, enable_table_replication, get_peer_config, list_peer_configs, list_peers, list_replicated_tables, remove_peer, remove_peer_exclude_namespaces, remove_peer_exclude_tableCFs, remove_peer_namespaces, remove_peer_tableCFs, set_peer_bandwidth, set_peer_exclude_namespaces, set_peer_exclude_tableCFs, set_peer_namespaces, set_peer_replicate_all, set_peer_serial, set_peer_tableCFs, show_peer_tableCFs, update_peer_configGroup name: snapshotsCommands: clone_snapshot, delete_all_snapshot, delete_snapshot, delete_table_snapshots, list_snapshots, list_table_snapshots, restore_snapshot, snapshotGroup name: configurationCommands: update_all_config, update_config, update_rsgroup_configGroup name: quotasCommands: disable_exceed_throttle_quota, disable_rpc_throttle, enable_exceed_throttle_quota, enable_rpc_throttle, list_quota_snapshots, list_quota_table_sizes, list_quotas, list_snapshot_sizes, set_quotaGroup name: securityCommands: grant, list_security_capabilities, revoke, user_permissionGroup name: proceduresCommands: list_locks, list_proceduresGroup name: visibility labelsCommands: add_labels, clear_auths, get_auths, list_labels, set_auths, set_visibilityGroup name: rsgroupCommands: add_rsgroup, alter_rsgroup_config, balance_rsgroup, get_namespace_rsgroup, get_rsgroup, get_server_rsgroup, get_table_rsgroup, list_rsgroups, move_namespaces_rsgroup, move_servers_namespaces_rsgroup, move_servers_rsgroup, move_servers_tables_rsgroup, move_tables_rsgroup, remove_rsgroup, remove_servers_rsgroup, rename_rsgroup, show_rsgroup_configGroup name: storefiletrackerCommands: change_sft, change_sft_allSHELL 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
查看集群状态
查看版本号
version
查看登录用户
whoami
操作表
查看表空间
list_namespace
创建表空间
create_namespace 'lihaozhe',{"author"=>"lihaozhe", "create_time"=>"2024-11-06 14:30:00"}
描述表空间
describe_namespace 'lihaozhe'
查看某表空间下有哪些表
list_namespace_tables 'lihaozhe'
删除表空间
drop_namespace 'lihaozhe'
指定命名空间创建表
create 'lihaozhe:user', 'info' , 'msg'
create 'lihaozhe:person', {NAME => 'info', VERSIONS => 5} , {NAME => 'msg', VERSIONS => 5}
查看当前存在哪些表
所有表空间
list
描述表
describe 'lihaozhe:person'
验证表是否被禁用
is_disabled 'lihaozhe:user'
禁用表
disable 'lihaozhe:user'
启用表
enable 'lihaozhe:user'
插入数据到表
put 'lihaozhe:person',1001,'info:name','user1001'
put 'lihaozhe:person',1001,'info:gender',1
put 'lihaozhe:person',1001,'msg:slogan','hello world'put 'lihaozhe:person',1002,'info:name','user1002'
put 'lihaozhe:person',1002,'info:gender',0
put 'lihaozhe:person',1002,'msg:slogan','hello'put 'lihaozhe:person',1003,'info:name','user1003'
put 'lihaozhe:person',1003,'info:gender',1
put 'lihaozhe:person',1003,'msg:slogan','hi'
查询
扫描全表中的数据
scan 'lihaozhe:person'
按照指定 RowKey 查询
get 'lihaozhe:person', 1001
查询某 RowKey 下某列簇的值
get 'lihaozhe:person', 1001 , 'info'
查询表中某行+某一列簇+某一列的值
get 'lihaozhe:person', 1001 , 'info:name'
更新指定字段的数据
put 'lihaozhe:person',1001,'info:gender',0
统计数据
count 'lihaozhe:person'
删除数据
删除指定数据
delete 'lihaozhe:person',1001,'msg:slogan'
删除某RowKey下所有数据
deleteall 'lihaozhe:person',1001
清空表
truncate 'lihaozhe:person'
删除表
先禁用再删除不然会报错
disable 'lihaozhe:person'
drop 'lihaozhe:person'
的数据
put 'lihaozhe:person',1001,'info:gender',0
统计数据
count 'lihaozhe:person'
删除数据
删除指定数据
delete 'lihaozhe:person',1001,'msg:slogan'
删除某RowKey下所有数据
deleteall 'lihaozhe:person',1001
清空表
truncate 'lihaozhe:person'
删除表
先禁用再删除不然会报错
disable 'lihaozhe:person'
drop 'lihaozhe:person'