首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > 云计算 >

hbase:应用开发,hbase表操作及其java api兑现

2013-09-10 
hbase:应用开发,hbase表操作及其java api实现开发环境:hadoop: hadoop-1.1.2hbase: hbase-0.94.11-securit

hbase:应用开发,hbase表操作及其java api实现
开发环境:

hadoop: hadoop-1.1.2

hbase: hbase-0.94.11-security

eclipse:Juno Service Release 2

配置Eclipse 

通过 Eclipse 创建一个新 Java 工程,右击项目根目录,选择“Properties> Java Build Path> Library>  Add  External  JARs”,将 HBase 安装文件解压后根目录下的hbase-0.94.11-security.jar、hbase-0.94.11-security-tests.jar 和 lib 子目录下所有的 jar 包添加到本工程的 Build Path下。 

示例使用表users及表的基本操作:创建表
13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:host.name=tht13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:java.version=1.6.0_4513/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Sun Microsystems Inc.13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:java.home=D:\Java\jre613/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:java.class.path=。。。。。。。。。。。。13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:java.library.path=。。。。。。。。。。。13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=C:\Users\ADMINI~1\AppData\Local\Temp\13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:java.compiler=<NA>13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:os.name=Windows 713/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:os.arch=x8613/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:os.version=6.113/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:user.name=hadoop13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:user.home=C:\Users\Administrator13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Client environment:user.dir=D:\workspace\eclipse-workspace-jee-kepler\hadoop-Apps-tht13/09/09 22:01:18 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=master:2181 sessionTimeout=180000 watcher=hconnection13/09/09 22:01:18 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 9608@tht13/09/09 22:01:18 INFO zookeeper.ClientCnxn: Opening socket connection to server master/192.168.1.101:2181. Will not attempt to authenticate using SASL (无法定位登录配置)13/09/09 22:01:18 INFO zookeeper.ClientCnxn: Socket connection established to master/192.168.1.101:2181, initiating session13/09/09 22:01:18 INFO zookeeper.ClientCnxn: Session establishment complete on server master/192.168.1.101:2181, sessionid = 0x14102d851f8000b, negotiated timeout = 18000013/09/09 22:01:18 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=master:2181 sessionTimeout=180000 watcher=catalogtracker-on-org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@ba860213/09/09 22:01:18 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 9608@tht13/09/09 22:01:18 INFO zookeeper.ClientCnxn: Opening socket connection to server master/192.168.1.101:2181. Will not attempt to authenticate using SASL (无法定位登录配置)13/09/09 22:01:18 INFO zookeeper.ClientCnxn: Socket connection established to master/192.168.1.101:2181, initiating session13/09/09 22:01:18 INFO zookeeper.ClientCnxn: Session establishment complete on server master/192.168.1.101:2181, sessionid = 0x14102d851f8000c, negotiated timeout = 18000013/09/09 22:01:20 INFO zookeeper.ZooKeeper: Session: 0x14102d851f8000c closed13/09/09 22:01:20 INFO zookeeper.ClientCnxn: EventThread shut down13/09/09 22:01:36 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=master:2181 sessionTimeout=180000 watcher=catalogtracker-on-org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@ba860213/09/09 22:01:36 INFO zookeeper.ClientCnxn: Opening socket connection to server master/192.168.1.101:2181. Will not attempt to authenticate using SASL (无法定位登录配置)13/09/09 22:01:36 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 9608@tht13/09/09 22:01:36 INFO zookeeper.ClientCnxn: Socket connection established to master/192.168.1.101:2181, initiating session13/09/09 22:01:38 INFO zookeeper.ClientCnxn: Session establishment complete on server master/192.168.1.101:2181, sessionid = 0x14102d851f8000d, negotiated timeout = 18000013/09/09 22:01:38 INFO zookeeper.ZooKeeper: Session: 0x14102d851f8000d closed13/09/09 22:01:38 INFO zookeeper.ClientCnxn: EventThread shut down创建表成功获取一条数据Row Name: tht Timestamp: 1378735285456 column Family: course Row Name:  china Value: 97 Row Name: tht Timestamp: 1378735285918 column Family: course Row Name:  english Value: 85 Row Name: tht Timestamp: 1378735285591 column Family: course Row Name:  math Value: 128 Row Name: tht Timestamp: 1378735285056 column Family: info Row Name:  age Value: 20 Row Name: tht Timestamp: 1378735285368 column Family: info Row Name:  sex Value: boy 获取所有数据Row Name: qingqing Timestamp: 1378735286503 column Family: course Row Name:  china Value: 100 Row Name: qingqing Timestamp: 1378735286547 column Family: course Row Name:  english Value: 99 Row Name: qingqing Timestamp: 1378735286524 column Family: course Row Name:  math Value: 100 Row Name: qingqing Timestamp: 1378735286463 column Family: info Row Name:  age Value: 18 Row Name: qingqing Timestamp: 1378735286482 column Family: info Row Name:  sex Value: girl Row Name: tht Timestamp: 1378735285456 column Family: course Row Name:  china Value: 97 Row Name: tht Timestamp: 1378735285918 column Family: course Row Name:  english Value: 85 Row Name: tht Timestamp: 1378735285591 column Family: course Row Name:  math Value: 128 Row Name: tht Timestamp: 1378735285056 column Family: info Row Name:  age Value: 20 Row Name: tht Timestamp: 1378735285368 column Family: info Row Name:  sex Value: boy Row Name: xiaoxue Timestamp: 1378735286268 column Family: course Row Name:  china Value: 90 Row Name: xiaoxue Timestamp: 1378735286403 column Family: course Row Name:  english Value: 90 Row Name: xiaoxue Timestamp: 1378735286343 column Family: course Row Name:  math Value: 120 Row Name: xiaoxue Timestamp: 1378735286114 column Family: info Row Name:  age Value: 19 Row Name: xiaoxue Timestamp: 1378735286236 column Family: info Row Name:  sex Value: boy 删除一条数据Row Name: qingqing Timestamp: 1378735286503 column Family: course Row Name:  china Value: 100 Row Name: qingqing Timestamp: 1378735286547 column Family: course Row Name:  english Value: 99 Row Name: qingqing Timestamp: 1378735286524 column Family: course Row Name:  math Value: 100 Row Name: qingqing Timestamp: 1378735286463 column Family: info Row Name:  age Value: 18 Row Name: qingqing Timestamp: 1378735286482 column Family: info Row Name:  sex Value: girl Row Name: xiaoxue Timestamp: 1378735286268 column Family: course Row Name:  china Value: 90 Row Name: xiaoxue Timestamp: 1378735286403 column Family: course Row Name:  english Value: 90 Row Name: xiaoxue Timestamp: 1378735286343 column Family: course Row Name:  math Value: 120 Row Name: xiaoxue Timestamp: 1378735286114 column Family: info Row Name:  age Value: 19 Row Name: xiaoxue Timestamp: 1378735286236 column Family: info Row Name:  sex Value: boy 删除多条数据删除数据库13/09/09 22:01:40 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=master:2181 sessionTimeout=180000 watcher=catalogtracker-on-org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@ba860213/09/09 22:01:40 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 9608@tht13/09/09 22:01:40 INFO zookeeper.ClientCnxn: Opening socket connection to server master/192.168.1.101:2181. Will not attempt to authenticate using SASL (无法定位登录配置)13/09/09 22:01:40 INFO zookeeper.ClientCnxn: Socket connection established to master/192.168.1.101:2181, initiating session13/09/09 22:01:42 INFO zookeeper.ClientCnxn: Session establishment complete on server master/192.168.1.101:2181, sessionid = 0x14102d851f8000e, negotiated timeout = 18000013/09/09 22:01:44 INFO zookeeper.ZooKeeper: Session: 0x14102d851f8000e closed13/09/09 22:01:44 INFO zookeeper.ClientCnxn: EventThread shut down13/09/09 22:01:48 INFO client.HBaseAdmin: Started disable of users213/09/09 22:01:50 INFO client.HBaseAdmin: Disabled users213/09/09 22:01:51 INFO client.HBaseAdmin: Deleted users2删除表成功




热点排行