`

beeline 连接SPARK /Hive

 
阅读更多


hiveclient所在主机的jdk 1.7_51,hive 0.12和hadoop 2.3.0是从服务器端拷贝过来的,环境变量一切OK.
执行连接报了Invalid URL的错误:
$ beeline
Beeline version 0.12.0 by Apache Hive
beeline> !connect jdbc:hive2://cloud011:10000
scan complete in 2ms
Connecting to jdbc:hive2://cloud011:10000
Enter username for jdbc:hive2://cloud011:10000:
Enter password for jdbc:hive2://cloud011:10000:
Error: Invalid URL: jdbc:hive2://cloud011:10000 (state=08S01,code=0)

开始的一段时间都在纠结这个jdbc的URL格式问题,后来在cloudra论坛上找到了一个方法,
直接调用的jdbc:hive2的驱动测试是正常的,证明CLASSPATH等环境变量没有问题。

这时候感觉很可能不是客户端的问题,矛头指向服务器端:

发现绑定的主机地址是localhost,而localhost的地址是127.0.0.1。这应该就是问题所在,从服务器本地测试:

连接成功!

下面就要把参数改一下,然后重启服务

重启服务后检查监听地址,这次是正确的了。

再次在客户端主机上测试连接:

成功。

 

 

 

Thrift JDBC Server描述

Thrift JDBC Server使用的是HIVE0.12的HiveServer2实现。能够使用Spark或者hive0.12版本的beeline脚本与JDBC Server进行交互使用。Thrift JDBC Server默认监听端口是10000。

使用Thrift JDBC Server前需要注意:

1、将hive-site.xml配置文件拷贝到$SPARK_HOME/conf目录下;

2、需要在$SPARK_HOME/conf/spark-env.sh中的SPARK_CLASSPATH添加jdbc驱动的jar包

export SPARK_CLASSPATH=$SPARK_CLASSPATH:/home/Hadoop/software/mysql-connector-java-5.1.27-bin.jar

Thrift JDBC Server命令使用帮助:

cd $SPARK_HOME/sbin
start-thriftserver.sh --help


复制代码
Usage: ./sbin/start-thriftserver [options] [thrift server options]
Spark assembly has been built with Hive, including Datanucleus jars on classpath
Options:
  --master MASTER_URL        spark://host:port, mesos://host:port, yarn, or local.
  --deploy-mode DEPLOY_MODE  Whether to launch the driver program locally ("client") or
                              on one of the worker machines inside the cluster ("cluster")
                              (Default: client).
  --class CLASS_NAME          Your application's main class (for Java / Scala apps).
  --name NAME                A name of your application.
  --jars JARS                Comma-separated list of local jars to include on the driver
                              and executor classpaths.
  --py-files PY_FILES        Comma-separated list of .zip, .egg, or .py files to place
                              on the PYTHONPATH for Python apps.
  --files FILES              Comma-separated list of files to be placed in the working
                              directory of each executor.

  --conf PROP=VALUE          Arbitrary Spark configuration property.
  --properties-file FILE      Path to a file from which to load extra properties. If not
                              specified, this will look for conf/spark-defaults.conf.

  --driver-memory MEM        Memory for driver (e.g. 1000M, 2G) (Default: 512M).
  --driver-java-options      Extra Java options to pass to the driver.
  --driver-library-path      Extra library path entries to pass to the driver.
  --driver-class-path        Extra class path entries to pass to the driver. Note that
                              jars added with --jars are automatically included in the
                              classpath.

  --executor-memory MEM      Memory per executor (e.g. 1000M, 2G) (Default: 1G).

  --help, -h                  Show this help message and exit
  --verbose, -v              Print additional debug output

 Spark standalone with cluster deploy mode only:
  --driver-cores NUM          Cores for driver (Default: 1).
  --supervise                If given, restarts the driver on failure.

 Spark standalone and Mesos only:
  --total-executor-cores NUM  Total cores for all executors.

 YARN-only:
  --executor-cores NUM        Number of cores per executor (Default: 1).
  --queue QUEUE_NAME          The YARN queue to submit to (Default: "default").
  --num-executors NUM        Number of executors to launch (Default: 2).
  --archives ARCHIVES        Comma separated list of archives to be extracted into the
                              working directory of each executor.

Thrift server options:
    --hiveconf <property=value>  Use value for given property

master的描述与Spark SQL CLI一致

beeline命令使用帮助:

cd $SPARK_HOME/bin
beeline --help

 

Thrift JDBC Server/beeline启动

启动Thrift JDBC Server:默认端口是10000

cd $SPARK_HOME/sbin
start-thriftserver.sh

如何修改Thrift JDBC Server的默认监听端口号?借助于--hiveconf

start-thriftserver.sh  --hiveconf hive.server2.thrift.port=14000

HiveServer2 Clients 详情参见:https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients

启动beeline

cd $SPARK_HOME/bin
beeline -u jdbc:hive2://hadoop000:10000/default -n hadoop

sql脚本测试

SELECT track_time, url, session_id, referer, ip, end_user_id, city_id FROM page_views WHERE city_id = -1000 limit 10;
SELECT session_id, count(*) c FROM page_views group by session_id order by c desc limit 10;

 

 

分享到:
评论

相关推荐

    使用beeline工具连接Hive.md

    使用beeline工具连接Hive

    hivesql语句练习

    1.上传tar包 2.解压 tar -zxvf hive-1.2.1.tar.gz 3.安装mysql数据库 推荐yum 在线安装 4.配置hive (a)配置HIVE_HOME环境变量 vi conf/hive-env.sh ... bin/hive -e 'select * from t_test'

    Hiveserver2 Beeline连接设置用户名和密码.docx

    本文将详细介绍如何在Hive中设置用户名和密码,从而保证连接的鉴权与安全。基本思路是先自定义一个权限认证类接收用户名和密码,打成jar包后放到到HIVE的Lib目录下,然后配置Hive的配置文件和Hadoop的配置文件即可。...

    jdbc连接hive数据库的驱动jar包

    jdbc连接hive数据库的jar包.整理可用合集.

    hive jdbc 连接所需要的jar包

    hive jdbc 连接所需要的所有jar包,很全的,不需要再下载其他的

    Hive Beeline连接报错:Could not open client transport with JDBC Uri: jdbc:hive2://hcmaster:10000/default

    其中“hc”是连接beeline的用户。 启动测试 重启hdfs:先stop-all.sh,再start-all.sh,否则不会生效。 启动hiverserver2 查看是否启动:netstat -anp | grep 10000 3. 连接hiveserver2 作者:梁云亮

    HiveJDBC4.jar客户端连接hive-jdbc驱动包

    cloudera.com为我们提供的hiveserver2-JDBC驱动包,不需要把10几个jar找齐就能使用了。

    hive连接jdbc所需jar包.zip

    使用SQuirreL SQL 连接hive,jdbc方式,共计17个jar包 commons-collections-3.2.2.jar commons-httpclient-3.0.1.jar guava-14.0.1.jar hadoop-common-2.7.3.jar hive-beeline-1.2.1.jar hive-common-1.2.1.jar hive...

    hive2_auth-1.0.jar

    Hiveserver2 Beeline连接设置用户名和密码,通用jar包。放到hive lib路径下即可。用户名密码在配置文件hive-site.xml中配置,具体的配置方式,请参考本站博文。 &lt;name&gt;hive.jdbc_passwd.auth.root&lt;/name&gt;&lt;!--用户...

    reflectasm-1.07-shaded.jar

    使用beeline登录到hive服务端的时候报错了,错误信息如下: 解决办法:单独下载这3个jar包,然后放入到hive的lib目录下,再配置hive-site.xml配置文件,如下: &lt;name&gt;hive.aux.jars.path&lt;/name&gt; &lt;value&gt;...

    HiveCLI和Beeline命令行的基本使用.md

    HiveCLI和Beeline命令行的基本使用,基础篇

    Hadoop+Hive+Spark+Kafka+Zookeeper+Flume+Sqoop+Azkaban+Scala

    CLI 和 Beeline 命令行的基本使用 常用 DDL 操作 分区表和分桶表 视图和索引 常用 DML 操作 数据查询详解 三、Spark Spark Core Spark SQL Spark Streaming 五、Flink 核心概念综述 开发环境搭建 Data Source Data ...

    ES-HIVE数据互通

    实现elasticsearch与hive数据互通 环境 实验性单节点集群 vagrant.linux16.4.4(无doctor) hive2.3.3+beeline es6.2.2 kibana6.2.2 elasticsearch-hadoop-6.2.2.jar 没有doctor

    hive-shell批量命令执行脚本的实现方法

    今天小编就为大家分享一篇hive-shell批量命令执行脚本的实现方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

    非常好的大数据入门目资源,分享出来.zip

    Hive CLI 和 Beeline 命令行的基本使用 Hive 常用 DDL 操作 Hive 分区表和分桶表 Hive 视图和索引 Hive 常用 DML 操作 Hive 数据查询详解 三、Spark Spark Core : Spark 简介 Spark 开发环境搭建 弹性式数据集 RDD ...

    14-Hive-HA

    Hive-HA思维导图,便捷整理思路,Hive的搭建方式有三种、hiveserver2的优点、架构、配置、启动、连接:beeline连接、jdbc连接

    spark 测试脚本

    用于测试spark数据,beeline链接,hive数据同步!带有log输出!

    hbase:实验一-Hive3安装与部署.pdf

    实验目的: 学习Hive基本知识;2)提高Linux操作技能;3)巩固Hadoop相关知识;4)了解Hive架构与相关组件。 实验内容: 1)配置伪分布式Hadoop3系统;...3)以beeline连接HiveServer2,可以运行初级查询命令。

    大数据精选入门指南,包括大数据学习路线、大数据技术栈思维导图

    Hive CLI 和 Beeline 命令行的基本使用 Hive 使用 DDL 操作 Hive 分区表和分区表 Hive 视图和索引 Hive 使用 DML 操作 Hive数据详细查询解 三、火花 火花核心: 斯帕克简介 Spark开发环境搭建 弹性式数据集 RDD RDD...

    big_data_training

    大数据培训资料库设定表hdfs dfs -mkdir -p /tmp/hivedemo/cd big_data_traininghdfs dfs -put -f data /tmp/hivedemo/beeline -u "jdbc:hive2://localhost:10000" -f data/setup_tables.sql练习题 : /蜂巢SQL :...

Global site tag (gtag.js) - Google Analytics