解決:Permission denied at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)


Permission denied at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)

Logging initialized using configuration in jar:file:/opt/hive/1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: Permission denied
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
Caused by: java.lang.RuntimeException: java.io.IOException: Permission denied
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:515)
        ... 7 more
Caused by: java.io.IOException: Permission denied
        at java.io.UnixFileSystem.createFileExclusively(Native Method)
        at java.io.File.createNewFile(File.java:1006)
        at java.io.File.createTempFile(File.java:1989)
        at org.apache.hadoop.hive.ql.session.SessionState.createTempFile(SessionState.java:818)
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:513)
        ... 7 more
myuser@namenode:/opt/hive/current/bin$

嘗試一:

myuser@namenode:~$ sudo hive
sudo: hive: command not found
#必須到執行文件路徑,sudo之后還必須指定下環境變量
myuser@namenode:/opt/hive/current/bin$ sudo source /etc/profile ; ./hive

參考
跟在crontab中執行代碼情況類似hive: command not found錯誤解決

嘗試二

把hive參數hive.exec.scratchdir 設置的目錄,一般為 /tmp/hive權限調整為777即可.即: chmod -R 777 /hive/tmp

<property>
  <name>hive.exec.scratchdir</name>
  <value>/hivetest/hive</value>
  <description>HDFS root scratch dir for Hive jobs which gets created with write all (733) permission. For each connecting user, an HDFS scratch dir: ${hive.exec.scratchdir}/&lt;username&gt; is created, with ${hive.scratch.dir.pe
  rmission}.</description>
</property>

發現已經是了

myuser@namenode:/opt/hive/current/bin$ hdfs dfs -ls  /hivetest/
17/04/26 15:17:09 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 1 items
drwxrwxrwx   - 777 hive          0 2017-01-10 15:44 /hivetest/hive

hive錯誤:Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Permission denied

嘗試三

修改用戶組

usermod -a -G hive  myuser
#檢查修改
myuser@namenode:/opt/hive/current/bin$ groups
myuser adm cdrom sudo dip plugdev lpadmin sambashare

myuser@namenode:/opt/hive/current/bin$ groups myuser
myuser : myuser adm cdrom sudo dip plugdev lpadmin sambashare hive

還是不行,報原來的錯誤。

嘗試四

切換用戶

myuser@namenode:/opt/hive/current/bin$ su hive
#密碼:123456
Password:
hive@namenode:/opt/hive/current/bin$

解決


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM