ubuntu16.04 安装hive及配置
Posted suphowe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu16.04 安装hive及配置相关的知识,希望对你有一定的参考价值。
1.下载hive
http://mirror.bit.edu.cn/apache/hive/
2.解压文件
tar -xvf apache-hive-3.1.2-bin.tar.gz
修改名称
mv apache-hive-3.1.2 hive
3.配置环境变量
1.修改~/.bashrc文件
vim ~/.bashrc
添加
export HIVE_HOME=/home/user/server/hive
export PATH=$PATH:$HIVE_HOME/bin
//立即生效
source ~/.bashrc
2.修改hive-site.xml
//新建文件 cp hive-default.xml.template hive-default.xml //新建文件 touch hive-site.xml
在hive-site.xml中添加<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<!--数据库用户-->
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>username to use against metastore database</description>
</property>
<!--数据库密码-->
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
<description>password to use against metastore database</description>
</property>
</configuration>
4.在mysql中添加database
mysql -uroot -p //输入密码进入 create database hive;
5.启动hadoop和hive
//启动hadoop
bash start-all.sh //启动hive
./hive
6.问题处理
1.启动hive时
Cannot find hadoop installation: $HADOOP_HOME or $HADOOP_PREFIX must be set or hadoop must be in the path
处理:
在confi目录下
cp hive-env.sh.template hive-env.sh
在hive-env.sh添加
export HADOOP_HOME=/home/user/server/hadoop/hadoop-3.2.1
2.报错
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357) at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338) at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:536) at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:554) at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:448) at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:5141) at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5099) at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:97) at org.apache.hadoop.hive.common.LogUtils.initHiveLog4j(LogUtils.java:81) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:699) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:683) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.util.RunJar.run(RunJar.java:323) at org.apache.hadoop.util.RunJar.main(RunJar.java:236)
比较
/home/tjtl/user/hive/lib
/home/tjtl/user/hadoop/hadoop-3.2.1/share/hadoop/common/lib
两个目录下 guava jar包的版本,删除低版本,复制高版本
rm guava-19.0.jar cp ../../hadoop/hadoop-3.2.1/share/hadoop/common/lib/guava-27.0-jre.jar ./
以上是关于ubuntu16.04 安装hive及配置的主要内容,如果未能解决你的问题,请参考以下文章