- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我找到了一种通过 hftp
连接到 hadoop 的方法,它工作正常,(只读):
uri = "hftp://172.16.xxx.xxx:50070/";
System.out.println( "uri: " + uri );
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get( URI.create( uri ), conf );
fs.printStatistics();
但是,我想读/写以及复制文件,也就是说,我想通过 hdfs 连接。如何启用 hdfs 连接以便我可以编辑实际的远程文件系统?
我试图从 hftp
-> hdfs
更改上面的协议(protocol),但出现以下异常 ...
(请原谅我对 url 协议(protocol)和 hadoop 的了解不足,我认为这是我问的一个有点奇怪的问题,但我们将不胜感激任何帮助!)
Exception in thread "main" java.io.IOException: Call to /172.16.112.131:50070 failed on local exception: java.io.EOFException at org.apache.hadoop.ipc.Client.wrapException(Client.java:1139) at org.apache.hadoop.ipc.Client.call(Client.java:1107) at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:226) at $Proxy0.getProtocolVersion(Unknown Source) at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:398) at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:384) at org.apache.hadoop.hdfs.DFSClient.createRPCNamenode(DFSClient.java:111) at org.apache.hadoop.hdfs.DFSClient.(DFSClient.java:213) at org.apache.hadoop.hdfs.DFSClient.(DFSClient.java:180) at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:89) at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1514) at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:67) at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:1548) at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1530) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:228) at sb.HadoopRemote.main(HadoopRemote.java:24)
最佳答案
把你要打的hadoop的core-site.xml
和hdfs-site.xml
加到conf
里就行了像这样:
import java.net.URI;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.testng.annotations.Test;
/**
* @author karan
*
*/
public class HadoopPushTester {
@Test
public void run() throws Exception {
Configuration conf = new Configuration();
conf.addResource(new Path("src/test/resources/HadoopConfs/core-site.xml"));
conf.addResource(new Path("src/test/resources/HadoopConfs/hdfs-site.xml"));
String dirName = "hdfs://hosthdfs:port/user/testJava";
// Values of hosthdfs:port can be found in the core-site.xml in the fs.default.name
FileSystem fileSystem = FileSystem.get(conf);
Path path = new Path(dirName);
if (fileSystem.exists(path)) {
System.out.println("Dir " + dirName + " already exists");
return;
}
// Create directories
fileSystem.mkdirs(path);
fileSystem.close();
}
}
关于ssh - 如何通过 java 的 hdfs 协议(protocol)访问 hadoop?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7844458/
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 10年前关闭。 Improve this qu
我错误地设置了 ssh key 的密码。 但是每次使用 key 时都要输入密码很烦人。 我想删除我的 key 的密码: $ ssh-keygen -p -f 但是,我担心 key 会被更改。 由于我
你好!我在连接到远程主机时遇到问题。我忘记了 ssh 密码,但我有 SSH key 的指纹。是否可以仅使用指纹进行连接? 最佳答案 不会。机器的指纹仅用于验证您正在连接您认为正在连接的机器。它是用于避
我有一个 Ubuntu 服务器 example.com 并且我已经通过 ssh 进入了它。但只有在我通过 ssh 进入它之后,我才意识到我打算执行 ssh -L 8000:localhost:9000
通过终端,我可以多次 SSH 连接到服务器: (客户端--->网关--->服务器1---->服务器2---) 但是现在要通过Java的JSch库来实现,怎么办呢?首先尝试了端口转发,但在终端上我没有这
在创建一个新的仓库(本地 + 远程)之后,我正在尝试推送提交。但是我遇到了 SSH key 的问题 在我的 ~/.ssh/config 中,我有一个 gitlab 条目定义为 Host MyRepoJ
我发现 ssh 和 ssh-keygen 有一种奇怪的行为:它们根本没有反应。 Cygwin 以管理员权限启动并正常运行。主机 192.168.1.1 已启动,我可以远程桌面到它: 当我尝试时: $
为什么eval语句返回 Illegal variable name $ eval "$(ssh-agent -s)" Illegal variable name. 最佳答案 请尝试$ eval "ss
我正在尝试通过以下命令从我的本地主机连接到远程主机。但是远程主机中有一个设置,我们登录后不久它会提示输入徽章 ID、密码和登录原因,因为它在 profile 中是这样编码的文件在 remote-hos
有时,我被迫在不稳定的互联网连接上使用 ssh。 ping some.doma.in PING some.doma.in (x.x.x.x): 56 data bytes Request timeou
This thread is a response to the titled question : Why ssh-agent doesn't forward my SSH certificate
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
因此,我在10.10.10.x子网中有一堆机器,基本上所有这些机器都以相同的方式配置。我将这些与我的10.10.11.x子网中的计算机区分开,后者具有不同的用途。 我希望能够输入“ssh 10.x”以
我不想在 vagrant box 上创建新的 SSH key 对,而是想重新使用主机上的 key 对,使用 agent forwarding 。我尝试过设置 config.ssh.forward_ag
我有一台服务器,可以通过ssh通过pubkey身份验证通过ssh访问: ssh "Host" -l "my identity" 这很好。但是,我无法在一个命令中使用我的私钥进行端口重定向和标识(这是我
创建一对 key 并通过 ssh-copy-id 将公钥发送到服务器后,我仍然无法在没有密码的情况下登录 ssh -v user@host 的输出 debug1:在/home/pumba/.ssh/k
我被困在 Permission denied (publickey) hell 中,试图将公钥复制到远程服务器,以便 Jenkins 可以在构建期间同步文件。 运行: sudo ssh-copy-id
我正在尝试通过我大学的代理服务器ssh到我们实验室的服务器之一。我们的目标是使用paramiko使其自动化,但我试图首先了解终端机级别中正在发生的事情。 我试过了 ssh -o ProxyComman
我在说明问题上有问题,我想通过SSH切换到我的Cisco交换机,但是我遇到了一些麻烦 我写了两个脚本, 有了这个我没有任何问题,我可以通过运行脚本并输入用户名和密码来更改默认网关: from Exsc
每个人 我目前正在使用一个集群,并且会经常使用“ssh”连接到它。有时我需要打开多个终端。因此,每次需要连接时,我都必须输入“ssh username@cluster.com”,然后输入“密码”(我在
我是一名优秀的程序员,十分优秀!