hbase集群安装
安装参考 :https://www.cnblogs.com/qingyunzong/p/8668880.html
hbase一般用法, https://www.cnblogs.com/cxzdy/p/5583239.html
(一)下载:
wget http://mirrors.hust.edu.cn/apache/hbase/2.2.2/hbase-2.2.2-bin.tar.gz
解压 tar -zxvf hbase-2.2.2-bin.tar.gz -C /home/hadoop
(二)配置
vi /home/hadoop/hbase-222/conf/hbase-env.sh
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64
export HBASE_MANAGES_ZK=false
vi /home/hadoop/hbase-222/conf/hbase-site.xml
追加以下配置项目:
<property>
<!-- 指定 hbase 在 HDFS 上存储的路径 -->
<name>hbase.rootdir</name>
<value>hdfs://master:9000/hbase222</value> 【habse 默认会找8020的hdfs的端口,所以这个地方要指定hdfs的端口9000保持一致 hdfs://master:9000/hbase222 】
</property>
<property>
<!-- 指定 hbase 是分布式的 -->
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<!-- 指定 zk 的地址,多个用“,”分割 -->
<name>hbase.zookeeper.quorum</name>
<value>master:2181,slave1:2181,slave2:2181</value>
</property>
#####如果hbase启动出现以下错误,
java.lang.IllegalStateException: The procedure WAL relies on the ability to hsync for proper operation during component failures
那么再在【conf/hbase-site.xml】增加 以下配置项
<property>
<name>hbase.unsafe.stream.capability.enforce</name>
<value>false</value>
</property>
########################################################################################################
vi /home/hadoop/hbase-222/conf/regionservers
内容
master
slave1
slave2
创建 vi /home/hadoop/hbase-222/conf/backup-masters
内容
slave1
拷贝hadoop的两个配置文件 hdfs-site.xml、core-site.xml 到hbase /conf下
cp /home/hadoop/hadoop-313/etc/hadoop/hdfs-site.xml /home/hadoop/hadoop-313/etc/hadoop/core-site.xml /home/hadoop/hbase-222/conf
删除文档目录
rm -r docs
scp 分发到 其他机器节点
scp -r hbase-222 slave1:$PWD
scp -r hbase-222 slave2:$PWD
每台机器 环境变量配置:
vi /etc/profile
export HBASE_HOME=/home/hadoop/hbase-222
export PATH=$PATH:$HBASE_HOME/bin
source /etc/profile
(三)启动
zookeeper ==============================>> zkServer.sh start
启动HDFS集群及YARN集群==================>> start-dfs.sh
启动hbase===============================>> /home/hadoop/hbase-222/bin/start-hbase.sh
查看进程
39596 HMaster
39766 HRegionServer
38599 NameNode
38807 SecondaryNameNode
38376 QuorumPeerMain
39837 Jps
(四)测试
hbase 命令参考: https://blog.csdn.net/vbirdbest/article/details/88236575
测试:
/bin/hbase shell
创建表
create 't1',{NAME => 'f1', VERSIONS => 2},{NAME => 'f2', VERSIONS => 2}
备注: 创建的表hdfs位置
【hadoop fs -ls /hbase222/data/default
/hbase222/data/default/t1
】
插入数据
put 't1','rowkey001','f1:col1','value01'
查询数据
get 't1','rowkey001', 'f1:col1'
get 't1','rowkey001', {COLUMN=>'f1:col1'}
删除数据
delete 't1','rowkey001','f1:col1'
扫描 数据
scan 't1',{LIMIT => 5}
计算 行数
count 't1', {INTERVAL => 100, CACHE => 500}
删除表
disable 't1'
drop 't1'
habse web 管理页面
http://192.168.91.112:16000/master-status
web页面启动乱码 待查中
错误代码摘要:
org.apache.hadoop.hbase.ipc.FatalConnectionException HEADER=HBas but received HEADER=GET
======================================================================================
hive 整合 hbase表
创建hive整合hbase的表总结
-- hive与hbase联动的形式[可以通过这个方式在hbase中批量写入数据]
CREATE TABLE rsc.hbase_news_company_content(
key string comment "流水号",
news_id string comment "新闻id",
news_content string comment "文章内容")
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:news_id,cf1:news_content")
TBLPROPERTIES("hbase.table.name" = "news_company_content");
--在hive插入数据
insert into rsc.hbase_news_company_content select '101','wz_101','改革开放' ;
insert into rsc.hbase_news_company_content select '102','wz_102','市场经济' ;
--hbase查询数据
scan 'news_company_content',{LIMIT => 5}
-- 外表形式
--在hbase建表
create 'jsActionPage','cf1'
--插入数据
put 'jsActionPage','rowkey001','cf1:bdcCookieId','zhangsancookie219','cf1:pcScreenRatio','92.3'
put 'jsActionPage','rowkey001','cf1:pcScreenRatio','92.3'
put 'jsActionPage','rowkey001','cf1:pageCloseTime','1600069928174'
put 'jsActionPage','rowkey001','cf1:pageLoadCompleteTime','1600069928174'
put 'jsActionPage','rowkey001','cf1:pageOpenTime','1600069928174'
put 'jsActionPage','rowkey001','cf1:currentURL','http://www.baidu.com'
-- 查询数据
scan 'jsActionPage',{LIMIT => 5}
get 'jsActionPage','rowkey001'
--模糊查询
scan 'jsActionPage',{FILTER=>"PrefixFilter('rowkey0')"}
--在hive建立外部表
CREATE EXTERNAL TABLE rsc.hbase_jsActionPage(
key string,
bdcCookieId string ,
pcScreenRatio string ,
pageCloseTime string ,
pageLoadCompleteTime string,
pageOpenTime string,
currentURL string)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:bdcCookieId,cf1:pcScreenRatio,
cf1:pageCloseTime,
cf1:pageLoadCompleteTime,
cf1:pageOpenTime,
cf1:currentURL")
TBLPROPERTIES("hbase.table.name" = "jsActionPage");
-- hive 查询数据
select * from rsc.hbase_jsActionPage;
浙公网安备 33010602011771号