首页 > 代码库 > 使用hbase的api创建表时出现的异常

使用hbase的api创建表时出现的异常

技术分享
 1 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Didea.launcher.port=7538 -Didea.launcher.bin.path=/usr/local/idea-IC-139.225.3/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/compilefontconfig.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/javazic.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/pulse-java.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/java-atk-wrapper.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/sunpkcs11.jar:/root/IdeaProjects/Test/out/production/HbaseTest:/usr/local/hbase-0.90.3/hbase-0.90.3.jar:/usr/local/hbase-0.90.3/lib/activation-1.1.jar:/usr/local/hbase-0.90.3/lib/asm-3.1.jar:/usr/local/hbase-0.90.3/lib/avro-1.3.3.jar:/usr/local/hbase-0.90.3/lib/commons-cli-1.2.jar:/usr/local/hbase-0.90.3/lib/commons-codec-1.4.jar:/usr/local/hbase-0.90.3/lib/commons-el-1.0.jar:/usr/local/hbase-0.90.3/lib/commons-httpclient-3.1.jar:/usr/local/hbase-0.90.3/lib/commons-lang-2.5.jar:/usr/local/hbase-0.90.3/lib/commons-logging-1.1.1.jar:/usr/local/hbase-0.90.3/lib/commons-net-1.4.1.jar:/usr/local/hbase-0.90.3/lib/core-3.1.1.jar:/usr/local/hbase-0.90.3/lib/guava-r06.jar:/usr/local/hbase-0.90.3/lib/hadoop-0.20.2-core.jar:/usr/local/hbase-0.90.3/lib/jackson-core-asl-1.5.5.jar:/usr/local/hbase-0.90.3/lib/jackson-jaxrs-1.5.5.jar:/usr/local/hbase-0.90.3/lib/jackson-mapper-asl-1.4.2.jar:/usr/local/hbase-0.90.3/lib/jackson-xc-1.5.5.jar:/usr/local/hbase-0.90.3/lib/jasper-compiler-5.5.23.jar:/usr/local/hbase-0.90.3/lib/jasper-runtime-5.5.23.jar:/usr/local/hbase-0.90.3/lib/jaxb-api-2.1.jar:/usr/local/hbase-0.90.3/lib/jaxb-impl-2.1.12.jar:/usr/local/hbase-0.90.3/lib/jersey-core-1.4.jar:/usr/local/hbase-0.90.3/lib/jersey-json-1.4.jar:/usr/local/hbase-0.90.3/lib/jersey-server-1.4.jar:/usr/local/hbase-0.90.3/lib/jettison-1.1.jar:/usr/local/hbase-0.90.3/lib/jetty-6.1.26.jar:/usr/local/hbase-0.90.3/lib/jetty-util-6.1.26.jar:/usr/local/hbase-0.90.3/lib/jruby-complete-1.6.0.jar:/usr/local/hbase-0.90.3/lib/jsp-2.1-6.1.14.jar:/usr/local/hbase-0.90.3/lib/jsp-api-2.1-6.1.14.jar:/usr/local/hbase-0.90.3/lib/jsr311-api-1.1.1.jar:/usr/local/hbase-0.90.3/lib/log4j-1.2.16.jar:/usr/local/hbase-0.90.3/lib/protobuf-java-2.3.0.jar:/usr/local/hbase-0.90.3/lib/servlet-api-2.5-6.1.14.jar:/usr/local/hbase-0.90.3/lib/slf4j-api-1.5.8.jar:/usr/local/hbase-0.90.3/lib/slf4j-log4j12-1.5.8.jar:/usr/local/hbase-0.90.3/lib/stax-api-1.0.1.jar:/usr/local/hbase-0.90.3/lib/thrift-0.2.0.jar:/usr/local/hbase-0.90.3/lib/xmlenc-0.52.jar:/usr/local/hbase-0.90.3/lib/zookeeper-3.3.2.jar:/usr/local/idea-IC-139.225.3/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain PutEcample 2 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.3.2-1031432, built on 11/05/2010 05:32 GMT 3 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:host.name=localhost 4 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:java.version=1.7.0_65 5 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation 6 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre 7 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:java.class.path=/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/compilefontconfig.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/javazic.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/pulse-java.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/java-atk-wrapper.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/sunpkcs11.jar:/root/IdeaProjects/Test/out/production/HbaseTest:/usr/local/hbase-0.90.3/hbase-0.90.3.jar:/usr/local/hbase-0.90.3/lib/activation-1.1.jar:/usr/local/hbase-0.90.3/lib/asm-3.1.jar:/usr/local/hbase-0.90.3/lib/avro-1.3.3.jar:/usr/local/hbase-0.90.3/lib/commons-cli-1.2.jar:/usr/local/hbase-0.90.3/lib/commons-codec-1.4.jar:/usr/local/hbase-0.90.3/lib/commons-el-1.0.jar:/usr/local/hbase-0.90.3/lib/commons-httpclient-3.1.jar:/usr/local/hbase-0.90.3/lib/commons-lang-2.5.jar:/usr/local/hbase-0.90.3/lib/commons-logging-1.1.1.jar:/usr/local/hbase-0.90.3/lib/commons-net-1.4.1.jar:/usr/local/hbase-0.90.3/lib/core-3.1.1.jar:/usr/local/hbase-0.90.3/lib/guava-r06.jar:/usr/local/hbase-0.90.3/lib/hadoop-0.20.2-core.jar:/usr/local/hbase-0.90.3/lib/jackson-core-asl-1.5.5.jar:/usr/local/hbase-0.90.3/lib/jackson-jaxrs-1.5.5.jar:/usr/local/hbase-0.90.3/lib/jackson-mapper-asl-1.4.2.jar:/usr/local/hbase-0.90.3/lib/jackson-xc-1.5.5.jar:/usr/local/hbase-0.90.3/lib/jasper-compiler-5.5.23.jar:/usr/local/hbase-0.90.3/lib/jasper-runtime-5.5.23.jar:/usr/local/hbase-0.90.3/lib/jaxb-api-2.1.jar:/usr/local/hbase-0.90.3/lib/jaxb-impl-2.1.12.jar:/usr/local/hbase-0.90.3/lib/jersey-core-1.4.jar:/usr/local/hbase-0.90.3/lib/jersey-json-1.4.jar:/usr/local/hbase-0.90.3/lib/jersey-server-1.4.jar:/usr/local/hbase-0.90.3/lib/jettison-1.1.jar:/usr/local/hbase-0.90.3/lib/jetty-6.1.26.jar:/usr/local/hbase-0.90.3/lib/jetty-util-6.1.26.jar:/usr/local/hbase-0.90.3/lib/jruby-complete-1.6.0.jar:/usr/local/hbase-0.90.3/lib/jsp-2.1-6.1.14.jar:/usr/local/hbase-0.90.3/lib/jsp-api-2.1-6.1.14.jar:/usr/local/hbase-0.90.3/lib/jsr311-api-1.1.1.jar:/usr/local/hbase-0.90.3/lib/log4j-1.2.16.jar:/usr/local/hbase-0.90.3/lib/protobuf-java-2.3.0.jar:/usr/local/hbase-0.90.3/lib/servlet-api-2.5-6.1.14.jar:/usr/local/hbase-0.90.3/lib/slf4j-api-1.5.8.jar:/usr/local/hbase-0.90.3/lib/slf4j-log4j12-1.5.8.jar:/usr/local/hbase-0.90.3/lib/stax-api-1.0.1.jar:/usr/local/hbase-0.90.3/lib/thrift-0.2.0.jar:/usr/local/hbase-0.90.3/lib/xmlenc-0.52.jar:/usr/local/hbase-0.90.3/lib/zookeeper-3.3.2.jar:/usr/local/idea-IC-139.225.3/lib/idea_rt.jar 8 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:java.library.path=/usr/local/idea-IC-139.225.3/bin::/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib 9 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=/tmp10 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:java.compiler=<NA>11 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:os.name=Linux12 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:os.arch=amd6413 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:os.version=3.8.0-44-generic14 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:user.name=root15 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:user.home=/root16 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Client environment:user.dir=/root/IdeaProjects/Test17 15/01/04 11:18:17 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection18 15/01/04 11:18:17 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:218119 15/01/04 11:18:17 INFO zookeeper.ClientCnxn: Socket connection established to localhost/127.0.0.1:2181, initiating session20 15/01/04 11:18:17 INFO zookeeper.ClientCnxn: Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x14ab2ae95630011, negotiated timeout = 4000021 15/01/04 11:18:17 WARN client.HConnectionManager$HConnectionImplementation: Encountered problems when prefetch META table: 22 org.apache.hadoop.hbase.TableNotFoundException: Cannot find row in .META. for table: testtable9, row=testtable9,,9999999999999923     at org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:136)24     at org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:95)25     at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.prefetchRegionCache(HConnectionManager.java:648)26     at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:702)27     at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:593)28     at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:558)29     at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:172)30     at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:146)31     at PutEcample.main(PutEcample.java:21)32     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)33     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)34     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)35     at java.lang.reflect.Method.invoke(Method.java:606)36     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)37 Exception in thread "main" org.apache.hadoop.hbase.TableNotFoundException: testtable938     at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:724)39     at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:593)40     at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:558)41     at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:172)42     at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:146)43     at PutEcample.main(PutEcample.java:21)44     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)45     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)46     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)47     at java.lang.reflect.Method.invoke(Method.java:606)48     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
View Code
import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.hbase.HBaseConfiguration;import org.apache.hadoop.hbase.HColumnDescriptor;import org.apache.hadoop.hbase.HTableDescriptor;import org.apache.hadoop.hbase.client.HBaseAdmin;import org.apache.hadoop.hbase.client.HTable;import org.apache.hadoop.hbase.client.Put;import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;public class PutEcample {    public static void main(String[] args) throws IOException{        Configuration conf= HBaseConfiguration.create();        HBaseAdmin hbase=new HBaseAdmin(conf);        HTableDescriptor desc=new HTableDescriptor("testtable1");        HColumnDescriptor colfam1=new HColumnDescriptor("colfam1".getBytes());        desc.addFamily(colfam1);        hbase.createTable(desc);        HTable table=new HTable(conf,"testtable1");        Put put=new Put(Bytes.toBytes("row1"));        put.add(Bytes.toBytes("colfam1"),Bytes.toBytes("qual1"),Bytes.toBytes("val1"));        //Put.add(Bytes.toBytes("colfam1"),Bytes.toBytes("qual2"),Bytes.toBytes("val2"));        table.put(put);        System.out.println("ok");    }}

使用hbase的api创建表时要先创建表的结构。

 

使用hbase的api创建表时出现的异常