首页 > 其他 > 详细

hive (一)

时间:2018-01-01 19:01:33      阅读:284      评论:0      收藏:0      [点我收藏+]

1、配置 hive-site.xml

 1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>  
 2 <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
 3 <configuration>  
 4    <property>  
 5         <name>javax.jdo.option.ConnectionURL</name>  
 6         <value>jdbc:mysql://192.168.2.128:3306/hive?createDatabaseIfNotExist=true</value>  
 7     </property>  
 8     <property>  
 9         <name>javax.jdo.option.ConnectionDriverName</name>  
10         <value>com.mysql.jdbc.Driver</value>  
11     </property>  
12     <property>  
13         <name>javax.jdo.option.ConnectionUserName</name>  
14         <value>root</value>  
15     </property>  
16     <property>  
17         <name>javax.jdo.option.ConnectionPassword</name>  
18         <value>MyNewPass1!</value>  
19     </property>  
20     <property>    
21    <name>hive.metastore.schema.verification</name>    
22    <value>false</value>    
23     <description>    
24     Enforce metastore schema version consistency.    
25     True: Verify that version information stored in metastore matches with one from Hive jars.  Also disable automatic    
26           schema migration attempt. Users are required to manully migrate schema after Hive upgrade which ensures    
27           proper metastore schema migration. (Default)    
28     False: Warn if the version information stored in metastore doesnt match with one from in Hive jars.    
29     </description>    
30  </property>   
31 </configuration>  

2、初始化

bin/schematool -initSchema -dbType mysql

3、

技术分享图片

4、

技术分享图片

 4、开启开启 metastore和hiveserver2

hive --service metastore &

hive --service hiveserver2 &

可以通过命令netstat -ntulp |grep 10000 
可以看到结果 
tcp 0 0 0.0.0.0:10000 0.0.0.0:* LISTEN 27799/java

技术分享图片

5、hive jdbc

 1 public static void main(String[] args) throws Exception {
 2         Class.forName("org.apache.hive.jdbc.HiveDriver");
 3         // default为数据库名
 4         Connection con = DriverManager.getConnection("jdbc:hive2://master:10000/db_hive_test");
 5         Statement stmt = con.createStatement();
 6         String querySQL = "SELECT * FROM sudent";
 7 
 8         ResultSet res = stmt.executeQuery(querySQL);
 9 
10         while (res.next()) {
11             System.out.println(res.getString(1)+","+res.getString(2));
12         }
13 
14     }

 

hive (一)

原文:https://www.cnblogs.com/huangjianping/p/8168008.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!