问题1:当编译通过后,运行时,会出现:
[html]
hadoop@springwater-Aspire-4743:/usr/local/hadoop/test$
./test
Exception in thread "main" java.io.IOException: Mkdirs failed to
create /my
Call to
org.apache.hadoop.conf.FileSystem::create((Lorg/apache/hadoop/fs/Path;ZISJ)Lorg/apache/hadoop/fs/FSDataOutputStream;)
failed!
Failed to open /my/t.txt for writing!
hadoop@springwater-Aspire-4743:/usr/local/hadoop/test$ ./test
Exception in thread "main" java.io.IOException: Mkdirs failed to
create /my
Call to
org.apache.hadoop.conf.FileSystem::create((Lorg/apache/hadoop/fs/Path;ZISJ)Lorg/apache/hadoop/fs/FSDataOutputStream;)
failed!
Failed to open /my/t.txt for writing!
原因分析,读写权限不够。
解决方法:
sudo ./test
可是又有新的问题:
[html]
hadoop@springwater-Aspire-4743:/usr/local/hadoop/test$ sudo
./test
Environment variable CLASSPATH not set!
Environment variable CLASSPATH not set!
Failed to open /my/t.txt for writing!
hadoop@springwater-Aspire-4743:/usr/local/hadoop/test$ sudo
./test
Environment variable CLASSPATH not set!
Environment variable CLASSPATH not set!
Failed to open /my/t.txt for writing!
问题2: sudo env发现 我在~/.bashrc中定义的环境变量CLASSPATH没有被sudo继承。
所以sudo ./test会显示CLASSPATH没有定义
在/etc/sudoers中修改:
Defaults
为:
Defaults
问题3:当我sudo chmod 777 /etc/sudoers,修改之后,
再 sudo chmod 777 /etc/sudoers发生错误:
[html]
springwater@springwater-Aspire-4743:/etc$ sudo chmod 440
sudoers
sudo: /etc/sudoers 的模式为 0777,应为 0440
sudo: 没有找到有效的 sudoers 资源,退出
sudo: 无法初始化策略插件
springwater@springwater-Aspire-4743:/etc$ sudo chmod 440
sudoers
sudo: /etc/sudoers 的模式为 0777,应为 0440
sudo: 没有找到有效的 sudoers 资源,退出
sudo: 无法初始化策略插件
解决方法:
su root
进入root模式修改即可。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23177705/viewspace-1119809/ ,如需转载,请注明出处,否则将追究法律责任。