【IDEA配置毗连Linux虚拟机的Hive数据库(超详细)】

打印 上一主题 下一主题

主题 912|帖子 912|积分 2736

1. 准备工作

配置好hive的长途模式,hive-site.xml配置如下:
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
  3.    Licensed to the Apache Software Foundation (ASF) under one or more
  4.    contributor license agreements.  See the NOTICE file distributed with
  5.    this work for additional information regarding copyright ownership.
  6.    The ASF licenses this file to You under the Apache License, Version 2.0
  7.    (the "License"); you may not use this file except in compliance with
  8.    the License.  You may obtain a copy of the License at
  9.        http://www.apache.org/licenses/LICENSE-2.0
  10.    Unless required by applicable law or agreed to in writing, software
  11.    distributed under the License is distributed on an "AS IS" BASIS,
  12.    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.    See the License for the specific language governing permissions and
  14.    limitations under the License.
  15. -->
  16. <configuration>
  17.    <!-- 存储元数据mysql相关配置 -->
  18.    <property>
  19.       <name>javax.jdo.option.ConnectionURL</name>
  20.       <value>jdbc:mysql://localhost:3306/hive_meta?createDatabaseIfNotExist=true&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8</value>
  21.    </property>
  22.    
  23.    <property>
  24.       <name>javax.jdo.option.ConnectionDriverName</name>
  25.       <value>com.mysql.jdbc.Driver</value>
  26.    </property>
  27.    <property>
  28.       <name>javax.jdo.option.ConnectionUserName</name>
  29.       <value>root</value>
  30.    </property>
  31.    
  32.    <property>
  33.       <name>javax.jdo.option.ConnectionPassword</name>
  34.       <value>123456</value>
  35.    </property>
  36.    <!-- H2S运行绑定host -->
  37.    <property>
  38.       <name>hive.server2.thrift.bind.host</name>
  39.       <value>my2308-host</value>
  40.    </property>
  41.    <!-- 远程模式部署metastore服务地址 -->
  42.    <property>
  43.       <name>hive.metastore.uris</name>
  44.       <value>thrift://my2308-host:9083</value>
  45.    </property>
  46.    <!-- 关闭元数据存储授权 -->
  47.    <property>
  48.       <name>hive.metastore.event.db.notification.api.auth</name>
  49.       <value>false</value>
  50.    </property>
  51.    <!-- 关闭元数据存储版本的验证 -->
  52.    <property>
  53.       <name>hive.metastore.schema.verification</name>
  54.       <value>false</value>
  55.    </property>
  56. </configuration>
复制代码
确保hadoop集群已经启动,然后启动metastore服务以及hive server2服务,命令如下:
  1. # 后台挂起metastore
  2. nohup /export/servers/apache-hive-3.1.3-bin/bin/hive --service metastore &
  3. # 后台挂起server2
  4. nohup hiveserver2 > ./nohup1.out 2>&1 &
复制代码
2. 创建毗连

下载hive对应版本的jdbc driver jar包,3.1.3版本链接如下:
https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/3.1.3/
进入页面,下载hive-jdbc-3.1.3-standalone.jar
打开IDEA,创建或打开一个项目,点击Database,选择”+“号,点击Driver。

添加Hive的jdbc jar包。之后点击Apply完成添加。

创建毗连。

填写hive server2所在的服务器或主机的主机名或者ip,登录的用户名,然后测试毗连。

测试毗连乐成!

点击OK,完成hive的毗连。
3. 结果

创建一个.sql的文件,即可快乐的进行hive QL的代码编写。


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

钜形不锈钢水箱

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表