Hazelcast配置文档(完整)

来源:互联网 发布:广州淘宝运营代理公司 编辑:程序博客网 时间:2024/05/18 00:29

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.

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

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.

对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.

利用内置适配器,可以对日志形式可以设置为以下四种方式: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>
0 0
原创粉丝点击