1.4-1.5 HBase部署及基本使用

一、部署

1、准备

##先用Apache hadoop
##之前的cdh 服务器先全部停掉##解压HBASE
[root@hadoop-senior hbase]# tar zxf hbase-0.98.6-hadoop2-bin.tar.gz -C /opt/modules/##启动Apache hadoop (hdfs)
[root@hadoop-senior hadoop-2.5.0]# pwd
/opt/modules/hadoop-2.5.0[root@hadoop-senior hadoop-2.5.0]# sbin/hadoop-daemon.sh start namenode
[root@hadoop-senior hadoop-2.5.0]# sbin/hadoop-daemon.sh start datanode[root@hadoop-senior hadoop-2.5.0]# jps
23159 Jps
23081 DataNode
22996 NameNode


2、配置、启动

hbase-env.sh

export JAVA_HOME=/opt/modules/jdk1.7.0_80


regionservers

改为主机名


hbase-site.xml

<property><name>hbase.rootdir</name><value>hdfs://hadoop-senior.ibeifeng.com:8020/hbase</value></property><property><name>hbase.cluster.distributed</name><value>true</value></property><property><name>hbase.zookeeper.quorum</name><value>hadoop-senior.ibeifeng.com</value></property>


启动

##替换jar包,事先准备好的,(cdh应该就不需要替换了)
[root@hadoop-senior hbase-0.98.6-hadoop2]# mv lib/hadoop-* /tmp/
[root@hadoop-senior hadoop-2.5.0-jars]# cp -r ./* /opt/modules/hbase-0.98.6-hadoop2/lib/

[root@hadoop-senior hbase-0.98.6-hadoop2]# mv lib/zookeeper-3.4.6.jar /tmp/

##启动
[root@hadoop-senior hbase-0.98.6-hadoop2]# bin/start-hbase.sh [root@hadoop-senior hbase-0.98.6-hadoop2]# jps
24548 Jps
24155 HMaster
23081 DataNode
24084 HQuorumPeer
24266 HRegionServer
22996 NameNode端口:60010       //可以web访问:ip:port


3、hdfs上HBASE各个目录

[root@hadoop-senior hadoop-2.5.0]# bin/hdfs dfs -ls /
Found 3 items
drwxr-xr-x   - root supergroup          0 2019-05-20 14:45 /hbase
drwx-w----   - root supergroup          0 2019-04-18 17:33 /tmp
drwxr-xr-x   - root supergroup          0 2019-04-18 17:21 /user[root@hadoop-senior hadoop-2.5.0]# bin/hdfs dfs -ls /hbase
Found 6 items
drwxr-xr-x   - root supergroup          0 2019-05-20 14:45 /hbase/.tmp
drwxr-xr-x   - root supergroup          0 2019-05-20 14:45 /hbase/WALs
drwxr-xr-x   - root supergroup          0 2019-05-20 14:31 /hbase/data
-rw-r--r--   3 root supergroup         42 2019-05-20 14:31 /hbase/hbase.id
-rw-r--r--   3 root supergroup          7 2019-05-20 14:31 /hbase/hbase.version
drwxr-xr-x   - root supergroup          0 2019-05-20 14:46 /hbase/oldWALs##
/hbase/.tmp当对表做创建或者删除操作的时候,会将表move 到该 tmp 目录下,然后再去做处理操作。/hbase/WALsHBase 是支持 WAL(Write Ahead Log) 的,HBase 会在第一次启动之初会给每一台 RegionServer 在WALs下创建一个目录,若客户端如果开启WAL 模式,
会先将数据写入一份到WALs下,当 RegionServer crash 或者目录达到一定大小,会开启 replay 模式,类似 MySQL 的 binlog。/hbase/data存储hbase数据,下面含有两个命名空间default和hbase,/hbase/data/default这个默认的namespace即没有指定namespace 的表都将会flush 到该目录下面。/hbase/data/hbase这个namespace 下面存储了 HBase 的 namespace、meta 和acl 三个表,这里的 meta 表跟0.94版本的.META.是一样的,自0.96之后就已经将 ROOT 表去掉了,直接从Zookeeper 中找到meta 表的位置,然后通过 meta 表定位到 region。 namespace 中存储了 HBase 中的所有 namespace 信息,包括预置的hbase 和 default。acl 则是表的用户权限控制。
如果自定义一些 namespace 的话,就会再/hbase/data 目录下新建一个 namespace 文件夹,该 namespace 下的表都将 flush 到该目录下。/hbase/hbase.id它是一个文件,存储集群唯一的 cluster id 号,是一个 uuid。/hbase/hbase.version同样也是一个文件,存储集群的版本号,貌似是加密的,看不到,只能通过web-ui 才能正确显示出来。/hbase/oldWALs当WALs文件夹中的 HLog 没用之后会 move 到.oldWALs 中,HMaster 会定期去清理。


