window-docker-hadoop伪单机 compose部署 配合springboot使用
本机环境 win11 + window docker (wsl2装的) + hadoop3.2.1
github链接:GitHub - big-data-europe/docker-hadoop: Apache Hadoop docker image
参考这个大佬的连接
下载到window之后
docker-compose up 安装
完成之后的图片
访问
http://localhost:9870/explorer.html#/
http://localhost:8088/cluster
可以打开就证明没有问题,端口暴露没事
这个时候进行正常的查询 和创建目录是没有问题的
重点来了
当你使用springboot 作为客户端进行访问 springboot 肯定是在window
会出现一个错误
org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /testA could only be written to 0 of the 1 minReplication nodes. There are 1 datanode(s) running and 1 node(s) are excluded in this operation.
这个错误表示 datanode节点无法进行访问
因为他访问的是
Connecting to datanode 172.18.0.5:9866
这行代码在控制台会输出的,或者报错
这个ip其实是docker内部网络的ip, 你在window环境是无法ping通的 所以肯定访问不了
下面是idea 的代码
public class hdfst