当前位置: 首页 > news >正文

HBase基础知识(二):HBase集群部署、HBaseShell操作

1. HBase安装部署

1.1 Zookeeper正常部署

首先保证Zookeeper集群的正常部署,并启动之:

创建集群启动脚本:

#!/bin/bash
case $1 in
"start"){
for i in hadoop100 hadoop101 hadoop102
do
echo----------zookeeper $i 启动------------
ssh $i "/opt/module/zookeeper-3.4.10/bin/zkServer.sh start"
done
};;
​
"stop"){
for i in hadoop100 hadoop101 hadoop102
do
echo----------zookeeper $i 停止------------
ssh $i "/opt/module/zookeeper-3.4.10/bin/zkServer.sh stop"
done
};;
​
"status"){
for i in hadoop100 hadoop101 hadoop102
do
echo----------zookeeper $i 状态------------
ssh $i "/opt/module/zookeeper-3.4.10/bin/zkServer.sh status"
done
};;
esac

1.2 Hadoop正常部署

Hadoop集群的正常部署并启动:

sbin/start-dfs.sh
sbin/start-yarn.sh

1.3 HBase的解压

解压Hbase到指定目录:

tar -zxvf hbase-1.3.1-bin.tar.gz -C /opt/module

1.4 HBase的配置文件

修改HBase对应的配置文件。

1)hbase-env.sh修改内容:

先获取自己环境的java信息

echo $JAVA_HOME
/opt/module/jdk1.8.0_161

注释下面的信息:

修改一下信息:

export JAVA_HOME=/opt/module/jdk1.8.0_161
export HBASE_MANAGES_ZK=false

2)hbase-site.xml修改内容:

<?xmlversion="1.0"?>
<configuration>
<property><name>hbase.rootdir</name><value>hdfs://hadoop100:8020/HBase</value>
</property><property><name>hbase.cluster.distributed</name><value>true</value>
</property>
<!--0.98后的新变动,之前版本没有.port,默认端口为60000-->
<property><name>hbase.master.port</name><value>16000</value>
</property>
<property><name>hbase.zookeeper.quorum</name><value>hadoop100,hadoop101,hadoop102</value>
</property>
<property><name>hbase.zookeeper.property.dataDir</name><value>/opt/module/zookeeper-3.4.10/zkData</value>
</property>
</configuration>

3)regionservers:

hadoop100
hadoop101
hadoop102

4)软连接hadoop配置文件到HBase:

ln -s /opt/module/hadoop-3.1.3/etc/hadoop/core-site.xml/opt/module/hbase-1.3.1/conf/core-site.xml
ln -s /opt/module/hadoop-3.1.3/etc/hadoop/hdfs-site.xml/opt/module/hbase-1.3.1/conf/hdfs-site.xml

可以看到两个文件都做好了引用:

1.5 HBase远程发送到其他集群

xsync.sh hbase-1.3.1

1.6 HBase服务的启动

1.启动方式

bin/hbase-daemon.sh start master
startingmaster,loggingto/opt/module/hbase-1.3.1/bin/../logs/hbase-atguigu-master-hadoop100.out
bin/hbase-daemon.sh start regionserver
startingregionserver,loggingto/opt/module/hbase-1.3.1/bin/../logs/hbase-atguigu-regionserver-hadoop100.out

提示:如果集群之间的节点时间不同步,会导致regionserver无法启动,抛出ClockOutOfSyncException异常。修复提示:

a、同步时间服务请参看帮助文档:《尚硅谷大数据技术之Hadoop入门》

b、属性:hbase.master.maxclockskew设置更大的值

<property><name>hbase.master.maxclockskew</name><value>180000</value><description>Timedifferenceofregionserverfrommaster</description>
</property>

2.启动方式

bin/start-hbase.sh

可以看到输出:

startingmaster,loggingto/opt/module/hbase-1.3.1/bin/../logs/hbase-atguigu-master-hadoop100.out
hadoop101:startingregionserver,loggingto/opt/module/hbase-1.3.1/bin/../logs/hbase-atguigu-regionserver-hadoop101.out
hadoop102:startingregionserver,loggingto/opt/module/hbase-1.3.1/bin/../logs/hbase-atguigu-regionserver-hadoop102.out
hadoop100:startingregionserver,loggingto/opt/module/hbase-1.3.1/bin/../logs/hbase-atguigu-regionserver-hadoop100.out

对应的停止服务:

