Chinaunix首页 | 论坛 | 博客
  • 博客访问: 450915
  • 博文数量: 80
  • 博客积分: 2301
  • 博客等级: 大尉
  • 技术积分: 884
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-16 20:07
个人简介

I\'m interested in mathematics and Daoism. Welcome to talk about these subjects with me.

文章分类

全部博文(80)

文章存档

2017年(2)

2016年(16)

2015年(4)

2014年(6)

2013年(22)

2012年(2)

2011年(1)

2010年(4)

2009年(20)

2008年(2)

2007年(1)

我的朋友

分类: 大数据

2016-03-11 16:21:11

    hive是hadoop中的一个组件,它提供了数据仓库的功能。它把你输入的sql语句转化成mapreduce任务来执行。最终的数据存储在hdfs上面。
    spark-sql提供了读写hive数据的功能。事实上,spark-sql可以认为是hive的重新实现:spark-sql的命令是spark执行引擎来运行,而不是mapreduce; 提供了自己独特的优化器。spark-sql可以认为是一个更好的hive。
    如果你是新搭建的系统,建议就不要安装hive了(当然hdfs还是?的)。

    一、设置
    vim /etc/profile
    添加类似如下的两行配置项
    export HIVE_HOME=/home/hadoop/hive/apache-hive-1.2.1-bin
    export PATH=$PATH:$HIVE_HOME/bin

    hive-site.xml可以不配置

    二、从命令行访问数据仓库
     1) 运行脚本sbin/start-thriftserver.sh 来后台服务。启动的服务,相当于mysqld
     2) 运行脚本./bin/beeline ,这个脚本相当于mysql自带的mysql客户端程序
     3) 链接服务器,使用如下命令
     !connect jdbc:hive2://192.168.0.201:10000
    4) 输入sql命令

     三、scala程序访问数据仓库
     自己用scala的程序中访问数据仓库,请见这里:
     
     只是要注意一点:在运行程序之前,千万不要运行脚本sbin/start-thriftserver.sh,否则自己写的程序是无法运行的,错误大致如下:
    ...
    java.sql.SQLException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@5a0039e7, see the next exception for details
    ...
    java.sql.SQLException: Failed to start database 'metastore_db' with class loader org.apache.spark.sql.hive.client.IsolatedClientLoader$$anon$1@5a0039e7, see the next exception for details
    ...
    Caused by: ERROR XSDB6: Another instance of Derby may have already booted the database /home/hadoop/spark/spark-1.5.2-bin-hadoop2.6/metastore_db
   

     
     
阅读(4714) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~