1 安装hive

下载

http://mirrors.shu.edu.cn/apache/hive/hive-1.2.2/,红框中的不需要编译。

由于hive是默认将元数据保存在本地内嵌的 Derby 数据库中,但是这种做法缺点也很明显,Derby不支持多会话连接,因此本文将选择mysql作为元数据存储。

安装mysql

  1. yum安装mysql
  2.  
  3. wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
  4.  
  5. yum -y install mysql57-community-release-el7-.noarch.rpm
  6.  
  7. yum -y install mysql-community-server
  8.  
  9. 启动MySQL
  10. systemctl start mysqld.service
  11. 查看MySQL运行状态
  12. systemctl status mysqld.service
  13.  
  14. mysql -uroot -p # 回车后会提示输入密码
  15. 此时MySQL已经开始正常运行,不过要想进入MySQL还得先找出此时root用户的密码,通过如下命令可以在日志文件中找出密码:
  16. ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
  17. 12345
  18.  
  19. 具体请参考
  20. https://www.cnblogs.com/brianzhu/p/8575243.html

tar -zxvf apache-hive-1.2.3-bin.tar.gz  后的内容如下,进入到conf

  1. cp hive-default.xml.template hive-site.xml

编辑文件hive-site.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3.  
  4. <!--
  5. Licensed to the Apache Software Foundation (ASF) under one or more
  6. contributor license agreements. See the NOTICE file distributed with
  7. this work for additional information regarding copyright ownership.
  8. The ASF licenses this file to You under the Apache License, Version 2.0
  9. (the "License"); you may not use this file except in compliance with
  10. the License. You may obtain a copy of the License at
  11.  
  12. http://www.apache.org/licenses/LICENSE-2.0
  13.  
  14. Unless required by applicable law or agreed to in writing, software
  15. distributed under the License is distributed on an "AS IS" BASIS,
  16. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. See the License for the specific language governing permissions and
  18. limitations under the License.
  19. -->
  20. <configuration>
  21. <property>
  22. <name>javax.jdo.option.ConnectionUserName</name>
  23. <value>xxxx</value>
  24. </property>
  25. <property>
  26. <name>javax.jdo.option.ConnectionPassword</name>
  27. <value>xxxx</value>
  28. </property>
  29. <property>
  30. <name>javax.jdo.option.ConnectionURL</name>mysql
  31. <value>jdbc:mysql://hostIP:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false&amp;nullNamePatternMatchesAll=true</value>
  32. </property>
  33. <property>
  34. <name>javax.jdo.option.ConnectionDriverName</name>
  35. <value>com.mysql.jdbc.Driver</value>
  36. </property>
  37. </configuration>

复制mysql的驱动程序到hive/lib下面

2 hive启动方式

  1. 运行hive之前首先要确保meta store服务已经启动,
  2.  
  3. nohup hive --service metastore > metastore.log >& &
  4.  
  5. 如果需要用到远程客户端(比如 Tableau)连接到hive数据库,还需要启动hive service
  6.  
  7. nohup hive --service hiveserver2 > hiveserver2.log >& &
  8.  
  9. [sms@gc64 conf]$ hive --help
    Usage ./hive <parameters> --service serviceName <service parameters>
    Service List: beeline cli help hiveburninclient hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledump rcfilecat schemaTool version
    Parameters parsed:
      --auxpath : Auxillary jars
      --config : Hive configuration directory
      --service : Starts specific service/component. cli is default
    Parameters used:
      HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory
      HIVE_OPT : Hive options
    For help on a particular service:
      ./hive --service serviceName --help
    Debug help:  ./hive --debug --help

hive2.0一下没有web查看

  1. [sms@gc64 ~]$ hive
  2.  
  3. Logging initialized using configuration in jar:file:/home/sms/app/apache-hive-1.2.-bin/lib/hive-common-1.2..jar!/hive-log4j.properties
  4. Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
  5. hive>
  6. >
  7. >
  8. > show databases;
  9. OK
  10. default
  11. Time taken: 1.285 seconds, Fetched: row(s)
  12. hive>
  13. >
  14. >
  15. >
  16. >
  17. >
  18. >
  19. >
  20. >
  21. >
  1. from pyspark.sql import HiveContext,Row
  2. from pyspark import SparkConf, SparkContext
  3. conf = SparkConf().setMaster("local").setAppName("count")
  4. sc = SparkContext(conf=conf)
  5. hiveCtx=HiveContext(sc)
  6. hiveCtx.sql("show tables").show()
  7. hiveCtx.sql("select count(1) from (select msid from raw_data group by msid) a").show()