二、HBase Shell基本使用

1、登入命令行

[root@hadoop-senior hbase-0.98.6-hadoop2]# bin/hbase
Usage: hbase [<options>] <command> [<args>]
Options:--config DIR    Configuration direction to use. Default: ./conf--hosts HOSTS   Override the list in 'regionservers' fileCommands:
Some commands take arguments. Pass no args or -h for usage.shell           Run the HBase shellhbck            Run the hbase 'fsck' toolhlog            Write-ahead-log analyzerhfile           Store file analyzerzkcli           Run the ZooKeeper shellupgrade         Upgrade hbasemaster          Run an HBase HMaster noderegionserver    Run an HBase HRegionServer nodezookeeper       Run a Zookeeper serverrest            Run an HBase REST serverthrift          Run the HBase Thrift serverthrift2         Run the HBase Thrift2 serverclean           Run the HBase clean up scriptclasspath       Dump hbase CLASSPATHmapredcp        Dump CLASSPATH entries required by mapreducepe              Run PerformanceEvaluationltt             Run LoadTestToolversion         Print the versionCLASSNAME       Run the class named CLASSNAME[root@hadoop-senior hbase-0.98.6-hadoop2]# bin/hbase shell    //进入HBASE命令行
hbase(main):001:0> help                    //查看帮助


2、操作命令

hbase(main):007:0> help 'create'        //查看建表帮助
hbase(main):004:0> create 'user', 'info'        //创建一个表,user:表名;  info:列簇
hbase(main):005:0> list            //列出表
hbase(main):006:0> describe 'user'        //查看表结构##插入数据
hbase(main):008:0> put 'user', '10001', 'info:name', 'zhangsan'    //user:表名;  10001:rowkey;   info:name:列簇的其中一列;   zhangsan:值
0 row(s) in 0.0770 seconds hbase(main):010:0> put 'user', '10001', 'info:age', '25'
0 row(s) in 0.0060 secondshbase(main):011:0> put 'user', '10001', 'info:sex', 'male'
0 row(s) in 0.0040 secondshbase(main):012:0>  put 'user', '10001', 'info:address', 'shanghai'##查询
HBase的数据查询有三种方式:
*依据rowkey查询,最快的get*范围查询scan range*全表扫描scan##查询10001这个rowkey下的所有列数据
hbase(main):014:0> get 'user', '10001'
COLUMN                                       CELL                                                                                                                           info:address                                timestamp=1558342595476, value=shanghai                                                                                        info:age                                    timestamp=1558342530687, value=25                                                                                              info:name                                   timestamp=1558342470065, value=zhangsan                                                                                        info:sex                                    timestamp=1558342551186, value=male                                                                                            
4 row(s) in 0.0160 seconds##单独列查询hbase(main):015:0> get 'user', '10001', 'info:name'
COLUMN                                       CELL                                                                                                                           info:name                                   timestamp=1558342470065, value=zhangsan                                                                                        
1 row(s) in 0.0080 seconds


3、操作命令

##插入数据,rowkey:10002
hbase(main):016:0> put 'user', '10002', 'info:name', 'wangwu'
0 row(s) in 0.0040 secondshbase(main):017:0> put 'user', '10002', 'info:age', '30'
0 row(s) in 0.0040 secondshbase(main):018:0> put 'user', '10002', 'info:tel', '231294737'
0 row(s) in 0.0030 secondshbase(main):019:0> put 'user', '10002', 'info:qq', '231294737'
0 row(s) in 0.0030 seconds##全表扫描查询
hbase(main):020:0> scan 'user'
ROW                                          COLUMN+CELL                                                                                                                    10001                                       column=info:address, timestamp=1558342595476, value=shanghai                                                                   10001                                       column=info:age, timestamp=1558342530687, value=25                                                                             10001                                       column=info:name, timestamp=1558342470065, value=zhangsan                                                                      10001                                       column=info:sex, timestamp=1558342551186, value=male                                                                           10002                                       column=info:age, timestamp=1558343570256, value=30                                                                             10002                                       column=info:name, timestamp=1558343559457, value=wangwu                                                                        10002                                       column=info:qq, timestamp=1558343612746, value=231294737                                                                       10002                                       column=info:tel, timestamp=1558343607851, value=231294737                                                                      
2 row(s) in 0.0220 seconds##插入数据,rowkey:10003
hbase(main):021:0> put 'user', '10003', 'info:name', 'zhaoliu'
0 row(s) in 0.0050 seconds##范围查询,只查询name和age两个列
hbase(main):022:0> scan 'user', {COLUMNS => ['info:name', 'info:age']}
ROW                                          COLUMN+CELL                                                                                                                    10001                                       column=info:age, timestamp=1558342530687, value=25                                                                             10001                                       column=info:name, timestamp=1558342470065, value=zhangsan                                                                      10002                                       column=info:age, timestamp=1558343570256, value=30                                                                             10002                                       column=info:name, timestamp=1558343559457, value=wangwu                                                                        10003                                       column=info:name, timestamp=1558345826709, value=zhaoliu ##只从某个rowkey开始往后查
hbase(main):023:0> scan 'user', {STARTROW => '10002'}
ROW                                          COLUMN+CELL                                                                                                                    10002                                       column=info:age, timestamp=1558343570256, value=30                                                                             10002                                       column=info:name, timestamp=1558343559457, value=wangwu                                                                        10002                                       column=info:qq, timestamp=1558343612746, value=231294737                                                                       10002                                       column=info:tel, timestamp=1558343607851, value=231294737                                                                      10003                                       column=info:name, timestamp=1558345826709, value=zhaoliu                                                                       
2 row(s) in 0.0120 seconds
#从某个rowkey到某个rowkey(包前不包后)