bin/stop-hbase.sh

2. HBaseShell操作

2.1 基本操作

1.进入HBase客户端命令行

bin/hbaseshell

2.查看帮助命令

hbase(main):001:0>help
HBaseShell,version1.3.1,r930b9a55528fe45d8edce7af42fef2d35e77677a,ThuApr619:36:54PDT2017
Type'help"COMMAND"',(e.g.'help"get"'--thequotesarenecessary)forhelponaspecificcommand.
Commandsaregrouped.Type'help"COMMAND_GROUP"',(e.g.'help"general"')forhelponacommandgroup.
​
COMMANDGROUPS:
Groupname:general
Commands:status,table_help,version,whoami
​
#Groupname: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
​
Groupname:namespace
Commands:alter_namespace,create_namespace,describe_namespace,drop_namespace,list_namespace,list_namespace_tables
​
#Groupname:dml
#Commands:append,count,delete,deleteall,get,get_counter,get_splits,incr,put,scan,truncate,truncate_preserve
​
Groupname: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,splitormerge_enabled,splitormerge_switch,trace,unassign,wal_roll,zk_dump
​
Groupname:replication
Commands:add_peer,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_tableCFs,set_peer_tableCFs,show_peer_tableCFs
​
Groupname:snapshots
Commands:clone_snapshot,delete_all_snapshot,delete_snapshot,delete_table_snapshots,list_snapshots,list_table_snapshots,restore_snapshot,snapshot
​
Groupname:configuration
Commands:update_all_config,update_config
​
Groupname:quotas
Commands:list_quotas,set_quota
​
Groupname:security
Commands:grant,list_security_capabilities,revoke,user_permission
​
Groupname:procedures
Commands:abort_procedure,list_procedures
​
Groupname:visibilitylabels
Commands:add_labels,clear_auths,get_auths,list_labels,set_auths,set_visibility
​
SHELLUSAGE:
QuoteallnamesinHBaseShellsuchastableandcolumnnames.Commasdelimit
commandparameters.Type<RETURN>afterenteringacommandtorunit.
Dictionariesofconfigurationusedinthecreationandalterationoftablesare
RubyHashes.Theylooklikethis:
​
{'key1'=>'value1','key2'=>'value2',...}
​
andareopenedandclosedwithcurley-braces.Key/valuesaredelimitedbythe
'=>'charactercombination.Usuallykeysarepredefinedconstantssuchas
NAME,VERSIONS,COMPRESSION,etc.Constantsdonotneedtobequoted.Type
'Object.constants'toseea(messy)listofallconstantsintheenvironment.
​
Ifyouareusingbinarykeysorvaluesandneedtoenterthemintheshell,use
double-quote'dhexadecimalrepresentation.Forexample:
​
hbase>get't1',"key\x03\x3f\xcd"
hbase>get't1',"key\003\023\011"
hbase>put't1',"test\xef\xff",'f1:',"\x01\x33\x40"
​
TheHBaseshellisthe(J)RubyIRBwiththeaboveHBase-specificcommandsadded.
FormoreontheHBaseShell,seehttp://hbase.apache.org/book.html

3.查看当前数据库中有哪些表

hbase(main):002:0>list
TABLE
0row(s)in0.6350seconds
​
=>[]

2.2 表的操作

1.创建表

hbase(main):003:0>create 'student','info'
0row(s)in2.4680seconds
​
=>Hbase::Table-student
hbase(main):004:0>create 'stu','info1','info2'
0row(s)in1.2800seconds
​
=>Hbase::Table-stu
hbase(main):005:0>list
TABLE
stu
student
2row(s)in0.0200seconds
​
=>["stu","student"]

2.插入数据到表

hbase(main):003:0>put 'student','1001','info:sex','male'
hbase(main):004:0>put 'student','1001','info:age','18'
hbase(main):005:0>put 'student','1002','info:name','Janna'
hbase(main):006:0>put 'student','1002','info:sex','female'
hbase(main):007:0>put 'student','1002','info:age','20'

3.扫描查看表数据

hbase(main):008:0>scan 'student'
hbase(main):009:0>scan 'student',{STARTROW=>'1001',STOPROW=>'1001'}
hbase(main):010:0>scan 'student',{STARTROW=>'1001'}

4.查看表结构

describe ‘student’

5.更新指定字段的数据

hbase(main):012:0>put 'student','1001','info:name','Nick'
hbase(main):013:0>put 'student','1001','info:age','100'

