Apache Hive--安装部署-几种交互方式| 学习笔记

开发者学堂课程【大数据 Hive 教程精讲Apache Hive--安装部署-几种交互方式】学习笔记,与课程紧密联系,让用户快速学习知识。

课程地址https://developer.aliyun.com/learning/course/90/detail/1365


Apache Hive--安装部署-几种交互方式

 

Apache Hive--安装部署:

hive 安装手册:

启动 hivebin/ hive

Hive几种使用方式:

1.Hive 交互shell

bin/hive

2.  Hive JDBC 服务(参考java jdbc连接mysql)

3.  hive 启动为一个服务器,来对外提供服务

bin/hiveserver2

nohup bin/hiveserver2 1>/var/log/hiveserver.log 2>/var/log/hiveserver.err &

启动成功后,可以在别的节点上用 beeline去连接

bin/ beeline -u jdbc:hive2: //mini1:10000 -n root

或者

bin/beeline

! connect jdbc:hive2: / /mini1: 10000

4.Hive命令

hive-e'sql'

bin/ hive -e 'select * from t_test'

添加如下内容:​​<configuration><property>

<name>javax.jdo.option. connectionURL</ name>

<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value><description>JDBC connect string for a JDBc metastore</description>

</property>

<property>

<name>javax.jdo.option.connectionDriverName</name><value>com.mysql.jdbc.Driver</value>

<description>Driver class name for a JDBc metastore</description></property>

<property>

<name>javax.jdo.option.ConnectionUserName</name><value>root</value>

<description>username to use against metastore database</description></property>

<property>

<name>javax.jdo.option.connectionPassword</name><value>root</value>

<description>password to use against metastore database</description></property>

</ configuration>

Node-1:

[root@node-1 hive]# 11total 476

drwxr-xr-x. 3 root root4096 an 15 13:42 bindrwxr-xr-x. 2 root root4096 jan 15 13:50 conf

drwxr-xr-x. 4 root root 4096 Jan 15 13:36 examplesdrwxr-Xr-x. 7 root root4096 Jan 15 13:36 hcatalogdrwxr-xr-x. 4 root root4096 Jan 15 13:51 1ib

-rw-rw-r--. 1 root root24754 Apr 302015 LICENSE-rw-rw-r--. 1 root root397 Jun 192015 NOTICE

-rw-rw-r--. 1 root root 4366 Jun 192015 README.txt

-rw-rw-r--. 1 root root 421129 Jun 192015 RELEASE_NOTES.txtdrwxr-xr-x. 3 root root 4096 Jan 15 13:36 scripts

[root@node-1 hive]# bin/hive

Logging initialized using configuration in jar:file:/export/server/hive/1ib/hive-common-1.2.1.jar ! /hive-1og4j.properties

hive> show databases

oK

defaultitcast

ime taken: 0.794 seconds,Fetched: 2 row(s)hive> use itcast;

oK

Time taken : o.028 secondshive> [root@node-1 hive]#

riftCLIservice.java: 486)

at_org.apache.hive.service.c1i.thrift.TCLIService$Processor$Executestate

nt.getResu1t(icLiservice.java:1313)

at_org.apache.hive.service.c1i.thrift.TCLIService$Processor$ExecuteStatem

nt.getResu1t(IcLiservice.java:1298)

at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)

at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddr

ssProcessor.java:56

at org.apache.thrift.server.TThreadPoo1Server$workerProcess.run(TThreadPo

1server.java:285)

....at java.uti1.concurrent. ThreadPoo1Executor.runworker(ThreadPoo1Executor.jva: 1142)​​“.ava.ul

...at java.uti1.concurrent.ThreadPoo1Executor$worker.run(ThreadPoo1Executor.ava:617)"--

at java. 1ang.Thread.run (Thread.java: 745)

FAILED: ParseException line 1:s cannot recognize input near 'show​​’'databas’ 'Eo>' in dd7 statement

[root@node-1 hive]# bin/hive -e 'show databases'

Logging initialized using configuration in jar:fi1e:/export/server/hive/1ib/hive-Common-1.2.1.jar !/hive-1og4j.properties

oK

defaultitcast

Time taken: o.983_seconds​​,Fetched: 2 row(s)[root@node-1 hive]#

Node-1(1):

Last login: Mon Jan 15 14:01:27 2018 from 192.168.158.1

[root@node-1 ~]# jps

2384 DataNode

277O NodeManager2245 NameNode

5350 Jps

5225 Run3ar

2655 ResourceManager

[root@node-1 ~]#scp -r /export/server/hive/ root@node-3:/export/server/

[root@node-3 ~]# cd lexport/server/hive/[root@node-3 hive]# bin/bee7ine

Beeline version i.2.i by Apache Hive

beeline> ! connect jdbc:hive2://node-1:1000oConnecting to jdbc:hive2://node-1: 100o0

Enter username for jdbc:hive2 ://node-1:10000: rootEnter password for jdbc:hive2://node-1:10000:*​​☆☆☆☆☆☆Connected to: Apache Hive (varsion 1.2.1)

Driver: Hive jDBc (version i.2.1)

Transaction isolation: TRANSACTTON_REPEATABLE_READ0: jdbc:hive2: //node-1:10000> show databases;

2 rows selected (1.156 seconds)

0: jdbc:hive2:/ /node-1:10000>

上一篇:关于 xcode 工程编译报错 undefined symbol _res_9_init的解决办法


下一篇:@staticmethod和@classmethod的作用与区别