海豚dolphinscheduler-shell 执行hivesql任务 Permission denied 异常

一、dolphinscheduler 执行shell处理hsql任务时出现没有访问权限

关键异常:

/tmp/dolphinscheduler/hive.log (Permission denied) java.io.FileNotFoundException: /tmp/dolphinscheduler/hive.log (Permission denied)

异常明细:

[INFO] 2023-04-20 11:09:03.350  - [taskAppId=TASK-43-815-3377]:[129] -  -> 2023-04-20 11:09:02,670 main ERROR Cannot access RandomAccessFile java.io.FileNotFoundException: /tmp/dolphinscheduler/hive.log (Permission denied) java.io.FileNotFoundException: /tmp/dolphinscheduler/hive.log (Permission denied)
		at java.io.RandomAccessFile.open0(Native Method)
		at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
		at java.io.RandomAccessFile.(RandomAccessFile.java:243)
		at java.io.RandomAccessFile.(RandomAccessFile.java:124)
		at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory.createManager(RollingRandomAccessFileManager.java:180)
		at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory.createManager(RollingRandomAccessFileManager.java:156)
		at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:112)
		at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
		at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.getRollingRandomAccessFileManager(RollingRandomAccessFileManager.java:87)
		at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender$Builder.build(RollingRandomAccessFileAppender.java:116)
		at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender$Builder.build(RollingRandomAccessFileAppender.java:52)
		at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:952)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:892)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:884)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:508)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:232)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:244)
		at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
		at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
		at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:239)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:159)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:131)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:101)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:188)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jDefault(LogUtils.java:176)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:109)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:101)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4j(LogUtils.java:84)
		at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:717)
		at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:701)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at org.apache.hadoop.util.RunJar.run(RunJar.java:313)
		at org.apache.hadoop.util.RunJar.main(RunJar.java:227)
	
	2023-04-20 11:09:02,674 main ERROR Unable to inject fields into builder class for plugin type class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender, element RollingRandomAccessFile. java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$RollingRandomAccessFileManagerFactory@f627d13] unable to create manager for [/tmp/dolphinscheduler/hive.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager$FactoryData@4e928fbf]
		at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:114)
		at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
		at org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager.getRollingRandomAccessFileManager(RollingRandomAccessFileManager.java:87)
		at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender$Builder.build(RollingRandomAccessFileAppender.java:116)
		at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender$Builder.build(RollingRandomAccessFileAppender.java:52)
		at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:952)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:892)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:884)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:508)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:232)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:244)
		at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
		at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
		at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:239)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:159)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:131)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:101)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:188)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jDefault(LogUtils.java:176)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:109)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:101)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4j(LogUtils.java:84)
		at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:717)
		at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:701)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at org.apache.hadoop.util.RunJar.run(RunJar.java:313)
		at org.apache.hadoop.util.RunJar.main(RunJar.java:227)
	
	2023-04-20 11:09:02,675 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile. java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender
		at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:224)
		at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:130)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:952)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:892)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:884)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:508)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:232)
		at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:244)
		at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
		at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
		at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:239)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:159)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:131)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:101)
		at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:188)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jDefault(LogUtils.java:176)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:109)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:101)
		at org.apache.hadoop.hive.common.LogUtils.initHiveLog4j(LogUtils.java:84)
		at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:717)
		at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:701)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at org.apache.hadoop.util.RunJar.run(RunJar.java:313)
		at org.apache.hadoop.util.RunJar.main(RunJar.java:227)
	
	2023-04-20 11:09:02,676 main ERROR Null object returned for RollingRandomAccessFile in Appenders.
	2023-04-20 11:09:02,676 main ERROR Unable to locate appender "DRFA" for logger config "root"
[INFO] 2023-04-20 11:09:04.178  - [taskAppId=TASK-43-815-3377]:[217] - process has exited, execute path:/tmp/dolphinscheduler/exec/process/5/43/815/3377, processId:23896 ,exitStatusCode:0
[INFO] 2023-04-20 11:09:04.352  - [taskAppId=TASK-43-815-3377]:[129] -  -> 23/04/20 11:09:03 INFO session.SessionState: Created HDFS directory: /tmp/hive/dolphinscheduler/82a46c9d-de6c-45fb-ac3b-9c6bdeba6569
	23/04/20 11:09:03 INFO session.SessionState: Created local directory: /tmp/dolphinscheduler/82a46c9d-de6c-45fb-ac3b-9c6bdeba6569
	23/04/20 11:09:03 INFO session.SessionState: Created HDFS directory: /tmp/hive/dolphinscheduler/82a46c9d-de6c-45fb-ac3b-9c6bdeba6569/_tmp_space.db
	Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Permission denied
		at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:582)
		at org.apache.hadoop.hive.ql.session.SessionState.beginStart(SessionState.java:540)
		at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:765)
		at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:701)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at org.apache.hadoop.util.RunJar.run(RunJar.java:313)
		at org.apache.hadoop.util.RunJar.main(RunJar.java:227)
	Caused by: java.io.IOException: Permission denied
		at java.io.UnixFileSystem.createFileExclusively(Native Method)
		at java.io.File.createTempFile(File.java:2024)
		at org.apache.hadoop.hive.common.FileUtils.createTempFile(FileUtils.java:821)
		at org.apache.hadoop.hive.ql.session.SessionState.createTempFile(SessionState.java:960)
		at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:580)
		... 9 more

二、解决方法

每一个节点执行如下操作:
touch -p /tmp/dolphinscheduler/hive.log
groupadd supergroup
usermod -a -G supergroup dolphinscheduler
sudo -u hdfs hdfs dfsadmin -refreshUserToGroupsMappings
chown -R dolphinscheduler:dolphinscheduler /tmp/dolphinscheduler


 

你可能感兴趣的:(log4j,apache,java)