6.查看“指定行”或“指定列族:列”的数据

hbase(main):014:0>get 'student','1001'
hbase(main):015:0>get 'student','1001','info:name'

7.统计表数据行数

hbase(main):021:0>count 'student'

8.删除数据

删除某rowkey的全部数据:

hbase(main):016:0>deleteall 'student','1001'

删除某rowkey的某一列数据:

hbase(main):017:0>delete 'student','1002','info:sex'

9.清空表数据

hbase(main):018:0>truncate 'student'

提示:清空表的操作顺序为先disable,然后再truncate。

10.删除表

首先需要先让该表为disable状态:

hbase(main):019:0>disable 'student'

然后才能drop这个表:

hbase(main):020:0>drop 'student'

提示:如果直接drop表,会报错:ERROR:Tablestudentisenabled.Disableitfirst.

11.变更表信息

将info列族中的数据存放3个版本:

hbase(main):022:0>alter 'student',{NAME=>'info',VERSIONS=>3}
hbase(main):022:0>get 'student','1001',{COLUMN=>'info:name',VERSIONS=>3}

相关文章:

HBase基础知识(二):HBase集群部署、HBaseShell操作

1. HBase安装部署 1.1 Zookeeper正常部署 首先保证Zookeeper集群的正常部署&#xff0c;并启动之&#xff1a; 创建集群启动脚本&#xff1a; #!/bin/bash case $1 in "start"){ for i in hadoop100 hadoop101 hadoop102 do echo----------zookeeper $i 启动----…...

C 标准库 - <time.h>

简介 time.h 头文件定义了四个变量类型、两个宏和各种操作日期和时间的函数。 库变量 下面是头文件 time.h 中定义的变量类型&#xff1a; 序号变量 & 描述1size_t是无符号整数类型&#xff0c;它是 sizeof 关键字的结果。2clock_t这是一个适合存储处理器时间的类型。3…...

养老院自助饮水机(字符设备驱动)

目录 1、项目背景 2、驱动程序 2.1 三层架构 2.2 驱动三要素 2.3 字符设备驱动 2.3.1 驱动模块 2.3.2 应用层 3、设计实现 3.1 项目设计 3.2 项目实现 3.2.1 驱动模块代码 3.2.2 用户层代码 4、功能特性 5、技术分析 6. 总结与未来展望 1、项目背景 养老院的老人…...

Jenkins 构建触发器指南

