問題1:當編譯通過後,運行時,會出現:
[html]
hadoop@springwater-Aspire-4743:/usr/local/hadoop/test$ ./test
Exception in thread "main" java.io.IOException: Mkdirs failed to create /my
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:378)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:364)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:555)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:536)
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
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:378)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:364)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:555)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:536)
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 env_reset
為:
Defaults !env_rese
問題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模式修改即可。