HIVE学习(待更新)的更多相关文章

  1. hive学习

    大数据的仓库Hive学习  10期-崔晓光 2016-06-20  大数据   hadoop   10原文链接 我们接着之前学习的大数据来学习.之前说到了NoSql的HBase数据库以及Hadoop中 ...

  2. [转]实现Hive数据同步更新的shell脚本

    引言: 上一篇文章<Sqoop1.4.4 实现将 Oracle10g 中的增量数据导入 Hive0.13.1 ,并更新Hive中的主表>http://www.linuxidc.com/Li ...

  3. hive学习笔记之六:HiveQL基础

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  4. Hive学习路线图(转)

    Hadoophivehqlroadmap学习路线图   1 Comment Hive学习路线图 Hadoop家族系列文章,主要介绍Hadoop家族产品,常用的项目包括Hadoop, Hive, Pig ...

  5. 【转】Hive学习路线图

    原文博客出自于:http://blog.fens.me/hadoop-hive-roadmap/ 感谢! Hive学习路线图 Hadoop家族系列文章,主要介绍Hadoop家族产品,常用的项目包括Ha ...

  6. Hive学习之六 《Hive进阶— —hive jdbc》 详解

    接Hive学习五 http://www.cnblogs.com/invban/p/5331159.html 一.配置环境变量 hive jdbc的开发,在开发环境中,配置Java环境变量 修改/etc ...

  7. Hive学习路线图--张丹老师

    前言 Hive是Hadoop家族中一款数据仓库产品,Hive最大的特点就是提供了类SQL的语法,封装了底层的MapReduce过程,让有SQL基础的业务人员,也可以直接利用Hadoop进行大数据的操作 ...

  8. Hive学习 系列博客

    原 Hive作业优化 原 Hive学习六:HIVE日志分析(用户画像) 原 Hive学习五--日志案例分析 原 Hive学习三 原 Hive学习二 原 Hive学习一 博客来源,https://blo ...

  9. hive学习路线

    hive学习路线图:

  10. Hive学习之修改表、分区、列

    Hive学习之修改表.分区.列 https://blog.csdn.net/skywalker_only/article/details/30224309 https://www.cnblogs.co ...

随机推荐

  1. UVA10954:Add All(优先队列)

    题目:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68990#problem/O 题目需求:在数组中拿出两个数相加,再把结果放回数组中再 ...

  2. R中seurat等问题学习

    1.Seurat 转自:https://cloud.tencent.com/developer/article/1055892 # Initialize the Seurat object with ...

  3. Spring框架第一篇之Spring的第一个程序

    一.下载Spring的jar包 通过http://repo.spring.io/release/org/springframework/spring/地址下载最新的Spring的zip包,当然,如果你 ...

  4. Elment UI的使用说明

    一. Elment UI 1. 简介 Element UI是饿了么团队提供的一套基于Vue2.0的组件库,可以快速搭建网站,提高开发效率,就如同bootstrap. 2.组件分类 ElementUI  ...

  5. FileLoadTools

    /** * Created by dev013 on 9/9/14. */ var FileLoadTools = (function () { var my = {}; var htmlFile = ...

  6. The adidas NMD XR1 singapore is a bit more cool

    The adidas NMD Singapore continues to be the right silhouette for summer time because of a mix of a ...

  7. spl_autoload_register(转载 http://blog.csdn.net/panpan639944806/article/details/23192267)

    在了解这个函数之前先来看另一个函数:__autoload. 一.__autoload 这是一个自动加载函数,在PHP5中,当我们实例化一个未定义的类时,就会触发此函数.看下面例子: printit.c ...

  8. ruby中的方法查找

    ruby中的方法调用都是 对象.方法 的形式,那么对象如何找到这个方法呢? 首先必须了解祖先链的概念,祖先链就是从一个类开始,到它的父类,再到父类的父类...一直到最终的起点(ruby中是BasicO ...

  9. 斐迅面试记录—Http协议中的Header

    HTTP Request的Header信息 1.HTTP请求方式 如下表: 说明:  主要使用到“GET”和“POST”. 实例: POST /test/tupian/cm HTTP/1.1 分成三部 ...

  10. MVC[xml]页面传值

    MVC 各种传值方式 ViewData传值.HomeController.cs Co de: public ActionResult Index(){      ViewData["Titl ...