目录 触发远程构建 (例如&#xff0c;使用脚本) 描述 配置步骤 安全令牌 在其他项目构建完成后触发构建 描述 配置步骤 定时触发构建 描述 配置步骤 GitHub钩子触发GITScm轮询 描述 配置步骤 Poll SCM - 轮询版本控制系统 描述 触发远程构建 (例如&#xff0c;使…...

通用的java中部分方式实现List<自定义对象>转为List<Map>

自定义类 /*** date 2023/12/19 11:20*/ public class Person {private String name;private String sex;public Person() {}public Person(String name, String sex) {this.name name;this.sex sex;}public String getName() {return name;}public String getSex() {return…...

Python---静态Web服务器-返回固定页面数据

1. 开发自己的静态Web服务器 实现步骤: 编写一个TCP服务端程序获取浏览器发送的http请求报文数据读取固定页面数据&#xff0c;把页面数据组装成HTTP响应报文数据发送给浏览器。HTTP响应报文数据发送完成以后&#xff0c;关闭服务于客户端的套接字。 2. 静态Web服务器-返回固…...

react v-18父组件调用子组件的方法和数据

版本 "react": "^18.1.0", "react-dom": "^18.1.0", 父组件 import React, { useState, useRef, memo, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { Card } from &q…...

Linux——缓冲区

我在上篇博客留下了一个问题&#xff0c;那个问题就是关于缓冲区的问题&#xff0c;我们发现 文件有缓冲区&#xff0c;语言有用户级缓冲区&#xff0c;那么缓冲区到底是什么&#xff1f;&#xff0c;或者该怎 么认识缓冲区&#xff1f;这篇文章或许会让你有所认识&#xff0c;…...

Mac 生成Android签名证书 .keystore文件

工具下载地址 https://www.oracle.com/java/technologies/downloads/#jdk21-mac1. 找到安装jdk的路径&#xff0c;并进入bin目录下 1.1 查找JDK命令 /usr/libexec/java_home -v结果为: java_home: option requires an argument -- v /Library/Java/JavaVirtualMachines/jdk…...

电商数仓项目----笔记六(数仓ODS层)

ODS层的设计要点如下&#xff1a; &#xff08;1&#xff09;ODS层的表结构设计依托于从业务系统同步过来的数据结构。 &#xff08;2&#xff09;ODS层要保存全部历史数据&#xff0c;故其压缩格式应选择压缩比较高的&#xff0c;此处选择gzip。 &#xff08;3&#xff09;…...

rtsp视频在使用unity三维融合播放后的修正

1 rtsp 接入 我们使用unity UE 等三维渲染引擎中使用c编写插件来接入rtsp 视频。同时做融合的时候&#xff0c;和背景的三维颜色要一致&#xff0c;这就要使用视频融合修正技术。包括亮度&#xff0c;对比度&#xff0c;饱和度的修正。在单纯颜色上的修正可以简单使用rgb->…...

【已解决】解决Springboot项目访问本地图片等静态资源无法访问的问题

今天在开发一个招聘系统的时候&#xff0c;有投递简历功能&#xff0c;有投递就会有随之而来的查看简历对吧&#xff0c;我投递过的简历&#xff0c;另存为一个文件夹&#xff0c;就是说本地磁盘(或者服务器)有一个专门存放投递过的简历的文件夹&#xff0c;用于存放PDF&#x…...

运维笔记之centos部署Go-FastDfs

安装Go-FastDfs 当前最新版本为1.4.5&#xff0c;但发布的最新版本为1.4.4 # 下载文件 wget --no-check-certificate https://github.com/sjqzhang/go-fastdfs/releases/download/v1.4.4/fileserver -O fileserver # 赋权限 chmod x fileserver # 运行 ./fileserver server服…...

C#基础——线程(线程池、线程锁、线程抢占、多线程)

线程 进程&#xff08;Process&#xff09;是由操作系统分配资源并执行的一个独立的程序实&#xff0c;属于Windows的概念&#xff0c;进程结束就表示程序关闭了。 线程&#xff08;Thread&#xff09;是程序中执行的最小单位。一个线程代表了一个独立的执行流&#xff0c;可…...

C# WPF上位机开发(QT vs WPF)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 最近经常收到朋友们的私信&#xff0c;他们对C# WPF开发很感兴趣&#xff0c;但是呢&#xff0c;正当准备学习的时候&#xff0c;又有人告诉他们应…...

2-高可用-负载均衡、反向代理

负载均衡、反向代理 upstream server即上游服务器&#xff0c;指Nginx负载均衡到的处理业务的服务器&#xff0c;也可以称之为real server,即真实处理业务的服务器。 对于负载均衡我们要关心的几个方面如下&#xff1a; 上游服务器配置&#xff1a;使用upstream server配置上…...

STM32 使用ARM仿真器设置

STM32单片机程序下载到单片机芯片中有两种方式&#xff0c;①编译生成HEX&#xff0c;使用程序烧录软件刷到单片机芯片里。②使用ARM仿真器下载程序。使用ARM仿真器的优势是&#xff0c;在工程编译没问题直接在Keil软件里就可以将程序下载到单片机里&#xff0c;并且程序可以在…...

【Java】spring

一、spring spring是一个很大的生态圈&#xff0c;里面有很多技术。 其中最基础的是spring framework&#xff0c;主要的技术 是springboot以及springcloud。 1、spring framework spring framework是spring生态圈中最基础的项目&#xff0c;是其他项目的基础。 1.1、核心…...

C语言中关于操作符的理解

本篇文章只会列出大家在生活中经常使用的操作符 算术操作符 在算数操作符中常用的有&#xff0c;&#xff0c;-&#xff0c;*&#xff0c;/&#xff0c;% &#xff0c;我们重点讲一讲 / (除) 和 % (模) " / "运算 #include <stdio.h>int main() {int a5/2;fl…...

Flutter本地化(国际化)之App名称

文章目录 Android国际化IOS国际化 Flutter开发的App&#xff0c;如果名称想要跟随着系统的语言自动改变&#xff0c;则必须同时配置Android和IOS原生。 Android国际化 打开android\app\src\main\res\values 创建strings.xml 在values上右键&#xff0c;选择New>Values Res…...

掌握Agentic RAG:动态智能代理,提升大模型学习与实战效率,CSDN小白程序员必收藏!

掌握Agentic RAG&#xff1a;动态智能代理&#xff0c;提升大模型学习与实战效率&#xff0c;CSDN小白程序员必收藏&#xff01; Agentic RAG技术通过引入自主AI代理&#xff0c;解决了传统RAG系统依赖静态数据的局限性&#xff0c;实现实时检索最新数据&#xff0c;灵活调整策…...

字节Agent开发岗面试血泪史:ReAct框架、IterResearch架构、训练流程全解析,小白必看!收藏!

字节Agent开发岗面试血泪史&#xff1a;ReAct框架、IterResearch架构、训练流程全解析&#xff0c;小白必看&#xff01;收藏&#xff01; 文章通过字节Agent开发岗校招面试实例&#xff0c;揭示候选人因缺乏底层逻辑和工程实现细节而失败。详细解析ReAct框架、IterResearch架构…...

【PAT甲级真题】- Shopping in Mars (25)

题目来源 Shopping in Mars (25) 题目描述点击链接自行查看 注意点&#xff1a; 输出时按照区间左端点从小到大输出 思路简介 简单的滑动窗口 我做了一个小处理 因为题目实际上要求找的是大于等于目标值的区间 所以移动左指针的条件写成 l>r&&sum>m 这样我认…...

Seurat实战:如何用FindMarkers函数精准鉴定单细胞亚群(附避坑指南)

Seurat实战&#xff1a;用FindMarkers函数精准鉴定单细胞亚群的7个关键策略 单细胞RNA测序技术正在彻底改变我们对复杂组织的理解能力。在肌肉组织、肿瘤微环境或大脑皮层等高度异质性的样本中&#xff0c;准确识别和注释细胞亚群是每个研究者面临的重大挑战。Seurat工具包中的…...

Harness Engineering: 为 AI 搭建可持续迭代环境的实践

在公司内部一个 AIGC页面 Verify 项目(下面代号 HelixVerify )中,我们经历了 114 次版本迭代, 将相对benchmark 的风险样本召回率从 最初的 8% 提升至 98.86%,无风险样本通过率从 36.11% 提升至 54.93%。 **整个 114 次迭代中,基本没有代码是我手写的。**从第一个版本开始,所有…...

Qwen2.5-7B+Tools应用场景解析:智能客服、信息查询等实战案例

Qwen2.5-7BTools应用场景解析&#xff1a;智能客服、信息查询等实战案例 1. 引言&#xff1a;当大语言模型遇上工具 想象一下&#xff0c;你正在运营一家电商平台&#xff0c;每天要处理上千条客户咨询。人工客服团队疲于应对&#xff0c;而客户等待时间越来越长。这时&#…...

ASP.NET Core ApiEndpoints:告别臃肿控制器,拥抱REPR模式新时代

ASP.NET Core ApiEndpoints&#xff1a;告别臃肿控制器&#xff0c;拥抱REPR模式新时代 【免费下载链接】ApiEndpoints A project for supporting API Endpoints in ASP.NET Core web applications. 项目地址: https://gitcode.com/gh_mirrors/ap/ApiEndpoints 在ASP.NE…...

解决unsloth中ptxas版本不兼容导致的RuntimeError: 从CUDA 12.6降级到12.4的实战指南

1. 问题背景与错误分析 最近在Windows平台上使用unsloth框架时&#xff0c;遇到了一个让人头疼的RuntimeError。错误信息显示ptxas编译器报错&#xff0c;错误代码是4294967295。具体表现为ptxas无法处理.version 8.6的指令集&#xff0c;而当前只支持到8.5版本。这个错误通常发…...

A股数据仓库搭建指南:5分钟拥有专属本地金融数据库

A股数据仓库搭建指南&#xff1a;5分钟拥有专属本地金融数据库 【免费下载链接】AShareData 自动化Tushare数据获取和MySQL储存 项目地址: https://gitcode.com/gh_mirrors/as/AShareData 还在为A股数据分析而烦恼吗&#xff1f;每次研究都要重新下载数据&#xff0c;既…...

STM32F407的GPIO模式选对了吗?从LED驱动到按键读取,CubeMX配置全解析

STM32F407的GPIO模式选对了吗&#xff1f;从LED驱动到按键读取的实战指南 当你第一次拿到STM32开发板时&#xff0c;闪烁LED可能是你的第一个实验。但很快你会发现&#xff0c;GPIO的功能远不止于此——从简单的LED控制到复杂的按键检测&#xff0c;不同的应用场景需要完全不同…...