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>
相關文章
相關標籤/搜索