通过ssh隧道将文件传入/传出hdfs

vktxenjb  于 2021-06-02  发布在  Hadoop
关注(0)|答案(3)|浏览(386)

有点复杂的设置:
我有以下结构

localhost --> bastion_host -> server -> hadoop_cluster

现在我可以创建一个ssh隧道,允许我从 localhost 以及 server . 一旦进入服务器,我可以随时使用 hadoop fs -put/get 将群集中的文件传输到群集中。但是这个星团除了在其他地方是看不见的 server 有没有一种方法可以使用现有的隧道将文件复制到集群中或从集群中复制出来?
我觉得我可以

ssh -p 2345 localhost "hadoop fs -put -/user/eron/test_file3" < testing_scp.txt

其中2345是隧道的本地端口,testing\u scp.txt是本地文件。
但我知道,
“sh:hadoop:未找到命令”
所以命令不会在上执行 server

cx6n0qe3

cx6n0qe31#

当您使用ssh服务器时,通过执行.bashrc、.profile等更新$path。当您使用隧道时,/usr/local/hadoop/bin不会添加到$path中
指定hadoop二进制路径应该可以:

ssh -p 2345 localhost "/usr/local/hadoop/bin/hadoop fs -put -/user/eron/test_file3" < testing_scp.txt
k2fxgqgv

k2fxgqgv2#

ssh -p 2345 localhost "hadoop fs -put -/user/eron/test_file3" < testing_scp.txt

放置前使用催眠素

4ioopgfo

4ioopgfo3#

很明显很晚了,但我在寻找同样的东西(尤其是提取),所以我想为我未来的自己记录下这一点:
根据其他答案,可以通过

ssh -p 2345 localhost \
   "/usr/local/hadoop/bin/hadoop fs -put - /user/eron/test_file3" \
   < testing_scp.txt

或者:

cat testing_scp.txt  | \ 
  ssh -p 2345 localhost "/usr/local/hadoop/bin/hadoop fs -put - /user/eron/test_file3

把它弄出来也差不多:

ssh -p 2345 localhost \
   "/usr/local/hadoop/bin/hadoop fs -cat /user/eron/test_file3" \
   > local_file.txt

相关问题