HBase 客户端通过Java访问集群
来源:互联网 发布:海康视频服务器软件 编辑:程序博客网 时间:2024/06/06 03:26
Hive有客户端,HBase也有客户端咯
hBase如何通过客户端连接呢? 简单的程序帮助你连接你的Hbase,很简单,很实用。
public class App {private static HBaseAdmin admin = null;public static Configuration configuration; public App() throws MasterNotRunningException, ZooKeeperConnectionException, IOException{configuration = HBaseConfiguration.create(); configuration.set("hbase.zookeeper.property.clientPort", "2181"); configuration.set("hbase.zookeeper.quorum", "192.168.222.128"); configuration.set("hbase.master", "192.168.222.128:60000"); System.out.println(configuration); admin = new HBaseAdmin(configuration); } public static void main(String[] args) throws Exception{App app = new App();app.getAllTables();} public List getAllTables() { List<String> tables = null; if (admin != null) { try { System.out.println("here"); System.out.println(admin.isMasterRunning()); HTableDescriptor[] allTable = admin.listTables(); System.out.println(allTable.length); if (allTable.length > 0) tables = new ArrayList<String>(); for (HTableDescriptor hTableDescriptor : allTable) { tables.add(hTableDescriptor.getNameAsString()); System.out.println(hTableDescriptor.getNameAsString()); } } catch (IOException e) { e.printStackTrace(); } } return tables; } }上面的一些配置信息都是在hbase-site.xml中存在的。
具体的,可以查看你们的配置文件。
那么连接就会成功了吗???????
执行到这里就不动了。。。。。。。。
换另一个程序,报的错误是 hostException: ubuntu
so。。。。。。
win+R: drivers /etc/hosts 添加你的host配置: 192.168.222.128 ubuntu
再次访问,就ok了
部分结果显式:
3(共3张表)
member
student
test
连接完成。
不讲大道理,不讲深操作,只教你入门。
0 0
- HBase 客户端通过Java访问集群
- 如何通过JAVA客户端访问Hbase
- java客户端访问hbase
- 集群中通过Java操作Hbase 0.98
- 在集群中java 通过调用API操作HBase 0.98
- 在集群中Java 通过调用API操作HBase 0.98
- java客户端通过get方法获取Hbase的数据
- 通过nginx实现内网hadoop、hbase集群对外访问web界面
- memcached的java语言客户端和访问集群
- HBase--Java访问HBase示例
- python 通过happybase 访问hbase
- HBase Java客户端编程
- HBase JAVA WEB客户端
- HBase Java客户端编程
- Hbase java客户端操作
- HBase Java客户端编程
- HBase Java客户端编程
- HBase Java客户端编程
- 编程思想
- 安卓自定义view实现彩票刮刮卡效果
- 彻底理解webservice ,SOAP, WSDL
- iptables 里 recent 模块的用法
- HashMap实现原理
- HBase 客户端通过Java访问集群
- 第一篇博客
- [2016/11/28]判断一个数是否是回文数,但不能开多余空间
- activiti之排他网关,流程变量
- Hibernate中一对多关联关系保存
- 脚踏实地,一步一步地解决问题
- String literal is not properly closed by a double-quote
- 玩转Android之数据库框架greenDAO3.0使用指南
- 去除 input 点击时出现的蓝边框