hive0.13的搭建配置

注意:hive是搭建在hadoop的基础上的,Hive 的数据存储在 HDFS 中,大部分的查询由 MapReduce 完成
因此,启动hive时,必须先启动hadoop的集群,还要启动metastore进程。
hive的安装
1.解压hive文件到你所创建的文件中

tar -zxvf hive-0.13.1-cdh5.3.6.tar.gz -C /opt/modules/



2.进入到hive下的conf目录下修改以下的文件
hive-default.xml.template
hive-exec-log4j.properties.template
hive-env.sh.template
hive-log4j.properties.template

修改为:
$ cp hive-default.xml.template hive-site.xml
$ cp hive-env.sh.template hive-env.sh
$ cp hive-exec-log4j.properties.template hive-exec-log4j.properties
$ cp hive-log4j.properties.template hive-log4j.properties



3.修改 hive-env.sh文件,添加jdk的环境变量

export JAVA_HOME=/opt/modules/jdk1.7.0_67





4.回到hive的目录下执行bin/hive程序
出现以下错误信息:
[Fatal Error] hive-site.xml:2787:3:
The element type "configuration" must
be terminated by the matching end-tag
"</configuration>".

原因是在conf/的目录下hive-site.xml

文件中2783-2784处缺少了‘<property>’


进入到hive-site.xml最后进行修改文件


5.再次执行bin/hive
describe docs; //查看hive中出现的表
describe extended docs;
describe formatted docs;

一.本地模式连接mysql
本地mysql作为metastore的模式
1.在hive-env.sh中添加hadoop的环境变量
HADOOP_HOME=.....

2.在hive-site.xml中修改以下内容
1) 在文件中的javax.jdo.option.ConnectionURL
添加 jdbc:mysql://localhost:3306/local_db?createDatabaseIfNotExist=true 连接本地数据库
2)在文件中找到javax.jdo.option.ConnectionDriverName
添加mysql的驱动 com.mysql.jdbc.Driver
3)在文件中javax.jdo.option.ConnectionUserName 添加上本地数据库的账号
javax.jdo.option.ConnectionPassword 添加本地数据库中的密码
4)最重要的是文件中的 hive.metastore.uris 若为空是本地模式 ,若不为空则是远程模式

3.保存配置后设置一下hive的环境变量
sudo vim /etc/profile下设置HIVE_HOME的环境变量,保存后 ,
执行source /etc/profiel 使其生效

4.到hive的目录下执行bin/hive 则出现一下问题:
Caused by: org.datanucleus.exceptions.NucleusException: Attempt to invoke the "BoneCP" plugin to create a ConnectionPool gave an error : The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH. Please check your CLASSPATH specification,
and the name of the driver.
则是因为连接mysql吗,没有相对应的驱动类的jar包,把对应的jar包放入到/hive/lib/下

5.再次执行/bin/hive 就可以了

二.远程模式连接
1.在hive-site.xml文件中填写 hive.metastore.uris 的值
填写为thrift://ibiefeng.tanjian.com:9083
例如:
thrift://主机名:端口号

2.修改 文件中 javax.jdo.option.ConnectionURL 连接数据库所在的主机名
修改为 jdbc:mysql://ibeifeng02.tanjian.com:3306/remote_db?createDatabaseIfNotExist=true

3.保存文件退出后,在hive的文件下启动bin/hive,则会报以下的问题
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient

4.这是因为metastore 的进程没有启动,因此需要启动
nohup hive --service metastore > hive_metastore.run.log 2>&1 &
停止metastore,没有相应的停止命令,因此,只能kill -9 进程id

5.查看metastore 进程启动情况
ps -ef | grep HiveMetaStore

6.现在就可以执行bin/hive,进入到hive中


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值