C程序访问hadoop运行时遇到的各种问题以及解决方案
问题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模式修改即可。
补充:软件开发 , C语言 ,