Hazelcast配置文档(完整)

2.config.xml

<group>
    <name>openfire</name>
    <password>openfire</password>
</group>

You can create cluster groups. To do this, use the group configuration element.By specifying a group name and group password, you can separate your clusters in a simple way. Example groupings can be by development, production, test, app, etc. The following is an example declarative configuration.java

使用组的配置元素来建立群组。经过指定一个组名和组密码,就能够单独集群在一个简单的方法。例如分组能够开发、生产、测试、应用等等。

3.config.xml

<properties>
  <property name="hazelcast.logging.type">slf4j</property>
  <property name="hazelcast.operation.call.timeout.millis">30000</property>
  <property name="hazelcast.memcache.enabled">false</property>
  <property name="hazelcast.rest.enabled">false</property>
</properties>

Hazelcast has a flexible logging configuration and does not depend on any logging framework except JDK logging. It has built-in adaptors for a number of logging frameworks and it also supports custom loggers by providing logging interfaces.node

对Hazelcast的属性进行配置。Hazelcast有一个灵活的日志配置和除了JDK自己的日志外不依赖于任何日志框架,。它有内置适配器的日志框架还能够以日志接口为条件提供定制的日志。

“hazelcast.logging.type”:日志形式,

To use built-in adaptors, set the hazelcast.logging.type property to one of the predefined types below.
jdk: JDK logging (default)
log4j: Log4j
slf4j: Slf4j
none: disable logging
You can set hazelcast.logging.type through declarative configuration, programmatic configuration, or JVM system property.react

利用内置适配器,能够对日志形式能够设置为如下四种方式:jdk(即JDK日志),也是默认配置;log4j;slf4j;none。也能够经过声明性配置类型,编程配置或JVM系统属性来进行设置hazekcast.logging。

4.config.xml

<management-center enabled="false"/>

管理中心 。经过该标签来设置对集群的管理中心,enabled通常有“true”“false”两值,上述设置就是管理中心不启动。http://localhost:8080/mancenter,该方式既是经过定义的地址来进行管理。

5.onfig.xml

<network><!--网络配置-->
    <port auto-increment="true" port-count="100">5701</port><!--端口-->
    <outbound-ports><!--出站端口-->
        <ports>0</ports>
    </outbound-ports>
    <join>
        <multicast enabled="true">
            <multicast-group>224.2.2.3</multicast-group>
            <multicast-port>54327</multicast-port>
        </multicast>
        <tcp-ip enabled="false"/>
        <aws enabled="false"/>
    </join>
    <interfaces enabled="false">
        <interface>10.10.1.*</interface>
    </interfaces>
    <ssl enabled="false"/>
    <socket-interceptor enabled="false"/>
    <symmetric-encryption enabled="false">
        <!--
           encryption algorithm such as
           DES/ECB/PKCS5Padding,
           PBEWithMD5AndDES,
           AES/CBC/PKCS5Padding,
           Blowfish,
           DESede
        -->
        <algorithm>PBEWithMD5AndDES</algorithm>
        <!-- salt value to use when generating the secret key -->
        <salt>thesalt</salt>
        <!-- pass phrase to use when generating the secret key -->
        <password>thepass</password>
        <!-- iteration count to use when generating the secret key -->
        <iteration-count>19</iteration-count>
    </symmetric-encryption>
</network>

这 一部分是对网络链接进行配置。:端口设置,auto-increment即自动增量,其值为“true”和“false”,port-count,端口总 数,其值为“int”。如上例中,最初连接5701端口,若是失败就5702….自动日后知道5800。端口值范围,若是是0或者*就标识系统默认的,即 0-1024,也能够写任意的范围5701-5801.

