问题是如何为sqoop导入运行java程序?
我使用的是sqoop版本1.4.7和hadoop版本2.7.2,我正在尝试在net beans ide 8.1上运行以下代码:
package sqoop5;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import com.cloudera.sqoop.SqoopOptions;
import com.cloudera.sqoop.tool.BaseSqoopTool;
import com.cloudera.sqoop.tool.ImportTool;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Sqoop5 {
public static void main(String[] args) throws Exception {
String driver = "org.postgresql.Driver";
Class.forName(driver).newInstance();
SqoopOptions options = new SqoopOptions();
options.setConnectString(("jdbc:postgresql://
127.0.0.1:5432/postgres"));
options.setTableName(("new"));
options.setUsername(("postgres"));
options.setPassword(("********"));
options.setNumMappers(1);
options.setTargetDir(("hdfs://
127.0.0.1:9000/usr/new11"));
options.setFileLayout(com.cloudera.sqoop.
SqoopOptions.FileLayout.AvroD ataFile);
new ImportTool().run((com.cloudera.sqoop.SqoopOptions)
options);
}
}
错误消息如下:
cause:org.apache.hadoop.ipc.RemoteException: Server IPC
version 9
cannot communicate with client version 4
Aug 05, 2019 10:46:29 AM org.apache.sqoop.tool.ImportTool run
SEVERE: Encountered IOException running import job:
org.apache.hadoop.ipc.RemoteException: Server IPC version 9
cannot
communicate with client version 4
at org.apache.hadoop.ipc.Client.call(Client.java:1113)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:229)
at com.sun.proxy.$Proxy6.getProtocolVersion(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
1条答案
按热度按时间rqqzpn5f1#
如果你读了这篇文章,你会发现这和你的问题很相似。可能是应用程序之间的版本不匹配。检查所包含的hadoop版本与集群中的hadoop版本。