当前位置: 首页 > 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…...

基于算法竞赛的c++编程(28)结构体的进阶应用

结构体的嵌套与复杂数据组织 在C中&#xff0c;结构体可以嵌套使用&#xff0c;形成更复杂的数据结构。例如&#xff0c;可以通过嵌套结构体描述多层级数据关系&#xff1a; struct Address {string city;string street;int zipCode; };struct Employee {string name;int id;…...

Qt/C++开发监控GB28181系统/取流协议/同时支持udp/tcp被动/tcp主动

一、前言说明 在2011版本的gb28181协议中&#xff0c;拉取视频流只要求udp方式&#xff0c;从2016开始要求新增支持tcp被动和tcp主动两种方式&#xff0c;udp理论上会丢包的&#xff0c;所以实际使用过程可能会出现画面花屏的情况&#xff0c;而tcp肯定不丢包&#xff0c;起码…...

如何在看板中有效管理突发紧急任务

在看板中有效管理突发紧急任务需要&#xff1a;设立专门的紧急任务通道、重新调整任务优先级、保持适度的WIP&#xff08;Work-in-Progress&#xff09;弹性、优化任务处理流程、提高团队应对突发情况的敏捷性。其中&#xff0c;设立专门的紧急任务通道尤为重要&#xff0c;这能…...

VTK如何让部分单位不可见

最近遇到一个需求&#xff0c;需要让一个vtkDataSet中的部分单元不可见&#xff0c;查阅了一些资料大概有以下几种方式 1.通过颜色映射表来进行&#xff0c;是最正规的做法 vtkNew<vtkLookupTable> lut; //值为0不显示&#xff0c;主要是最后一个参数&#xff0c;透明度…...

IT供电系统绝缘监测及故障定位解决方案

随着新能源的快速发展&#xff0c;光伏电站、储能系统及充电设备已广泛应用于现代能源网络。在光伏领域&#xff0c;IT供电系统凭借其持续供电性好、安全性高等优势成为光伏首选&#xff0c;但在长期运行中&#xff0c;例如老化、潮湿、隐裂、机械损伤等问题会影响光伏板绝缘层…...

自然语言处理——循环神经网络

自然语言处理——循环神经网络 循环神经网络应用到基于机器学习的自然语言处理任务序列到类别同步的序列到序列模式异步的序列到序列模式 参数学习和长程依赖问题基于门控的循环神经网络门控循环单元&#xff08;GRU&#xff09;长短期记忆神经网络&#xff08;LSTM&#xff09…...

【Linux】自动化构建-Make/Makefile

前言 上文我们讲到了Linux中的编译器gcc/g 【Linux】编译器gcc/g及其库的详细介绍-CSDN博客 本来我们将一个对于编译来说很重要的工具&#xff1a;make/makfile 1.背景 在一个工程中源文件不计其数&#xff0c;其按类型、功能、模块分别放在若干个目录中&#xff0c;mak…...

上位机开发过程中的设计模式体会(1):工厂方法模式、单例模式和生成器模式

简介 在我的 QT/C 开发工作中&#xff0c;合理运用设计模式极大地提高了代码的可维护性和可扩展性。本文将分享我在实际项目中应用的三种创造型模式&#xff1a;工厂方法模式、单例模式和生成器模式。 1. 工厂模式 (Factory Pattern) 应用场景 在我的 QT 项目中曾经有一个需…...

ubuntu22.04有线网络无法连接,图标也没了

今天突然无法有线网络无法连接任何设备&#xff0c;并且图标都没了 错误案例 往上一顿搜索&#xff0c;试了很多博客都不行&#xff0c;比如 Ubuntu22.04右上角网络图标消失 最后解决的办法 下载网卡驱动&#xff0c;重新安装 操作步骤 查看自己网卡的型号 lspci | gre…...

C# winform教程(二)----checkbox

一、作用 提供一个用户选择或者不选的状态&#xff0c;这是一个可以多选的控件。 二、属性 其实功能大差不差&#xff0c;除了特殊的几个外&#xff0c;与button基本相同&#xff0c;所有说几个独有的 checkbox属性 名称内容含义appearance控件外观可以变成按钮形状checkali…...