首先hadoop2以后 命令有所变化 启动hdfs服务后
建立文件夹应该使用dfs
例如 hdfs dfs -mkdir /filename
其次需要在文件前加 / 代表建立在根目录,也可以加其他目录 ,比如 、/usr/local/
不加 / 会报错
mkdir
Usage: hadoop fs -mkdir [-p]
Takes path uri’s as argument and creates directories.
Options:
The -p option behavior is much like Unix mkdir -p, creating parent directories along the path.
Example:
hadoop fs -mkdir /user/hadoop/dir1 /user/hadoop/dir2
hadoop fs -mkdir hdfs://nn1.example.com/user/hadoop/dir hdfs://nn2.example.com/user/hadoop/dir
Exit Code:
Returns 0 on success and -1 on error.