0:
jdbc:hive2://hadoop210.cevent.com:10000> CREATE TABLE
hive_hbase_emp_table(
0:
jdbc:hive2://hadoop210.cevent.com:10000> empno int,
0: jdbc:hive2://hadoop210.cevent.com:10000>
ename string,
0:
jdbc:hive2://hadoop210.cevent.com:10000> job string,
0:
jdbc:hive2://hadoop210.cevent.com:10000> mgr int,
0: jdbc:hive2://hadoop210.cevent.com:10000>
hiredate string,
0:
jdbc:hive2://hadoop210.cevent.com:10000> sal double,
0:
jdbc:hive2://hadoop210.cevent.com:10000> comm double,
0:
jdbc:hive2://hadoop210.cevent.com:10000> deptno int)
0: jdbc:hive2://hadoop210.cevent.com:10000>
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
0: jdbc:hive2://hadoop210.cevent.com:10000>
WITH SERDEPROPERTIES ("hbase.columns.mapping" =
":key,info:ename,info:job,info:mgr,info:hiredate,info:sal,info:comm,info:deptno")
0:
jdbc:hive2://hadoop210.cevent.com:10000> TBLPROPERTIES
("hbase.table.name" = "hbase_emp_table");
Error: java.lang.UnsupportedClassVersionError:
org/apache/hadoop/hive/hbase/HBaseStorageHandler : Unsupported major.minor
version 52.0 (state=,code=0)
链接:http://archive.apache.org/dist/hive/hive-1.2.1/
[cevent@hadoop210 hadoop-2.7.2]$ sbin/start-dfs.sh
[cevent@hadoop210 hadoop-2.7.2]$ sbin/start-yarn.sh
[cevent@hadoop210 hadoop-2.7.2]$ zkServer.sh start
[cevent@hadoop210 hadoop-2.7.2]$ jps
4370 ResourceManager
4488 NodeManager
4841 QuorumPeerMain
4965 Jps
3448 NameNode
3745 SecondaryNameNode
3565 DataNode
[cevent@hadoop210 hbase-1.3.1]$ bin/start-hbase.sh
starting master, logging to
/opt/module/hbase-1.3.1/logs/hbase-cevent-master-hadoop210.cevent.com.out
hadoop212.cevent.com: starting
regionserver, logging to /opt/module/hbase-1.3.1/bin/../logs/hbase-cevent-regionserver-hadoop212.cevent.com.out
hadoop211.cevent.com: starting
regionserver, logging to
/opt/module/hbase-1.3.1/bin/../logs/hbase-cevent-regionserver-hadoop211.cevent.com.out
hadoop210.cevent.com: starting regionserver,
logging to
/opt/module/hbase-1.3.1/bin/../logs/hbase-cevent-regionserver-hadoop210.cevent.com.out
[cevent@hadoop210 hbase-1.3.1]$ jps
4370 ResourceManager
5115 HMaster
4488 NodeManager
4841 QuorumPeerMain
3448 NameNode
3745 SecondaryNameNode
3565 DataNode
5393 Jps
5262 HRegionServer
[cevent@hadoop210 hive-1.2.1]$ ll
总用量 532
drwxrwxr-x. 3 cevent cevent 4096 6月 28 16:23 bin
drwxrwxr-x. 2 cevent cevent 4096 6月 28 21:08 conf
-rw-rw-r--. 1 cevent cevent 21061 6月 28 16:35 derby.log
drwxrwxr-x. 4 cevent cevent 4096 6月 28 16:23 examples
drwxrwxr-x. 7 cevent cevent 4096 6月 28 16:23 hcatalog
drwxrwxr-x. 4 cevent cevent 4096 6月 29 09:24 lib
-rw-rw-r--. 1 cevent cevent 24754 4月 30 2015 LICENSE
drwxrwxr-x. 5 cevent cevent 4096 6月 28 16:35 metastore_db
-rw-rw-r--. 1 cevent cevent 397 6月 19 2015 NOTICE
-rw-rw-r--. 1 cevent cevent 4366 6月 19 2015 README.txt
-rw-rw-r--. 1 cevent cevent 421129 6月 19 2015 RELEASE_NOTES.txt
drwxrwxr-x. 3 cevent cevent 4096 6月 28 16:23 scripts
-rw-rw-r--. 1 cevent cevent 24896 6月 28 22:32 zookeeper.out
[cevent@hadoop210 hive-1.2.1]$ bin/hiveserver2
[cevent@hadoop210 hive-1.2.1]$ bin/beeline
Beeline version 1.2.1 by Apache Hive
beeline> !connect
jdbc:hive2://hadoop210.cevent.com:10000
Connecting to
jdbc:hive2://hadoop210.cevent.com:10000
Enter username for
jdbc:hive2://hadoop210.cevent.com:10000: cevent
Enter password for
jdbc:hive2://hadoop210.cevent.com:10000: ******
Connected to: Apache Hive (version 1.2.1)
Driver: Hive JDBC (version 1.2.1)
Transaction isolation:
TRANSACTION_REPEATABLE_READ
0:
jdbc:hive2://hadoop210.cevent.com:10000> show tables;
+-----------+--+
| tab_name |
+-----------+--+
| student |
+-----------+--+
1 row selected (1.458 seconds) 创建hive表和hbase表
0:
jdbc:hive2://hadoop210.cevent.com:10000> CREATE
TABLE hive_hbase_emp_table(
0:
jdbc:hive2://hadoop210.cevent.com:10000> empno
int,
0:
jdbc:hive2://hadoop210.cevent.com:10000> ename
string,
0: jdbc:hive2://hadoop210.cevent.com:10000>
job string,
0:
jdbc:hive2://hadoop210.cevent.com:10000> mgr int,
0:
jdbc:hive2://hadoop210.cevent.com:10000> hiredate
string,
0: jdbc:hive2://hadoop210.cevent.com:10000> sal double,
0: jdbc:hive2://hadoop210.cevent.com:10000>
comm double,
0:
jdbc:hive2://hadoop210.cevent.com:10000> deptno
int)
0:
jdbc:hive2://hadoop210.cevent.com:10000> STORED
BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
0: jdbc:hive2://hadoop210.cevent.com:10000>
WITH
SERDEPROPERTIES
("hbase.columns.mapping"
=
":key,info:ename,info:job,info:mgr,info:hiredate,info:sal,info:comm,info:deptno")
0:
jdbc:hive2://hadoop210.cevent.com:10000> TBLPROPERTIES
("hbase.table.name" = "hbase_emp_table");
No rows affected (5.286 seconds)
0: jdbc:hive2://hadoop210.cevent.com:10000>
show tables;
+-----------------------+--+
|
tab_name |
+-----------------------+--+
| hive_hbase_emp_table |
| student |
+-----------------------+--+
2 rows selected (0.057 seconds)
0: jdbc:hive2://hadoop210.cevent.com:10000>
插入数据
insert into table
hive_hbase_emp_table values(2020,'cevent','developer',201,'2020-06-29',20000,2000,619);
INFO
: Number of reduce tasks is set to 0 since there's no reduce operator
INFO
: number of splits:1
INFO
: Submitting tokens for job: job_1593393499225_0001
INFO
: The url to track the job:
http://hadoop210.cevent.com:8088/proxy/application_1593393499225_0001/
INFO
: Starting Job = job_1593393499225_0001, Tracking URL =
http://hadoop210.cevent.com:8088/proxy/application_1593393499225_0001/
INFO
: Kill Command = /opt/module/hadoop-2.7.2/bin/hadoop job -kill job_1593393499225_0001
INFO
: Hadoop job information for Stage-0: number of mappers: 1; number of
reducers: 0
INFO
: 2020-06-29 09:33:36,570 Stage-0 map = 0%, reduce = 0%
INFO
: 2020-06-29 09:33:44,934 Stage-0 map = 100%, reduce = 0%, Cumulative CPU 2.79 sec
INFO
: MapReduce Total cumulative CPU time: 2 seconds 790 msec
INFO
: Ended Job = job_1593393499225_0001
No rows affected (37.702 seconds)
0: jdbc:hive2://hadoop210.cevent.com:10000>
select * from hive_hbase_emp_table; 查看hbase中清除数据
+-----------------------------+-----------------------------+---------------------------+---------------------------+--------------------------------+---------------------------+----------------------------+------------------------------+--+
| hive_hbase_emp_table.empno |
hive_hbase_emp_table.ename |
hive_hbase_emp_table.job |
hive_hbase_emp_table.mgr |
hive_hbase_emp_table.hiredate |
hive_hbase_emp_table.sal |
hive_hbase_emp_table.comm |
hive_hbase_emp_table.deptno |
+-----------------------------+-----------------------------+---------------------------+---------------------------+--------------------------------+---------------------------+----------------------------+------------------------------+--+
+-----------------------------+-----------------------------+---------------------------+---------------------------+--------------------------------+---------------------------+----------------------------+------------------------------+--+
No rows selected (1.009 seconds)
[cevent@hadoop210 hbase-1.3.1]$ hbase shell
SLF4J: Class path contains multiple SLF4J
bindings.
SLF4J: Found binding in [jar:file:/opt/module/hbase-1.3.1/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/opt/module/hadoop-2.7.2/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See
http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type
[org.slf4j.impl.Log4jLoggerFactory]
HBase Shell; enter 'help'
for list of supported commands.
Type "exit" to
leave the HBase Shell
Version 1.3.1,
r930b9a55528fe45d8edce7af42fef2d35e77677a, Thu Apr 6 19:36:54 PDT 2017
hbase(main):001:0> list
TABLE
hbase_emp_table
student
2 row(s) in 0.2990 seconds
=> ["hbase_emp_table",
"student"]
hbase(main):002:0> scan
'hbase_emp_table'
ROW COLUMN+CELL
0 row(s) in 0.2450 seconds
ROW COLUMN+CELL
0 row(s) in 0.0070 seconds
hbase(main):004:0> scan 'hbase_emp_table'
ROW COLUMN+CELL
2020 column=info:comm,
timestamp=1593394424573, value=2000.0
2020 column=info:deptno,
timestamp=1593394424573, value=619
2020 column=info:ename,
timestamp=1593394424573, value=cevent
2020 column=info:hiredate,
timestamp=1593394424573, value=2020-06-29
2020 column=info:job,
timestamp=1593394424573, value=developer
2020 column=info:mgr,
timestamp=1593394424573, value=201
2020 column=info:sal,
timestamp=1593394424573, value=20000.0
1 row(s) in 0.0540 seconds
hbase(main):005:0> truncate 'hbase_emp_table'
清洗数据
Truncating 'hbase_emp_table' table (it
may take a while):
-
Disabling table...
-
Truncating table...
0 row(s) in 7.7160 seconds