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/$%7Bsystem:user.name%7D

java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D

Caused by: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D

at java.net.URI.checkPath(URI.java:1823)

at java.net.URI.<init>(URI.java:745)

at org.apache.hadoop.fs.Path.initialize(Path.java:203)

… 10 more

解决方法:

错误原因是${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D at org.apache.hadoop.fs.Path.initialize(Path.java:203)路径问题,只要在 hive-site.xml 文件中把所有的 system:java.io.tmpdir 相对路径改成绝对路径就行

具体步骤:

step1:在修改 hive-site.xml 前,先创建 tmp 目录

进入到hive的安装目录下,本文是进入到  /opt/modules/hive/apache-hive-1.2.2-bin

输入     mkdir   tmp            存储临时文件

step2:进入到 /apache-hive-1.2.2-bin/conf 目录下,修改 hive-site.xml 文件

输入   vim    hive-site.xml        编辑 hive-site.xml  文件

搜索 system:java.io.tmpdir ,输入  /system:java.io.tmpdir  进行搜索

可定位到多处含有 system:java.io.tmpdir 的地方(搜索功能按小写 n可切换到下一处;按小写 N 可切换到上一处)

输入 i 键 进入编辑模式

将 system:java.io.tmpdir 全部替换成 /opt/modules/hive/apache-hive-1.2.2-bin/tmp(这个是我存放临时文件的路径,替换成你所创建的)

《Hive | Hive 启动和操作出错》

输入 Esc 键 退出编辑模式,输入 :wq   保存并退出

问题二:hive启动时出错

org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hdfs.server.namenode.

SafeModeException): Cannot create directory /opt/modules/hive/apache-hive-1.2.2-bin/tmp/hadoop/b71fd2fc-cfb2-43c7-b3af-8d26f44ab7de.

Name node is in safe mode.

解决方法:

强制关闭安全模式

输入   hdfs dfsadmin -safemode leave

问题三:hive 在进行 show databases;操作出错

Failed with exception java.io.IOException:org.apache.hadoop.mapred.InvalidInputException: Input Pattern file:/opt/modules/hive/apache-hive-1.2.2-bin/tmp/${system:user.name}/15f626c2-2f99-4f28-8f69-75a2b0d6c33e/hive_2019-02-20_21-43-47_090_109741767523421454-1/-local-10000 matches 0 files

解决方法:

修改 /apache-hive-1.2.2-bin/conf/hive-site.xml 文件,将 hive.exec.local.scratchdir 配置中的 ${system:user.name} 替换成 ${user.name}

具体步骤:

进入到 /apache-hive-1.2.2-bin/conf 目录下,修改 hive-site.xml 文件

输入   vim    hive-site.xml      编辑 hive-site.xml  文件

搜索 hive.exec.local.scratchdir ,输入  /hive.exec.local.scratchdir   进行搜索

输入 i 键 进入编辑模式

将 ${system:user.name} 替换成 ${user.name}

<property>

    <name>hive.exec.local.scratchdir</name>

    <value>/opt/modules/hive/apache-hive-1.2.2-bin/tmp/${system:user.name}</value>

     <description>Local scratch space for Hive jobs</description>

</property>

改成:

<property>

    <name>hive.exec.local.scratchdir</name>

    <value>/opt/modules/hive/apache-hive-1.2.2-bin/tmp/${user.name}</value>

    <description>Local scratch space for Hive jobs</description>

  </property>

输入 Esc 键 退出编辑模式,输入 :wq   保存并退出

问题四:hive执行查询操作,报错

Failed with exception java.io.IOException:org.apache.hadoop.hdfs.

BlockMissingException: Could not obtain block: BP-1233369067-192.168.100.10-1535649785847:blk_1073741845_1021 file=/opt/modules/hive/apache-hive-1.2.2-bin/warehouse/testdb.db/t3_user_partition/provice=beijing/user_info.txt

解决方法:

说明 datanode 可能断掉了,或者通信有问题。

重启 hdfs 和 yarn

step1:查看目前 hdfs 和 yarn 的启动情况

输入   jps

《Hive | Hive 启动和操作出错》

从上图可看到,datanode 木有掉了,所以重启一下 hdfs 和 yarn

step2: 先停止 hdfs 和 yarn

输入      stop-all.sh       

或者分别输入        stop-dfs.sh        stop-yarn.sh

《Hive | Hive 启动和操作出错》

step3:再启动 hdfs 和 yarn

输入 start-all.sh

或是分别输入         start-dfs.sh        start-yarn.sh

《Hive | Hive 启动和操作出错》

参考链接:

https://www.cnblogs.com/zlslch/p/6028069.html

http://blog.csdn.net/jim110/article/details/44907745

https://www.cnblogs.com/0xcafedaddy/p/8250372.html

    原文作者:Ada54
    原文地址: https://www.jianshu.com/p/5716fe32ed17
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