gpt4 book ai didi

java - 无法在远程HBase表中插入记录

转载 作者:行者123 更新时间:2023-12-02 21:37:01 26 4
gpt4 key购买 nike

我试图在htable中插入一条记录。该程序没有结束,但是在打印111之后挂起。请帮助。

public static void insert(){
org.apache.hadoop.conf.Configuration config = HBaseConfiguration.create();
HTable table = null;
try{
config.set("hbase.zookeeper.quorum","ip_address_of_remotemachine");
config.set("hbase.zookeeper.property.clientPort","2181");
config.set("hbase.master", "hdfs://remote_ip:2181/hbase");
table = new HTable(config, "table_A");
Put p = new Put(Bytes.toBytes("1"));
p.add(Bytes.toBytes("Col"), Bytes.toBytes("ColFamily1"), Bytes.toBytes("Test123"));
System.out.println("111");
table.put(p);
System.out.println("222");
table.setAutoFlush(true);
}
catch(IOException ee){
ee.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
finally{
try {
if(table != null)
table.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

我得到的输出为

15/07/20 14:28:33 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 15/07/20 14:28:33 INFO zookeeper.RecoverableZooKeeper: Process identifier=hconnection-0x6a79d589 connecting to ZooKeeper ensemble=100.101.102.103:2181 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.5-mapr-1503--1, built on 03/26/2015 18:33 GMT 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:host.name=localhost 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:java.version=1.7.0_79 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:java.home=/usr/local/java/jdk1.7.0_79/jre 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:java.class.path=/usr/local/MyWorks/Flow1/test/target/classes:/usr/local/testDep/activation-1.1.jar:/usr/local/testDep/aopalliance-1.0.jar:/usr/local/testDep/apacheds-i18n-2.0.0-M15.jar:/usr/local/testDep/apacheds-kerberos-codec-2.0.0-M15.jar:/usr/local/testDep/api-asn1-api-1.0.0-M20.jar:/usr/local/testDep/api-util-1.0.0-M20.jar:/usr/local/testDep/asm-3.1.jar:/usr/local/testDep/avro-1.7.4.jar:/usr/local/testDep/commons-beanutils-1.7.0.jar:/usr/local/testDep/commons-beanutils-core-1.8.0.jar:/usr/local/testDep/commons-cli-1.2.jar:/usr/local/testDep/commons-codec-1.7.jar:/usr/local/testDep/commons-collections-3.2.1.jar:/usr/local/testDep/commons-compress-1.4.1.jar:/usr/local/testDep/commons-configuration-1.6.jar:/usr/local/testDep/commons-daemon-1.0.13.jar:/usr/local/testDep/commons-digester-1.8.jar:/usr/local/testDep/commons-el-1.0.jar:/usr/local/testDep/commons-httpclient-3.1.jar:/usr/local/testDep/commons-io-2.4.jar:/usr/local/testDep/commons-lang-2.6.jar:/usr/local/testDep/commons-logging-1.1.1.jar:/usr/local/testDep/commons-math3-3.1.1.jar:/usr/local/testDep/commons-math-2.1.jar:/usr/local/testDep/commons-net-3.1.jar:/usr/local/testDep/findbugs-annotations-1.3.9-1.jar:/usr/local/testDep/guava-12.0.1.jar:/usr/local/testDep/guice-3.0.jar:/usr/local/testDep/guice-servlet-3.0.jar:/usr/local/testDep/hamcrest-core-1.3.jar:/usr/local/testDep/hbase-annotations-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-checkstyle-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-client-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-common-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-common-0.98.9-mapr-1503-tests.jar:/usr/local/testDep/hbase-examples-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-hadoop2-compat-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-hadoop-compat-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-it-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-it-0.98.9-mapr-1503-tests.jar:/usr/local/testDep/hbase-prefix-tree-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-protocol-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-rest-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-server-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-server-0.98.9-mapr-1503-tests.jar:/usr/local/testDep/hbase-shell-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-testing-util-0.98.9-mapr-1503.jar:/usr/local/testDep/hbase-thrift-0.98.9-mapr-1503.jar:/usr/local/testDep/high-scale-lib-1.1.1.jar:/usr/local/testDep/htrace-core-2.04.jar:/usr/local/testDep/httpclient-4.2.5.jar:/usr/local/testDep/httpcore-4.1.3.jar:/usr/local/testDep/jackson-core-asl-1.8.8.jar:/usr/local/testDep/jackson-jaxrs-1.8.8.jar:/usr/local/testDep/jackson-mapper-asl-1.8.8.jar:/usr/local/testDep/jackson-xc-1.8.8.jar:/usr/local/testDep/jamon-runtime-2.3.1.jar:/usr/local/testDep/jasper-compiler-5.5.23.jar:/usr/local/testDep/jasper-runtime-5.5.23.jar:/usr/local/testDep/javax.inject-1.jar:/usr/local/testDep/java-xmlbuilder-0.4.jar:/usr/local/testDep/jaxb-api-2.2.2.jar:/usr/local/testDep/jaxb-impl-2.2.3-1.jar:/usr/local/testDep/jcodings-1.0.8.jar:/usr/local/testDep/jersey-client-1.9.jar:/usr/local/testDep/jersey-core-1.8.jar:/usr/local/testDep/jersey-guice-1.9.jar:/usr/local/testDep/jersey-json-1.8.jar:/usr/local/testDep/jersey-server-1.8.jar:/usr/local/testDep/jets3t-0.9.0.jar:/usr/local/testDep/jettison-1.3.1.jar:/usr/local/testDep/jetty-6.1.26.jar:/usr/local/testDep/jetty-sslengine-6.1.26.jar:/usr/local/testDep/jetty-util-6.1.26.jar:/usr/local/testDep/joni-2.1.2.jar:/usr/local/testDep/jruby-complete-1.6.8.jar:/usr/local/testDep/jsch-0.1.42.jar:/usr/local/testDep/jsp-2.1-6.1.14.jar:/usr/local/testDep/jsp-api-2.1-6.1.14.jar:/usr/local/testDep/jsr305-1.3.9.jar:/usr/local/testDep/junit-4.11.jar:/usr/local/testDep/leveldbjni-all-1.8.jar:/usr/local/testDep/libthrift-0.9.0.jar:/usr/local/testDep/log4j-1.2.17.jar:/usr/local/testDep/metrics-core-2.2.0.jar:/usr/local/testDep/netty-3.6.6.Final.jar:/usr/local/testDep/paranamer-2.3.jar:/usr/local/testDep/servlet-api-2.5.jar:/usr/local/testDep/servlet-api-2.5-6.1.14.jar:/usr/local/testDep/snappy-java-1.0.4.1.jar:/usr/local/testDep/xmlenc-0.52.jar:/usr/local/testDep/xz-1.0.jar:/usr/local/testDep/hadoop-annotations-2.0.5-alpha.jar:/usr/local/testDep/hadoop-annotations-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-auth-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-client-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-common-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-common-2.4.1-mapr-1408-tests.jar:/usr/local/testDep/hadoop-core-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-hdfs-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-hdfs-2.4.1-mapr-1408-tests.jar:/usr/local/testDep/hadoop-mapreduce-client-app-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-mapreduce-client-common-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-mapreduce-client-core-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-mapreduce-client-hs-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-mapreduce-client-jobclient-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-mapreduce-client-jobclient-2.4.1-mapr-1408-tests.jar:/usr/local/testDep/hadoop-mapreduce-client-shuffle-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-minicluster-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-test-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-yarn-api-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-yarn-client-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-yarn-common-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-yarn-server-applicationhistoryservice-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-yarn-server-common-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-yarn-server-nodemanager-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-yarn-server-resourcemanager-2.4.1-mapr-1408.jar:/usr/local/testDep/hadoop-yarn-server-tests-2.4.1-mapr-1408-tests.jar:/usr/local/testDep/hadoop-yarn-server-web-proxy-2.4.1-mapr-1408.jar:/usr/local/testDep/zookeeper-3.4.5-mapr-1503.jar:/usr/local/testDep/hbase-utils-4.1.0-mapr.jar:/usr/local/testDep/hibernate-c3p0-3.3.1.GA.jar:/usr/local/testDep/hibernate-commons-annotations-3.2.0.Final.jar:/usr/local/testDep/hibernate-core-3.6.8.Final.jar:/usr/local/testDep/httpclient-4.2.jar:/usr/local/testDep/httpclient-cache-4.2.jar:/usr/local/testDep/httpcore-4.2.jar:/usr/local/testDep/jasper-compiler-5.5.12.jar:/usr/local/testDep/jasper-runtime-5.5.12.jar:/usr/local/testDep/javassist-3.12.1.GA.jar:/usr/local/testDep/jetty-plus-6.1.26.jar:/usr/local/testDep/jobmngmnt-4.1.0-mapr.jar:/usr/local/testDep/joda-time-2.0.jar:/usr/local/testDep/JPam-1.1.jar:/usr/local/testDep/json-20080701.jar:/usr/local/testDep/jsp-2.1.jar:/usr/local/testDep/jsp-api-2.1.jar:/usr/local/testDep/jta-1.1.jar:/usr/local/testDep/junit-3.8.1.jar:/usr/local/testDep/junit-4.5.jar:/usr/local/testDep/kvstore-4.1.0-mapr.jar:/usr/local/testDep/libprotodefs-4.1.0-mapr.jar:/usr/local/testDep/log4j-1.2.15.jar:/usr/local/testDep/mail.jar:/usr/local/testDep/maprbuildversion-4.1.0-mapr.jar:/usr/local/testDep/maprcli-4.1.0-mapr.jar:/usr/local/testDep/maprfs-4.1.0-mapr.jar:/usr/local/testDep/maprfs-core-4.1.0-mapr.jar:/usr/local/testDep/maprfs-core-4.1.0-mapr-tests.jar:/usr/local/testDep/maprfs-diagnostic-tools-4.1.0-mapr.jar:/usr/local/testDep/maprfs-jni-4.1.0-mapr.jar:/usr/local/testDep/mapr-hbase-4.1.0-mapr.jar:/usr/local/testDep/mapr-hbase-4.1.0-mapr-tests.jar:/usr/local/testDep/maprutil-4.1.0-mapr.jar:/usr/local/testDep/maven-ant-tasks-2.1.3.jar:/usr/local/testDep/mysql-connector-java-5.1.25-bin.jar:/usr/local/testDep/persistence-api-1.0.jar:/usr/local/testDep/protobuf-java-2.5.0.jar:/usr/local/testDep/servlet-api-2.5-6.1.26.jar:/usr/local/testDep/slf4j-api-1.7.5.jar:/usr/local/testDep/slf4j-log4j12-1.7.5.jar:/usr/local/testDep/snakeyaml-1.14.jar:/usr/local/testDep/volumemirror-4.1.0-mapr.jar:/usr/local/testDep/warden-4.1.0-mapr.jar 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=/tmp 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:java.compiler= 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:os.name=Linux 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:os.arch=amd64 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:os.version=3.13.0-33-generic 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:user.name=user 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:user.home=/usr/local 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Client environment:user.dir=/usr/local/MyWorks/Flow1/test 15/07/20 14:28:34 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=100.101.102.103:2181 sessionTimeout=90000 watcher=hconnection-0x6a79d589, quorum=100.101.102.103:2181, baseZNode=/hbase 15/07/20 14:28:39 INFO zookeeper.Login: successfully logged in. 15/07/20 14:28:39 INFO client.ZooKeeperSaslClient: Client will use SIMPLE-SECURITY as SASL mechanism. 15/07/20 14:28:39 INFO zookeeper.ClientCnxn: Opening socket connection to server 100.101.102.103/100.101.102.103:2181. Will attempt to SASL-authenticate using Login Context section 'Client_simple' 15/07/20 14:28:39 INFO zookeeper.ClientCnxn: Socket connection established to 100.101.102.103/100.101.102.103:2181, initiating session 15/07/20 14:28:39 INFO zookeeper.ClientCnxn: Session establishment complete on server 100.101.102.103/100.101.102.103:2181, sessionid = 0x14eab4127f0001a, negotiated timeout = 40000 15/07/20 14:28:39 INFO client.ZooKeeperRegistry: ClusterId read in ZooKeeper is null

111

最佳答案

您需要将群集的hbase-site.xml文件放入Java应用程序的类路径中。
另外,您需要删除设置配置对象的代码。也就是说,这些行:

config.set("hbase.zookeeper.quorum","ip_address_of_remotemachine");
config.set("hbase.zookeeper.property.clientPort","2181");
config.set("hbase.master", "hdfs://remote_ip:2181/hbase");

关于java - 无法在远程HBase表中插入记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31512846/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com