1. 启动REST服务

a.启动一个非守护进程模式的REST服务器(ctrl+c 终止)

bin/hbase rest start

b.启动守护进程模式的REST服务器

bin/hbase-daemon.sh start rest

默认启动的是8080端口(可以使用参数在启动时指定端口),可以被访问。eg.  curl  http://<servername>:8080/

2.访问服务端的数据

3.使用Java API访问

 package rest;

 import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.rest.client.Client;
import org.apache.hadoop.hbase.rest.client.Cluster;
import org.apache.hadoop.hbase.rest.client.RemoteHTable;
import org.apache.hadoop.hbase.util.Bytes;
import util.HBaseHelper; import java.io.IOException; /**
* Created by root on 15-1-9.
*/
public class RestExample {
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create(); HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable");
helper.createTable("testtable", "colfam1");
System.out.println("Adding rows to table...");
helper.fillTable("testtable", 1, 10, 5, "colfam1"); Cluster cluster=new Cluster();
cluster.add("hadoop",8080); Client client=new Client(cluster); RemoteHTable table=new RemoteHTable(client,"testtable"); Get get = new Get(Bytes.toBytes("row-30"));
get.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("col-3"));
Result result1 = table.get(get); System.out.println("Get result1: " + result1); Scan scan = new Scan();
scan.setStartRow(Bytes.toBytes("row-10"));
scan.setStopRow(Bytes.toBytes("row-15"));
scan.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("col-5"));
ResultScanner scanner = table.getScanner(scan);
for (Result result2 : scanner) {
System.out.println("Scan row[" + Bytes.toString(result2.getRow()) +
"]: " + result2);
} } }

最新文章

  1. 从零开始编写自己的C#框架(25)——网站部署
  2. powerdesigner显示列描述信息
  3. Openvpn 公网访问内网
  4. 一、 Java的值传递和引用传递
  5. js 限定上传文件大小 类型
  6. bzoj1823 [JSOI2010]满汉全席(2-SAT)
  7. 解读JavaScript代码 var ie = !-[1,]
  8. Mark Russinovich 的博客:Windows Azure 主机更新:原因、时间和方式
  9. 3D空间中的AABB(轴向平行包围盒, Aixe align bounding box)的求法
  10. [solr] - solr5.2.1环境搭建 - 使用solr自带的jetty服务器
  11. Axis1.4之定制发布服务
  12. Ubuntu18.04教程
  13. SQL SERVER 2012 AlwaysOn - 维护篇 03
  14. bugku web 矛盾
  15. 20181115 python-第一章学习小结part3
  16. 第一册:lesson ninety-three。
  17. Eclipse的Servers视图中无法添加Tomcat
  18. 深入详解美团点评CAT跨语言服务监控(五)配置与数据库操作
  19. FakeID签名漏洞分析及利用(一)
  20. window2012如何查看进程中PID所对应的IIS应用程序池

热门文章

  1. Sql Server 查看所有存储过程或视图的位置及内容
  2. SQL Server -ISNULL()函数
  3. win8 安装myeclipse 失败 MyEclipse ForSpring 安装失败
  4. 你真的了解:IIS连接数、IIS并发连接数、IIS最大并发工作线程数、应用程序池的队列长度、应用程序池的最大工作进程数 吗?
  5. 在html页头设置不缓存
  6. Jquery函数实现时间显示模式为更新于+被当前时间减去后剩余的时间值(例如:更新于三小时前)的处理。
  7. Qt窗口句柄
  8. sql建立跨服务器链接
  9. phantomjs初入门
  10. js基础小总结之string&amp;array&amp;object