\标签 详情见(http://blog.csdn.net/frankcheng5143/article/details/48708899)

\

You can specify which network interfaces that Hazelcast should use. Servers mostly have more than one network interface, so you may want to list the valid IPs. Range characters (‘’ and ‘-‘) can be used for simplicity. For instance, 10.3.10. refers to IPs between 10.3.10.0 and 10.3.10.255. Interface 10.3.10.4-18 refers to IPs between 10.3.10.4 and 10.3.10.18 (4 and 18 included). If network interface configuration is enabled (it is disabled by default) and if Hazelcast cannot find an matching interface, then it will print a message on the console and will not start on that node算法

指定Hazelcast应该使用哪一个网络接口。服务器主要有多个网络接口,因此你可能想要有效的ip列表。范围字符(‘’和‘-’)可用于简单。例如,10.3.10。指IPs 10.3.10.0和10.3.10.255之间。接口10.3.10.4-18指IPs 10.3.10.4和10.3.10.18之间(包括4和18)。若是启用了网络接口配置(默认禁用),当Hazelcast不能找到一个匹配的接口,那 么它将在控制台上打印一条消息,不会在该节点开始。

\安全套接层

Hazelcast allows you to use SSL socket communication among all Hazelcast members. To use it, you need to implement com.hazelcast.nio.ssl.SSLContextFactory and configure the SSL section in network configuration.编程

Hazelcast容许使用SSL套接字在Hazelcast全部成员之间的沟通。使用它,须要实现com.hazelcast.nio.ssl。SSLContextFactory和配置SSL部分网络配置。官方给出以下配置:

<network>
    ...
    <ssl enabled="true">
      <factory-class-name>
          com.hazelcast.examples.MySSLContextFactory
      </factory-class-name>
      <properties>
        <property name="foo">bar</property>
      </properties>
    </ssl>
  </network>

Hazelcast provides a default SSLContextFactory, com.hazelcast.nio.ssl.BasicSSLContextFactory, which uses configured keystore to initialize SSLContext. You define keyStore and keyStorePassword, and you can set keyManagerAlgorithm (default SunX509), trustManagerAlgorithm (default SunX509) and protocol (default TLS).缓存

Hazelcast 提供一个默认SSLContextFactory和com.hazelcast.nio.ssl.BasicSSLContextFactory。使用 keystore配置SSLContext。定义keyStore和 keyStorePassword,setkeyManagerAlgorithm(默认 SunX509),trustManagerAlgorithm(默认SunX509)和协议(缺省TLS)。

<network>
    ...
    <ssl enabled="true">
      <factory-class-name>
          com.hazelcast.nio.ssl.BasicSSLContextFactory
      </factory-class-name>
      <properties>
        <property name="keyStore">keyStore</property>
        <property name="keyStorePassword">keyStorePassword</property>
        <property name="keyManagerAlgorithm">SunX509</property>
        <property name="trustManagerAlgorithm">SunX509</property>
        <property name="protocol">TLS</property>
      </properties>
    </ssl>
  </network>

\套接字拦截器

Hazelcast 套接字链接时能够截取前一个节点加入集群或一个客户端链接到一个节点。这可以添加自定义钩子到链接程序并执行(使用Kerberos身份检查,等)。实现 成员的com.hazelcast.nio.MemberSocketInterceptor 和客户的com.hazelcast.nio.SocketInterceptor。实例以下:

<network>
...
<socket-interceptor enabled="true">
  <class-name>com.hazelcast.examples.MySocketInterceptor</class-name>
  <properties>
    <property name="kerberos-host">kerb-host-name</property>
    <property name="kerberos-config-file">kerb.conf</property>
  </properties>
</socket-interceptor>
...
</network>

对称加密

Hazelcast容许您加密整个套接字上Hazelcast全部成员之间的沟通。加密是基于Java加密体系结构的。在对称加密中,每一个节点使用相同的密钥,因此密钥是共享的。这是一个对称加密的示例配置:

<symmetric-encryption enabled="true">
  <!--encryption algorithm such as
    DES/ECB/PKCS5Padding,
    PBEWithMD5AndDES,
    Blowfish,
    DESede
    -->
    <algorithm>PBEWithMD5AndDES</algorithm><!--加密方式-->

    <!-- salt value to use when generating the secret key -->
    <salt>thesalt</salt>

    <!-- pass phrase to use when generating the secret key -->
    <password>thepass</password>

    <!-- iteration count to use when generating the secret key -->
  <iteration-count>19</iteration-count><!--迭代次数-->
</symmetric-encryption>

6

 

集 群分组,Hazelcast分配关键对象到分区使用一致的散列算法。这些分区分配给节点。一个条目按照该条目被分配好的key存储在一个节点的分区。默认 分区总数是271,你能够改变它的配置propertyhazelcast.map.partition.count。除了这些分区,也有分区的备份副 本。备份分区能够有多个拷贝根据配置中定义的备份数,如第一备份分区,第二备份分区,等。一个节点不能持有一个以上的分区的副本(全部权或备份)。默认情 况下,Hazelcast分配分区及其备份副本随机的平均分配在集群节点中,假设集群中的全部节点都是相同的。可是若是某些节点共享相同的JVM或物理机 器或底盘,你想要这些节点的备份分配给在另外一台机器或底盘节点吗?若是某些节点的处理或记忆能力是不一样的,您不但愿同等数量的分区分配给全部节点?你能够 将节点聚合在同一个JVM(或物理机器)或使节点位于相同的底盘,亦或你能够给节点群建立相同的能力。咱们称这些群组为分区集群。分区分配给这些分区集群 而不是单一节点。分区的备份位于另外一个分区集群。当你启用分区分组,Hazelcast为您配置分区组提供了三个选择。group- type=”HOST_AWARE” /”CUSTOM”/”PER_MEMBER”

You can do custom grouping using Hazelcast’s interface matching configuration. This way, you can add different and multiple interfaces to a group. You can also use wildcards in the interface addresses. For example, the users can create rack aware or data warehouse partition groups using custom partition grouping安全

能够自定义分组使用Hazelcast匹配的接口配置,经过这种方式,能够添加多个不一样的接口组。还能够在接口地址使用通配符。例如,用户能够建立架机架感知或数据仓库分区组使用自定义分区分组:

<partition-group enabled="true" group-type="CUSTOM">
<member-group>
  <interface>10.10.0.*</interface>
  <interface>10.10.3.*</interface>
  <interface>10.10.5.*</interface>
</member-group>
<member-group>
  <interface>10.10.10.10-100</interface>
  <interface>10.10.1.*</interface>
  <interface>10.10.2.*</interface>
</member-group
</partition-group>

7

执行服务器

<executor-service name="exec">
   <pool-size>1</pool-size>
   <queue-capacity>10</queue-capacity>
   <statistics-enabled>true</statistics-enabled>
</executor-service>

pool-size: The number of executor threads per Member for the Executor.
queue-capacity: Executor’s task queue capacity.
statistics-enabled: Some statistics like pending operations count, started operations count, completed operations count, cancelled operations count can be retrieved by setting this parameter’s value as true. The method for retrieving the statistics is getLocalExecutorStats().服务器

pool-size:每一个执行者成员执行器的线程数量

queue-capacity: 执行者的任务队列容量

statistics-enabled: 一些统计数据就像等待操做数,操做数,操做完成,取消操做数能够经过设置该参数的值是真来进行检索,检索统计数据的方法是getLocalExecutorStats()。

8

\

<queue name="default">
    <!--
        队列的最大值。当JVM本地队列大小达到最大值时,全部put/offer操做将被封锁,直到队列的大小降低低于JVM的最大值。值为0和Integer.MAX_VALUE之间的任何整数。0表示Integer.MAX_VALUE. 默认值为0。
    -->
    <max-size>0</max-size>
    <!--
        备份的数量。若是1设置为备份数量,也就是说为了安全将map上的全部条目复制到另外一个JVM上
        。0表示没有备份。
    -->
    <backup-count>1</backup-count>

    <!--
       异步备份数量,0表示没有备份
    -->
    <async-backup-count>0</async-backup-count>
    <!--空队列生存时间,-1表示一直存在-->
    <empty-queue-ttl>-1</empty-queue-ttl>
</queue>

Hazelcast 分布式队列有一个默认的同步备份。经过这个备份,当一个集群成员的一个队列中止时,另外一个成员拥有备份将继续下去。所以,不会有任何项目丢失。您可使用 backup-count元素声明式配置定义同步备份的数量。队列也能够异步备份,您可使用async-backup-count元素配置定义备份数 量。

max-size元素定义队列的最大值。

当你想清除一段时间未使用的或空的队列您可使用empty-queue-ttl元素进行配置。若是为该元素定义一个值(时间以秒为单位),那么你的队列保持空或未使用超过你给的时间就会被清理,定义为-1是表示一直存在。

9

\多重映射

<hazelcast>
  <multimap name="default">
    <backup-count>0</backup-count>
      <async-backup-count>1</async-backup-count>
      <value-collection-type>SET</value-collection-type>
      <entry-listeners>
        <entry-listener include-value="false" local="false">
            com.hazelcast.examples.EntryListener
        </entry-listener>
    </entry-listeners>   
  </map>
</hazelcast>

多重映射的配置里面,backup-count:同步备份数量;

async-backup-count:异步备份数量;

value-collection-type:集合值得类型,能够设置为Set或List

entry-listers/entry-lister:详见

10

\

<list name="default">
   <backup-count>1</backup-count>
   <async-backup-count>0</async-backup-count>
   <max-size>10</max-size>
   <item-listeners>
    <item-listener>
        com.hazelcast.examples.ItemListener
    </item-listener>
  </item-listeners>
</list>

\

<set name="default">
   <backup-count>1</backup-count>
   <async-backup-count>0</async-backup-count>
   <max-size>10</max-size>
   <item-listeners>
  <item-listener>
  com.hazelcast.examples.ItemListener
  </item-listener>
   <item-listeners>
</set>

backup-count:数量的同步备份。列表是一个分区数据结构,所以全部条目列表的驻留在一个分区中。当这个参数是’ 1 ‘,集群中的另外一个节点作一个备份。’ 2 ‘,2个节点的备份。

async-backup-count:异步备份的数量。

max-size:这个列表条目的最大数量。

item-listeners:容许您添加侦听器列表项(侦听器类)。若是你想项目事件包含项目值还能够设置属性include-value为true,若是你想在本地节点监听项目,能够将本地属性设置为true。

11

\

JobTracker 配置用来设置Hazelcast MapReduce框架的行为。每一个JobTracker都可以运行多个MapReduce job;一个配置是做为全部相同JobTracker所创建的工做的共享资源。这个配置可以彻底控制使用时的预期负载行为和线程数量。下面的代码就是一个 典型的jobTracker配置:

<jobtracker name="default">
  <max-thread-size>0</max-thread-size>
  <!-- Queue size 0 means number of partitions * 2 -->
  <queue-size>0</queue-size>
  <retry-count>0</retry-count>
  <chunk-size>1000</chunk-size>
  <communicate-stats>true</communicate-stats>
  <topology-changed-strategy>CANCEL_RUNNING_OPERATION</topology-changed-strategy>
</jobtracker>

max-thread-size: Configures the maximum thread pool size of the JobTracker.
queue-size: Defines the maximum number of tasks that are able to wait to be processed. A value of 0 means an unbounded queue. Very low numbers can prevent successful execution since job might not be correctly scheduled or intermediate chunks might be lost.
retry-count: Currently not used. Reserved for later use where the framework will automatically try to restart / retry operations from an available save point.
chunk-size: Defines the number of emitted values before a chunk is sent to the reducers. If your emitted values are big or you want to better balance your work, you might want to change this to a lower or higher value. A value of 0 means immediate transmission, but remember that low values mean higher traffic costs. A very high value might cause an OutOfMemoryError to occur if the emitted values do not fit into heap memory before being sent to the reducers. To prevent this, you might want to use a combiner to pre-reduce values on mapping nodes.
communicate-stats: Defines if statistics (for example, statistics about processed entries) are transmitted to the job emitter. This can show progress to a user inside of an UI system, but it produces additional traffic. If not needed, you might want to deactivate this.
topology-changed-strategy: Defines how the MapReduce framework will React on topology changes while executing a job. Currently, only CANCEL_RUNNING_OPERATION is fully supported, which throws an exception to the job emitter (will throw a com.hazelcast.mapreduce.TopologyChangedException).网络

max-thread-size:JobTracker配置的线程池最大的值。

queue-size:定义等待处理任务大小的最大值。值为0时表示一个无界的队列。很是低的数字能够防止成功执行以来的工做可能不是正确的安排或中间块可能丢失。

retry-count:目前不使用。保留以备后用,使用这个框架会自动尝试从一个可用的保存点从新启动/重试操做。

chunk- size:定义了在chunk传递到the reducers前emitted values的数量。若是你的emitted values大或你想要更好的平衡你的工做,你可能想改成更低或更高的值,值为0时表示当即传输,但请记住,低值意味着更高的传递成本。若是发送到the reducers以前emitted values不符合堆内存,一个很高的值可能会致使一个OutOfMemoryError发生。为了不这种状况,您可能想要在映射节点上对pre- reduce values 使用一个组合器。

communicate-stats:若是统计数据被传送到工做发生器是,这里能够显示UI系统内的用户,可是会产生额外的流量,若是不须要,能够选择关闭。

topology- changed-strategy:定义了MapReduce框架的执行工做时对拓扑变化的影响。目前,只有 CANCEL_RUNNING_OPERATION彻底支持,向工做发射器抛出一个异常(将抛出一个 com.hazelcast.mapreduce.TopologyChangedException)。

12

\信号配置

<semaphore name="default">
    <initial-permits>0</initial-permits>
    <backup-count>1</backup-count>
    <async-backup-count>0</async-backup-count>
</semaphore>

initial-permits:在并发存取的情况下,线程的数目。例如,设为3,那么并发存取限制为3条线;
backup-count: 同步备份的数目;
async-backup-count: 同步备份的数目。数据结构

13

\

<reliable-topic name="default">
    <read-batch-size>10</read-batch-size>
    <topic-overload-policy>BLOCK</topic-overload-policy>
    <statistics-enabled>true</statistics-enabled>
</reliable-topic>

statistics-enabled: 容许或者禁止reliable topic使用统计量集合,默认值为true;
read-batch-size:Reliable Topic从群组中读取到的消息的最小数量,默认值为10;
topic-overload-policy:控制超负载的策略,可用的值为DISCARD_OLDEST,DISCARD_NEWST,BLOCK和ERROR,默认值为BLOCK。

14

\环形缓冲区

<ringbuffer name="default">
    <capacity>10000</capacity>
    <backup-count>1</backup-count>
    <async-backup-count>0</async-backup-count>
    <time-to-live-seconds>30</time-to-live-seconds>
    <in-memory-format>BINARY</in-memory-format>
</ringbuffer>

capacity:Ringbuffer内存的大小,默认值为10000;
time-to-live-seconds:项目在Ringbuffer中保留的时间,若是设为0,那么它是不可用的,默认值为0;
backup-count: 同步备份的数量,默认值为1;
async-backup-count: 同步备份的数量,默认值为0;
in-memory-format: 当项目存储在Ringbuffer中时的格式,可用的值为OBJECT和BINARY,默认值为BINARY。

15

\序列化

<serialization>
    <portable-version>0</portable-version>
</serialization>

portable-version:定义了便携式序列化的版本,便携式版本能够区分两个相同的类的,一旦类稍有改变 ,例如增长/移除方法,或将方法的名称进行改变。

16

\服务

<services enable-defaults="true"/>

启用该服务。

17#Map标签

Map概述

Hazelcast Map(即IMAP)扩展了Java.util.concurrent.ConcurrentMap接口,继承了java.util.Map类。它是Java map的分布式实现。咱们能够从Hazelcast map中读或写经过get和put方法。

in-memory-format标签

该标签决定数据在内存中存储的方式。它有三种值:BINARY,OBJECT,NATIVA。BINARY是默认的选项,将数据存储为连续的二进制的格式;若是设置为OBJECT,数据将会以非连续的形式存储;数据将会被存储在JVM的非堆区。

backup-count标签

同步备份的数目,若是设的值为1,为了防止发生错误,map的全部内容将被复制到另外一个JVM。若是数目为0,就意味着不进行备份。

async-backup-count

同步备份的数目,0意味着不备份。

read-backup-data

是否能够读取本地的备份接口,默认值为false使之具备更强的一致性。容许读取备份数据会给用户更多的权利。

time-to-live-seconds

入口在map中存活的最大的秒数。存活的时间比设置的时间长,而且没有更新的值时,入口将会自动从map中释放。它的取值范围是0到Integer.MAX_VALUE。0意味着无穷大,而且默认值为0。

<time-to-live-seconds>0</time-to-live-seconds>

max-idle-seconds

在map中每一个entry保持空闲的最大时间。

<max-idle-seconds>0</max-idle-seconds>

eviction-policy

entry的释放政策,有效值为:NONE,不释放;LRU(Least Recently Used),释放最少的最近使用过的entry;LFU(Least Frequently Used),释放最少的最常使用的entry。

<eviction-policy>LRU</eviction-policy>

max-size

map的最大数目(即,map最大的entry数)。当达到最大数目时,map将会按已定义的释放政策进行操做。它有四种属 性:PER_NODE,JVM中最大的map entry数;PER_PARTITION,在各分区中最大的entry数;USED_HEAP_SIZE,在JVM中以兆计的最大使用堆 数;USED_HEAP_PERCENTAGE,在JVM中,使用堆的最大百分比。

<max-size policy="PER_NODE">100000</max-size>

eviction-percentage

当达到最大数目时,被释放的百分比。若是值为25,那么25%的接口将会被释放。

<eviction-percentage>25</eviction-percentage>

min-eviction-check-millis

检测部分map是否被释放前通过的最短期,以毫秒计。默认值为100毫秒。

<min-eviction-check-millis>100</min-eviction-check-millis>

merge-policy

当从分裂中回复时,在小集群里的map接口将会合并到大的集群中取,基于这里设置的政策。当一个接口合并到集群中时 ,集群中可能已经存在拥有相同键得接口。但对于相同的键,它们的数值可能不尽相同。那么,该给这个键设置怎样的值呢?这个政策将会解决这个冲突。默认的政 策为PutIfAbsentMapMergePolicy.
如下为内置的合并政策:
com.hazelcast.map.merge.PassThroughMergePolicy,若是没有对于键没有存在的接口,那么接口会添加进集群;
com.hazelcast.map.merge.PutIfAbsentMapMergePolicy,若是在集群中不存在这样的集成接口,接口就会被加入 ;
com.hazelcast.map.merge.HigherHitsMapMergePolicy ,具备更高值得接口会被加入。
com.hazelcast.map.merge.LatestUpdateMapMergePolicy ,最新的接口将被加入。

<merge-policy>com.hazelcast.map.merge.PassThroughMergePolicy</merge-policy>

near-cache

near-cache提供了一个对map集群的本地视图,它对于高速缓存是很是理想的。每个集群成员会从分布式的map中保存一份entry到本 地种。这减小了常常须要读取时的网络缓存。可是,若是entry须要常常更新的话,由于其余集群成员的减小,就会致使性能的降低。

invalidate-on-change

决定是否释放缓存的entry,若是entry更新或者移除了。

<near-cache>
        <max-size>1000</max-size>
        <time-to-live-seconds>0</time-to-live-seconds>
        <max-idle-seconds>600</max-idle-seconds>
        <eviction-policy>LRU</eviction-policy>
        <invalidate-on-change>true</invalidate-on-change>
    </near-cache>
相关文章
相关标签/搜索