hbase(main):002:0> scan 'user', {STARTROW => '10001',ENDROW => '10003'}
ROW                                   COLUMN+CELL                                                                                                                   
  10001                                column=info:address, timestamp=1558342595476, value=shanghai                                                                  
  10001                                column=info:age, timestamp=1558342530687, value=25                                                                            
  10001                                column=info:name, timestamp=1558342470065, value=zhangsan                                                                     
  10001                                column=info:sex, timestamp=1558342551186, value=male                                                                          
  10002                                column=info:age, timestamp=1558343570256, value=30                                                                            
  10002                                column=info:name, timestamp=1558343559457, value=wangwu                                                                       
  10002                                column=info:qq, timestamp=1558343612746, value=231294737                                                                      
  10002                                column=info:tel, timestamp=1558343607851, value=231294737

##删除数据
hbase(main):004:0> delete 'user', '10001', 'info:name'  //删除user表下,rowkey为10001,列为name的值;
hbase(main):008:0> deleteall 'user', '10001'                  //删除整个rowkey下的值

转载于:https://www.cnblogs.com/weiyiming007/p/10898494.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/411367.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux双网口绑定,双网口绑定bond

bond内核模块和称为通道绑定接口的特殊网络&#xff0c;接口将多个网络接口绑定到一个通道。根据选择的绑定模式&#xff0c;通道绑定使两个或者更多个网络接口作为一个网络接口&#xff0c;从而增加带宽或者提供冗余性模式0(平衡轮循) - 轮循策略&#xff0c;所有 接口都采用轮…

Web3d明日之星基于Javascript和OpenGL的技术

和Linux的卫道人袁老相似&#xff0c;我也是VRML/X3D这种Web3D技术的守卫者&#xff0c;虽然我很渺小。 Web已经逐步成为应用程序界面的基础。Firefox开发商Mozilla和制定OpenGL 技术规范的Khronos组织 已经看到了OpenGL技术的广泛应用&#xff0c;他们也想借此为Web创建新的3D…

[html] 如何实现多行文字梯形排版?

[html] 如何实现多行文字梯形排版&#xff1f; 可以利用文字会环绕浮动元素的特性来做&#xff1a;HTML:#box {width: 400px;height: 600px;background-color: red; } #box .float-div{float: left; // 浮动起来clear: both; // 这个很重要&#xff0c;不然会排版出错backgrou…

c语言 字符串map,C语言实现BitMap

BitMap的原理不用多说了。主要说下位操作。我们假设每个基础存储单元为char&#xff0c;则BYTESIZE 8&#xff0c;如果为int则16 or 32。当设置i时&#xff0c;首先ptri/BYTESIZE&#xff0c;到达要操作的那个char。然后对*ptr | 0x01<检查的时候&#xff0c;也是首先ptri/…

MySQL5.7.9安装与配置优化

一、 环境准备 1. 下载软件包 wget http://test.hexin.cn/software/mysql-5.7.9.tar.gz -P /usr/local/src/ wget http://test.hexin.cn/software/cmake-3.4.0.tar.gz -P /usr/local/src/ wget http://test.hexin.cn/software/boost_1_59_0.tar.gz -P /usr/local/src/ 2. 安装基…

[html] h5页面如何传递参数给小程序?

[html] h5页面如何传递参数给小程序&#xff1f; 1、H5页面 <script src"${base}/resources/common/js/jweixin.miniProgram.js"></script>wx.miniProgram.postMessage({ data: { shareUrl:href } });注意&#xff1a;传参必须使用data2、小程序页面接收…

k8s的认证和service account简述

