1、 Is your zk-path 127.0.0.1:2181 ? This is default configuration without config file.
2、Set a cache value (100 or 1000 and so on ) for scan object. 在 16/4/4 01:06, "Sachin Mittal" <sjmit...@gmail.com> 写入: >I am stuck on connecting to hbase 1.0.3 via simple java client. >The program hangs at: > > [main] zookeeper.ZooKeeper: Initiating client connection, >connectString= >127.0.0.1:2181 sessionTimeout=90000 watcher=hconnection-0x1e67b8720x0, >quorum=127.0.0.1:2181, baseZNode=/hbaseenter code here > [main-SendThread(127.0.0.1:2181)] zookeeper.ClientCnxn: Opening socket >connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to >authenticate using SASL (unknown error) > [main-SendThread(127.0.0.1:2181)] zookeeper.ClientCnxn: Socket >connection established to 127.0.0.1/127.0.0.1:2181, initiating session > [main-SendThread(127.0.0.1:2181)] zookeeper.ClientCnxn: Session >establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = >0x153d8383c530008, negotiated timeout = 40000 > >The code is very simple and standard: > > public static void main(String args[]) throws IOException{ > // Instantiating Configuration class > Configuration config = HBaseConfiguration.create(); > Connection connection = >ConnectionFactory.createConnection(config); > // Instantiating Table class > Table table = >connection.getTable(TableName.valueOf(HBaseTables.APPLICATION_TRACE_INDEX) >); > // Instantiating the Scan class > Scan scan = new Scan(); > // Getting the scan result > ResultScanner scanner = table.getScanner(scan); > // Reading values from scan result > for (Result result = scanner.next(); result != null; result = >scanner.next()) { > System.out.println("Found row : " + result); > } > //closing the scanner > scanner.close(); > table.close(); > connection.close(); > } > > >The jars I am using are: > > commons-collections-3.2.1.jar > commons-configuration-1.6.jar > commons-lang-2.6.jar > commons-logging-1.2.jar > guava-12.0.1.jar > hadoop-auth-2.5.1.jar > hadoop-client-2.5.1.jar > hadoop-common-2.5.1.jar > hbase-client-1.0.3.jar > hbase-common-1.0.3.jar > hbase-hadoop-compat-1.0.3.jar > hbase-hadoop2-compat-1.0.3.jar > hbase-it-1.0.3.jar > hbase-protocol-1.0.3.jar > hbase-resource-bundle-1.0.3.jar > hbase-rest-1.0.3.jar > htrace-core-3.0.4.jar > htrace-core-3.1.0-incubating.jar > log4j-1.2.17.jar > netty-3.2.4.Final.jar > netty-all-4.0.23.Final.jar > protobuf-java-2.5.0.jar > slf4j-api-1.7.7.jar > slf4j-log4j12-1.7.7.jar > zookeeper-3.4.6.jar > >My hbase-site.xml is > > <configuration> > <property> > <name>hbase.rootdir</name> > <value>file:///path/to/data/hbase</value> > </property> > <property> > <name>hbase.zookeeper.property.dataDir</name> > <value>file:///path/to/data/zookeeper</value> > </property> > <property> > <name>hbase.zookeeper.quorum</name> > <value>127.0.0.1</value> > </property> > </configuration> > >In my hosts I have this entry: >127.0.0.1 localhost.localdomain localhost Sachin-PC > >Also in hbase regionservers has one entry >localhost > >I have tried many options for hbase.zookeeper.quorum like localhost, >Sachin-PC, 127.0.0.1 but none have worked. > >Also note the jars I am using are of same version in hbase lib. > >I am just not able to wrap my head around as what is causing the failure >to >scan table for this simple code. > >Note the code stops at line ResultScanner scanner = >table.getScanner(scan); >So connection is happening but it is not getting any data. > >Also note I am able to run hbase and connect to it via shell and scan >tables all fine. > >Please help! > >Thanks >Sachin > >ps additional logs: > > DEBUG [hconnection-0x1e67b872-shared--pool1-t1] ipc.AbstractRpcClient: >Use SIMPLE authentication for service ClientService, sasl=false > DEBUG [hconnection-0x1e67b872-shared--pool1-t1] ipc.AbstractRpcClient: >Connecting to Sachin-PC/127.0.0.1:55161 > > DEBUG [hconnection-0x1e67b872-shared--pool1-t1] ipc.AbstractRpcClient: >Use SIMPLE authentication for service ClientService, sasl=false > DEBUG [hconnection-0x1e67b872-shared--pool1-t1] ipc.AbstractRpcClient: >Not trying to connect to Sachin-PC/127.0.0.1:55161 this server is in the >failed servers list