zoukankan      html  css  js  c++  java
  • hive (一)

    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://master/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 doesn't 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 student";
     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/hmy-blog/p/6506417.html

  • 相关阅读:
    数据结构实践——败者树归并模拟
    systemctl介绍
    Andriod Atom x86模拟器启动报错。
    (白书训练计划)UVa 11572 Unique Snowflakes(窗体滑动法)
    OpenCV2.3.1在CentOS6.5下的安装
    本学期课程教学要解决这个问题要点备忘录
    firefox浏览器和IE
    [LeetCode] Validate Binary Search Tree
    android性能优化优秀文章
    如何在使用eclipse的情况下,清理android项目中的冗余class文件和资源文件以及冗余图片
  • 原文地址:https://www.cnblogs.com/huangjianping/p/8168008.html
Copyright © 2011-2022 走看看