hive【五】日志分析.md


[toc]

日志分析

hive常用客户端

hiveserver2和beeline客户端

服务端启动:

$ hive –service hiveserver2或者直接:hiveserver2

客户端远程:

$ beeline -u jdbc:hive2://master:10000 -n nemo -p tan -e "select count(*) from request_log"

客户端shell

$ 输入beeline后进入beeline shell
$ !connect jdbc:hive2://localhost:10000### hive 

jdbc客户端

创建一个maven项目,pom.xml文件如下

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>1.2.1</version>
</dependency>

jdbc连接代码:

 try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block e.printStackTrace();
System.exit(1);
}
//replace "hive" here with the name of the user the queries should run as Connection con = DriverManager.getConnection("jdbc:hive2://master:10000/default", "nemo", "lovelili");
Statement stmt = con.createStatement();
String tableName = "testHiveDriverTable";
stmt.execute("drop table if exists " + tableName);

hive日志分析步骤

nemotan /
Published under (CC) BY-NC-SA in categories hive  tagged with hive