k8s的认证&#xff1a; 与API server通信的客户端大致有两类&#xff1a; 1.集群客户端工具&#xff08;kubectl、kubeadm、kubelet等&#xff09; 2.集群内pod. 任何客户端访问k8s时的过程&#xff1a; 1.认证&#xff1a;任何客户端访问k8s&#xff0c;首先需要通过k8s的认…

单片机c语言应用100例第3版课后答案,单片机C语言应用100例(第3版)(含光盘1张)...

基 础 篇第1章 单片机概述及实验器材介绍21.1 单片机概述21.1.1 单片机的定义、分类与内部组成21.1.2 单片机应用系统的结构及其工作过程51.1.3 单片机的应用61.2 单片机基础知识71.2.1 数制与数制间的转换71.2.2 单片机中数的表示方法及常用数制的对应关系101.2.3 逻辑数…

biztalk在用户代码中构造多部分消息

大家知道&#xff0c;biztalk中可以在orchestration调用外部用户代码进行功能扩展&#xff0c;调用外部方法可以把消息作为参数传给外部方法&#xff0c;当然也可能需要外部方法返回一个消息到orchestration。<?xml:namespace prefix o />对于schema类型的消息&#xf…

[html] HTML5如何播放ts视频流?

[html] HTML5如何播放ts视频流&#xff1f; 引入mux.js转化&#xff0c;然后video展示个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c; 但坚持一定很酷。欢迎大家一起讨论 主目录 与歌谣一起通关前端面试题

c语言标准库 swap,swap

swap描述 (Description)C 函数std::forward_list::swap()将第一个forward_list的内容与另一个交换。 如有必要&#xff0c;此函数会更改forward_list的大小。声明 (Declaration)以下是std :: forward_list :: swap()函数形式std :: forward_list头的声明。C11template void swa…

[缓存]迅雷下载原理

来自&#xff1a;http://hi.baidu.com/gcjia/blog/item/2b77bc3df8544803bba1675f.html1.迅雷是什么&#xff1f; 迅雷是基于P2SP的一款下载软件&#xff0c;能够大大增强下载速度&#xff0c;可谓迅雷不及掩耳盗铃之势如破竹。 P2SP的道理不复杂&#xff0c;就是指&#xff1a…

[html] 实现两列等宽布局的方式有哪些?

[html] 实现两列等宽布局的方式有哪些&#xff1f; 1.flex实现&#xff1a; .parent { display: flex; } .child { flex: 1; width: 50%; } 2.float实现&#xff08;但是要注意清除浮动&#xff09;&#xff1a; .child { float: left; width: 50%; }个人简介 我是歌谣&#…

背景透明度 下拉菜单

下拉菜单 ——————> <style> /* 下拉按钮样式 */ .dropbtn {background-color: #4CAF50;color: white;padding: 16px;font-size: 16px;border: none;cursor: pointer; }/* 容器 <div> - 需要定位下拉内容 */ .dropdown {position: relative;display: inlin…

datavideo切换台说明书_巴掌大三轴稳定器,稳过微云台,试试飞宇VLOGPocket2

几乎全民VLOG的时代&#xff0c;我们随处可见有人举着手机、相机记录生活&#xff0c;甚至还有品牌推出了自带微云台的手机。不过&#xff0c;即便在手机上硬“塞”进一个微云台&#xff0c;效果也始终无法媲美真正的云台&#xff0c;对视频拍摄的提升相对有限&#xff0c;大部…

[html] 写一个滚动吸顶的布局

[html] 写一个滚动吸顶的布局 position: sticky; top:20px&#xff1b;个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c; 但坚持一定很酷。欢迎大家一起讨论 主目录 与歌谣一起通关前端面试题

C语言程序设计上机前三题,C语言程序设计(含上机实验与习题解答)

本书根据作者多年来教授不同基础学员的经验&#xff0c;针对初学者的特点&#xff0c;由浅入深&#xff0c;从一般程序设计语言的共性到C语言自身的特性&#xff0c;从C语言的语法规则到其内部实现&#xff0c;对C语言进行了系统的介绍。全书分上、下两篇。上篇介绍C语言程序设…

最新PC游戏下载链接

http://www.newyx.net/list/5_1.htm转载于:https://www.cnblogs.com/vilyLei/archive/2009/07/28/1533057.html

VSCode中Markdown目录显示异常

更新最新的VSCode之后编辑Markdown文件发现TOC标签的目录格式异常&#xff0c;发现是因为行尾字符导致&#xff0c;必须设置行尾字符进行解决。 转载于:https://www.cnblogs.com/phonecom/p/10904785.html

string转换成enum

String转换为Enum类型public enum TypeItemName{News,Bulletin,Dispatch} TypeItemName item (TypeItemName )Enum.Parse(typeof(TypeItemName ), inText, false);转载于:https://www.cnblogs.com/sceo/archive/2009/08/04/1538369.html