hdfs://localhost:9000
时间: 2023-04-26 10:00:51 浏览: 149
hdfs://localhost:900 是 Hadoop 分布式文件系统的默认地址,其中 localhost 表示本地主机,900 是默认的端口号。该地址用于访问 Hadoop 集群中的数据,可以通过该地址上传、下载、删除和管理文件。
相关问题
使用 Java API 对 HDFS 中的 hdfs://localhost:9000/total.csv 文件按照 gzip 格式压缩。压缩后的目录为:hdfs://localhost:9000/total.gz。
好的,我可以回答这个问题。你可以使用以下的 Java 代码将 HDFS 中的 total.csv 文件按照 gzip 格式进行压缩:
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
Path inputPath = new Path("hdfs://localhost:9000/total.csv");
Path outputPath = new Path("hdfs://localhost:9000/total.gz");
CompressionCodecFactory factory = new CompressionCodecFactory(conf);
CompressionCodec codec = factory.getCodec(outputPath);
if (codec == null) {
System.err.println("No codec found for " + outputPath);
System.exit(1);
}
OutputStream os = fs.create(outputPath);
GzipCodec gzipCodec = new GzipCodec();
gzipCodec.setConf(conf);
CompressionOutputStream cos = gzipCodec.createOutputStream(os);
InputStream is = fs.open(inputPath);
IOUtils.copyBytes(is, cos, conf);
is.close();
cos.close();
这段代码将会使用 Gzip 压缩格式对 total.csv 进行压缩,并将输出结果存储到 hdfs://localhost:9000/total.gz。
mkdir: `hdfs://localhost:9000/user/hadoop': No such file or directory
这个错误提示表明在 HDFS 文件系统中创建目录时出现了问题,可能是因为指定的父目录不存在。请先确认所需的父目录是否存在,如果不存在,请先创建父目录,然后再创建子目录。您可以使用以下命令创建目录:
```
hdfs dfs -mkdir -p hdfs://localhost:9000/user/hadoop
```
这将创建一个名为 `hadoop` 的用户目录。如果您需要创建其他目录,只需将上述命令中的路径更改为所需的路径即可。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)