HbaseTemplate进阶:利用hbase.properties文件对Hbase的集群和端口进行配置
来源:互联网 发布:虚拟linux系统界面 编辑:程序博客网 时间:2024/05/18 01:28
1、hbase.properties文件:
quorum=10.46.60.23
clientPort=2015
2、spring-hbase.xml配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hdp="http://www.springframework.org/schema/hadoop"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">
<!-- 加载外部的properties配置文件 -->
<context:property-placeholder location="file:/opt/search/resourse/hbase.properties"/>
<!-- 配置zookeeper的信息,远程连接hbase时使用 -->
<hdp:configuration resources="classpath:/hbase-site.xml" />
<hdp:hbase-configuration zk-quorum="${quorum}"
zk-port="${clientPort}" configuration-ref="hadoopConfiguration" /> <!--这里特别要注意,只有 zk-quorum和zk-port从hbase.properties获取,其他配置在hbase-site.xml-->
<!-- 配置HbaseTemplate -->
<bean id="htemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate">
<property name="configuration" ref="hbaseConfiguration">
</property>
<property name="encoding" value="UTF-8"></property>
</bean>
</beans>
3、hbase-site.xml文件
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- zookeeper集群的URL配置
<property>
<name>hbase.zookeeper.quorum</name>
<value>namenode1-sit.cnsuning.com,namenode2-sit.cnsuning.com,slave01-sit.cnsuning.com</value>
</property> -->
<!-- 客户端连接端口
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2015</value>
</property>-->
<!-- 重试等待时间 -->
<property>
<name>hbase.client.pause</name>
<value>50</value>
</property>
<!-- 失败时重试次数 -->
<property>
<name>hbase.client.retries.number</name>
<value>3</value>
</property>
<!-- RPC请求的超时时间。如果某次RPC时间超过该值,客户端就会主动关闭socket -->
<property>
<name>hbase.rpc.timeout</name>
<value>2000</value>
</property>
<!-- HBase客户端发起一次数据操作直至得到响应之间总的超时时间 -->
<property>
<name>hbase.client.operation.timeout</name>
<value>3000</value>
</property>
<!-- 该参数是表示HBase客户端发起一次scan操作的rpc调用至得到响应之间总的超时时间 -->
<property>
<name>hbase.client.scanner.timeout.period</name>
<value>10000</value>
</property>
</configuration>
4、在java中应用
static private ApplicationContext hbaseContext = new ClassPathXmlApplicationContext("classpath:spring-hbase.xml");
static private BeanFactory factory = (BeanFactory) hbaseContext;
static private HbaseTemplate htemplate = (HbaseTemplate) factory.getBean("htemplate");
注意:利用这种方式的缺陷:利用Spring获取hbase.properties文件的配置无法实现实时获取
- HbaseTemplate进阶:利用hbase.properties文件对Hbase的集群和端口进行配置
- HbaseTemplate进阶:利用hbase.properties文件对Hbase的集群和端口进行配置
- HbaseTemplate配置进阶:利用Spring自动装配加载HbaseTemplate
- HbaseTemplate配置进阶:利用Spring自动装配加载HbaseTemplate
- spring hbase hbaseTemplate
- hbase集群的安装、配置
- 利用MapReduce对HBase数据进行统计分析
- 【hbase】thrift2 集群 && 指定端口
- HBase笔记一:HBase的集群环境配置
- hbase集群配置
- HBase 集群配置
- Hbase集群配置
- Hbase集群配置
- Hbase集群安装配置
- HBase集群安装配置
- HBase集群配置
- Hbase集群配置
- Hbase集群安装配置
- Mr.Smile填坑记——微博、微信debug、release版本切换不能分享
- POJ-2752 Seek the Name, Seek the Fame
- JavaScript定时器原理及高级使用
- gdb多进程/多线程调试实战
- node 回调函数
- HbaseTemplate进阶:利用hbase.properties文件对Hbase的集群和端口进行配置
- 洛谷 P1140 相似基因
- CC26xx SPI
- Windows64 Py-Faster-RCNN的配置
- JSP&Servlet 监听器
- Vue之实例详解
- TTS开源方案open jTalk
- iOS编程基础-Swift(五)-流程控制与其他
- 千万级规模高性能、高并发的网络架构经验分享