spark学习2-1(hive1.2安装)

浏览: 1083

由于前面安装版本过老,导致学习过程中出现了很多问题,今天安装了一个新一点的版本。安装结束启动时遇到一点问题,记录在这里。

第一步:hive-1.2安装

通过WinSCP将apache-hive-1.2.1-bin.tar.gz上传到/usr/hive/目录下

[root@spark1 hive]# chmod u+x apache-hive-1.2.1-bin.tar.gz  #增加执行权限

[root@spark1 hive]# tar -zxvf apache-hive-1.2.1-bin.tar.gz #解压
[root@spark1 hive]# mv apache-hive-1.2.1-bin hive-1.2
[root@spark1 hive]# vi /etc/profile #配置环境变量
export HIVE_HOME=/usr/hive/hive-1.2
export PATH=$HIVE_HOME/bin

[root@spark1 hive]# source /etc/profile #是环境变量生效
[root@spark1 hive]# which hive #查看安装路径

第二步:安装mysql

[root@spark1 hive]# yum install -y mysql-server #下载安装
[root@spark1 hive]# service mysqld start #启动mysql
[root@spark1 hive]# chkconfig mysqld on #设置开机自动启动
[root@spark1 hive]# yum install -y mysql-connector-java #yum安装mysql connector
[root@spark1 hive]# cp /usr/share/java/mysql-connector-java-5.1.17.jar /usr/hive/hive-0.13/lib #拷贝到hive中的lib目录下

第三步:在mysql上创建hive元数据库,并对hive进行授权

mysql> create database if not exists hive_metadata;
mysql> grant all privileges on hive_metadata.* to 'hive'@'%' identified by 'hive';
mysql> grant all privileges on hive_metadata.* to 'hive'@'localhost' identified by 'hive';
mysql> grant all privileges on hive_metadata.* to 'hive'@'spark1' identified by 'hive';
mysql> flush privileges;
mysql> use hive_metadata;
mysql> exit

第四步:配置文件

[root@spark1 hive]# cd /usr/hive/hive-1.2/conf #进入到conf目录
[root@spark1 conf]# mv hive-default.xml.template hive-site.xml #重命名
[root@spark1 conf]# vi hive-site.xml


javax.jdo.option.ConnectionURL
jdbc:mysql://spark1:3306/hive_metadata?createDatabaseIfNotExist=true
JDBC connect string for a JDBC metastore



javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
Driver class name for a JDBC metastore



javax.jdo.option.ConnectionUserName
hive
username to use against metastore database



javax.jdo.option.ConnectionPassword
hive
password to use against metastore database



hive.metastore.warehouse.dir
/user/hive/warehouse
location of default database for the warehouse
[root@spark1 conf]# mv hive-env.sh.template hive-env.sh #重命名

[root@spark1 ~]# vi /usr/hive/hive-1.2/bin/hive-config.sh #加入java、hive、hadoop 路径
export JAVA_HOME=/usr/java/jdk1.8
export HIVE_HOME=/usr/hive/hive-1.2
export HADOOP_HOME=/usr/hadoop/hadoop-2.6.0

[hadoop@spark1 hive]$ cd hive-1.2
[hadoop@spark1 hive-1.2]$ hive #进入hive开始使用

测试hive
hive> hive;
启动报错
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: {system:java.io.tmpdir%7D/{system:java.io.tmpdir%7D/%7Bsystem:user.name%7D

启动hive-1.2报错1

Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: {system:java.io.tmpdir%7D/{system:java.io.tmpdir%7D/%7Bsystem:user.name%7D

解决办法
将hive-site.xml中三个含有system:java.io.tmpdir配置项的值修改为 $HIVE_HOME/iotmp 即:
/usr/hive/hive-1.2/iotmp



hive.exec.local.scratchdir
/usr/hive/hive-1.2/iotmp
Local scratch space for Hive jobs




hive.downloaded.resources.dir
/usr/hive/hive-1.2/iotmp
Temporary local directory for added resources in the remote file system.




hive.downloaded.resources.dir
/usr/hive/hive-1.2/iotmp
Temporary local directory for added resources in the remote file system.

搞定1之后报错2

[ERROR] Terminal initialization failed; falling back to unsupported

原因是hadoop目录下存在老版本jline:
/usr/hadoop/hadoop-2.6.0/share/hadoop/yarn/lib/jline-0.9.94.jar

解决方法:
将hive目录/usr/hive/hive-1.2/lib下的新版本jline的JAR包拷贝到hadoop下:

cp jline-2.12.jar /usr/hadoop/hadoop-2.6.0/share/hadoop/yarn/lib

结果如下图

image.png

推荐 0
本文由 邬家栋 创作,采用 知识共享署名-相同方式共享 3.0 中国大陆许可协议 进行许可。
转载、引用前需联系作者,并署名作者且注明文章出处。
本站文章版权归原作者及原出处所有 。内容为作者个人观点, 并不代表本站赞同其观点和对其真实性负责。本站是一个个人学习交流的平台,并不用于任何商业目的,如果有任何问题,请及时联系我们,我们将根据著作权人的要求,立即更正或者删除有关内容。本站拥有对此声明的最终解释权。

0 个评论

要回复文章请先登录注册