我正在尝试使用java API将其与hbase连接。
我在192.168.56.101本地运行Hortonworks Sandbox(HDP 2.5)。
以下是我的java代码
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
public class InsertData{
public static void main(String[] args) throws IOException {
// Instantiating Configuration class
System.out.println("Trying to connect...");
Configuration configuration = HBaseConfiguration.create();
configuration.set("hbase.zookeeper.property.clientPort", "2181");
configuration.set("hbase.zookeeper.quorum", "192.168.56.101");
configuration.set("zookeeper.znode.parent", "/hbase-unsecure");
System.out.println("HBase is running!");
// creating a new table
HTable table = new HTable(configuration, "emp");
System.out.println("Table obtained ");
}
}
以下是输出
Trying to connect...
HBase is running!
2017-03-21 14:32:37.974 java[12263:1255672] Unable to load realm mapping info from SCDynamicStore
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.3-1240972, built on 02/06/2012 10:48 GMT
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:host.name=lm-bng-00668684.paypalcorp.com
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:java.version=1.7.0_45
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:java.home=/Applications/corona-java-1.1.0/jdk-7u45-macosx-x64/Contents/Home/jre
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:java.class.path=/Users/aditsharma/Documents/hbase/Trial_Hbase_run/bin:/Users/aditsharma/Downloads/zookeeper-3.4.3.jar:/Users/aditsharma/Downloads/slf4j-log4j12-1.5.8.jar:/Users/aditsharma/Downloads/slf4j-api-1.5.8.jar:/Users/aditsharma/Downloads/log4j-1.2.16.jar:/Users/aditsharma/Downloads/hbase-0.92.1.jar:/Users/aditsharma/Downloads/hadoop-core-1.0.0.jar:/Users/aditsharma/Downloads/commons-logging-1.1.1.jar:/Users/aditsharma/Downloads/commons-lang-2.6.jar:/Users/aditsharma/Downloads/commons-configuration-1.8.jar
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:java.library.path=/Users/aditsharma/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=/var/folders/_p/73y8zhkj7mvfzxk123s6l3_m3kg68v/T/
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:java.compiler=<NA>
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:os.name=Mac OS X
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:os.arch=x86_64
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:os.version=10.11.6
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:user.name=aditsharma
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:user.home=/Users/aditsharma
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Client environment:user.dir=/Users/aditsharma/Documents/hbase/Trial_Hbase_run
17/03/21 14:32:38 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=192.168.56.101:2181 sessionTimeout=90000 watcher=hconnection
17/03/21 14:32:38 INFO zookeeper.ClientCnxn: Opening socket connection to server /192.168.56.101:2181
17/03/21 14:32:38 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 12263@LM-BNG-00668684
17/03/21 14:32:38 INFO client.ZooKeeperSaslClient: Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.
17/03/21 14:32:38 INFO zookeeper.ClientCnxn: Socket connection established to 192.168.56.101/192.168.56.101:2181, initiating session
17/03/21 14:32:38 INFO zookeeper.ClientCnxn: Session establishment complete on server 192.168.56.101/192.168.56.101:2181, sessionid = 0x15aeff6fa460020, negotiated timeout = 40000
正如您所看到的那样,它被卡住了,“获得的表格”没有被打印出来。因此没有获得表格。
我正在使用以下罐子:
1)commons-configuration-1.8.jar
2)commons-lang-2.6.jar
3)commons-logging-1.1.1.jar
4)hadoop-core-1.0.0.jar
5)hbase-0.92.1.jar
6)log4j-1.2.16.jar
7)slf4j-api-1.5.8.jar
8)slf4j-log4j12-1.5.8.jar
9)zookeeper-3.4.3.jar
更新 我还创建了一个可运行的jar并尝试直接在集群上运行它。它还没有运行。