Hive hiveserver2 配置运行

1:运行

命令行模式:

hive --service hiveserver2 --hiveconf hive.server2.thrift.port=10001

服务模式:

hiveserver2 start

[jifeng@feng01 conf]$ hive --service hiveserver2 --hiveconf hive.server2.thrift.port=10001
Starting HiveServer2
15/03/05 16:59:33 WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has any effect.  Use hive.hmshandler.retry.* instead


2:权限问题

java jdbc连接报错:

Exception in thread "main" java.sql.SQLException: Error while compiling statement: FAILED: RuntimeException Cannot make directory: hdfs://feng01:9000/tmp/hive-jifeng/hive_2015-03-05_17-04-43_349_5945847416346775092-3
	at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:121)
	at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:109)
	at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:231)
	at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:355)
	at demo.test.Pretest.main(Pretest.java:28)

服务端也看到错误
FAILED: RuntimeException Cannot make directory: hdfs://feng01:9000/tmp/hive-jifeng/hive_2015-03-05_17-04-43_349_5945847416346775092-3
无权限创建目录,修改为管理hadoop的用户和密码

修改后

3:For input string: "5000L"

JDBC连接报:

Exception in thread "main" java.sql.SQLException: For input string: "5000L"
	at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:121)
	at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:109)
	at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:263)
	at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:355)
	at demo.test.Pretest.main(Pretest.java:28)
修改配置:

把hive-site.xml

这个配置文件里hive.server2.long.polling.timeout这个参数是5000L,改成5000

[jifeng@feng01 conf]$ vi hive-site.xml 

  <name>hive.server2.long.polling.timeout</name>
  <value>5000</value>
  <description>Time in milliseconds that HiveServer2 will wait, before responding to asynchronous calls that
 use long polling</description>
</property>
4:JDBC 连接HIVE OK

package demo.test;

import java.sql.*;

public class Pretest {


		    public static void main( String args[] )
		        throws SQLException , ClassNotFoundException {
	    	    String jdbcdriver="org.apache.hive.jdbc.HiveDriver";

	    	    String jdbcurl="jdbc:hive2://feng01:10001";

	    	    String username="jifeng";
	    	    String password="jifeng";		
	    	    Class.forName(jdbcdriver);
	    	    Connection c = DriverManager.getConnection(jdbcurl,username,password); 
		        Statement st = c.createStatement();
		       // select * from firewall where idauto=16600918"));//
		        print( "num should be 1 " , st.executeQuery("select * from course"));
		        //( "select id,name,vip from users order by id limit 5" ) );
		        // TODO indexing
		    }
			 static void print( String name , ResultSet res )
				        throws SQLException {
				        System.out.println( name);
				        ResultSetMetaData meta=res.getMetaData();				        
		                //System.out.println( "\t"+res.getRow()+"条记录");
		                String	str="";
		                for(int i=1;i<=meta.getColumnCount();i++){
		                	str+=meta.getColumnName(i)+"   ";
		                	//System.out.println( meta.getColumnName(i)+"   ");
		                }
		                System.out.println("\t"+str);
		                str="";
				        while ( res.next() ){
				        	for(int i=1;i<=meta.getColumnCount();i++){	
				        		str+= res.getString(i)+"   ";				        	} 
				        	System.out.println("\t"+str);
				        	str="";
				        }
				    }	    
}
运行结果:
	course.id   course.c1   course.c2   course.c3   course.c4   
	1   英语   中文   法文   日文   
	2   中文   法文         
	3   中文   法文   日文      
	4   中文   法文   拉丁      
	5   中文   法文   德文      





  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值