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

  • 相关阅读:
    P1843 奶牛晒衣服
    P1577 切绳子
    P2777 [AHOI2016初中组]自行车比赛——洛谷
    选择我自己的算法 2012年CCC加拿大高中生信息学奥赛
    如何修改博客园里个人首页背景(form:cot 大犇)
    洛谷P1105 平台
    SPFA模板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板板
    洛谷p2504 HAOI2006 聪明的猴子
    舒适的路线
    超级质数
  • 原文地址:https://www.cnblogs.com/huangjianping/p/8168008.html
Copyright © 2011-2022 走看看