Hive安装

来源:互联网 发布:淘宝医药商城 编辑:程序博客网 时间:2024/05/25 01:35


前提

1、Linux centos 6.x 64位

2、安装了hadoop。教程:http://blog.csdn.net/zengmingen/article/details/50896094

3、安装了Mysql5.5+的版本(Hive2.x需要)。

教程:http://blog.csdn.net/zengmingen/article/details/52326253 。

不要忽略博文里的:但我安装时报错 


下载

地址:http://apache.fayea.com/hive/

     安装包:apache-hive-2.1.0-bin.tar.gz


解压

root登录。/home/文件下

tar -xzvf apache-hive-2.1.0-bin.tar.gz
mv apache-hive-2.1.0-bin hive2.1

Linux环境变量配置

vi /etc/profile
export HIVE_HOME=/home/hive2.1
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/bin


开启Mysql远程访问

新建了账号 hive,密码 123456

方法见博客:http://blog.csdn.net/zengmingen/article/details/52330705



配置hive参数

进入conf文件:/home/hive2.1/conf。

里面全是配置文件。会看到几个.template的文件。

1、准备文件

执行命令:

cp hive-default.xml.template hive-default.xml
cp hive-env.sh.template  hive-env.sh
cp hive-exec-log4j2.properties.template  hive-exec-log4j2.properties
cp hive-log4j2.properties.template  hive-log4j2.properties
cp llap-cli-log4j2.properties.template  llap-cli-log4j2.properties
cp llap-daemon-log4j2.properties.template  llap-daemon-log4j2.properties

关键的hive-site.xml,该文件不能少,没有该文件会报错。

touch hive-site.xml

PS:hive-site.xml里面的配置会覆盖 hive-default.xml里面相同的配置。


2、配置hive-env.sh

配置如下:

export JAVA_HOME=/home/hadoop/app/jdk1.8.0_73export HIVE_HOME=/home/hive2.1export HADOOP_HOME=/home/hadoop/app/hadoop-2.7.2

3、配置hive-site.xml

创建临时文件:/home/hive2.1文件夹下创建tmp

[root@hello110 hive2.1]# mkdir tmp

配置Mysql的jdbc信息和hive资源临时目录

具体如下:

<?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://192.168.255.130:3306/hive_data?createDatabaseIfNotExist=true</value></property><property>        <name>javax.jdo.option.ConnectionDriverName</name>        <value>com.mysql.jdbc.Driver</value></property><property>        <name>javax.jdo.option.ConnectionUserName</name>        <value>hive</value></property><property>        <name>javax.jdo.option.ConnectionPassword</name>        <value>123456</value></property><property>            <name>hive.querylog.location</name>           <value>/home/hive2.1/tmp</value> </property>  <property>            <name>hive.exec.local.scratchdir</name>           <value>/home/hive2.1/tmp</value> </property> <property>         <name>hive.downloaded.resources.dir</name>           <value>/home/hive2.1/tmp</value> </property></configuration>

启动hadoop

用hadoop用户,命令:start-all.sh


修改hive主程序文件权限

因为hive要和hadoop通信,所以hadoop集群的用户hadoop要有hive文件访问的权限。

命令:

[root@hello110 home]# chown -R hadoop:hadoop hive2.1/

上传mysql驱动jar

上传到:/home/hive2.1/lib 下

http://dev.mysql.com/downloads/connector/j/ 下载
mysql-connector-java-5.1.39-bin.jar
注:

到官网下载最新的jar,版本过低,在使用一些命令的时候会报错:

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:For direct MetaStore DB connections, we don't support retries at the client level.)


初始化hive

命令:schematool -initSchema -dbType mysql

最后显示schemaTool completed。没有报错就是成功了。


访问Mysql检验

用Navicat for MySQL访问Mysql数据库。账号 hive。

hive根据hive-site.xml配置文件,生成了数据库:hive_data和一些表.






启动hive

输入命令:hive

[hadoop@hello110 ~]$ hive
which: no hbase in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hadoop/app/jdk1.8.0_73/bin:/home/hadoop/app/hadoop-2.7.2/bin:/home/hadoop/app/hadoop-2.7.2/sbin:/home/hive2.1/bin:/home/hadoop/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hive2.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/app/hadoop-2.7.2/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]


Logging initialized using configuration in file:/home/hive2.1/conf/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> 



------------配置完成----------


0 0
原创粉丝点击