• 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

  • 相关阅读:
    调整数组顺序使奇数位于偶数前面
    网站远程附件存储到 OSS
    平滑升级mariadb
    在Apache服务器上安装SSL证书
    复试-英语
    部署博客(docker)
    远程连接Windows
    Ultimate SLAM?利用事件相机解锁高速运动、高动态范围场景
    LRNNet:轻量级FCB& SVN实时语义分割
    3D目标检测深度学习方法中voxel-represetnation内容综述(三)
  • 原文地址:https://www.cnblogs.com/huangjianping/p/8168008.html
Copyright © 2020-2023  润新知