Ignite 2.1.0新特性Durable Memory学习

Ignite自带存储 vs 第三方持久化

Apache Ignite Native Persistence has the following advantages over 3rd party stores (RDBMS, NoSQL, Hadoop) that can be used as an alternative persistence layer for an Apache Ignite cluster:

  • Ability to execute SQL queries over the data that is both in memory and on disk which means that Apache Ignite can be used as a memory-optimized distributed SQL database.
  • No need to have all the data and indexes in memory. The Ignite Persistence allows storing a superset of data on disk and only most frequently used subsets in memory.
  • Instantaneous cluster restarts. If the whole cluster goes down there is no need to warm up the memory by preloading data from the Ignite Persistence. The cluster becomes fully operational once all the cluster nodes are interconnected with each other.
  • Data and indexes are stored in a similar format both in memory and on disk that helps to avoid expensive transformations while the data sets are being moved between memory and disk.
  • An ability to create full and incremental cluster snapshots by plugging-in 3rd party solutions.

使用

打开这个Ignite native persistence的开关只需要传一个参数PersistentStoreConfiguration 到IgniteConfiguation中:

<bean class="org.apache.ignite.configuration.IgniteConfiguration">
  <!-- Enabling Apache Ignite Native Persistence. -->
  <property name="persistentStoreConfiguration">
    <bean class="org.apache.ignite.configuration.PersistentStoreConfiguration"/>
  </property>

  <!-- Additional setting. -->
 
</bean>

集群在启动过程中不能修改数据,否则有些节点被修改了有些还没有,就会出问题,这里需要控制,调用

// Activating the cluster once all the cluster nodes are up and running.
ignite.active(true);

默认文件路径为:

${IGNITE_HOME}/work

也可以用PersistentStoreConfiguration.setPersistentStorePath(...)来修改这个路径。

 

Write-Ahead Log (WAL)

当写入文件时,并不是实时更新的,应为会影响性能,所以会先加到WAL的尾端。

WAL的目的是为了将对文件的更新延迟,并且能够从单点故障或者整个集群故障中恢复,集群可以恢复到最新的成功提交的事务那里。

WAL分成好多段,然后填入的时候是按序列填入的,当地一个填满,这部分内容会被拷到WAL Archive并且保留被方法PersistentStoreConfiguration.walHistorySize定义好的一段时间。当第一段正在被拷贝到Archive的时候,第二段就变成活跃的WAL文件了,会接受从应用端过来的更新。默认会有十段。可以用PersistentStoreConfiguration.setWalSegmentSize来设置。

WAL是Ignite本地存储的精髓部分。主要角色是1尽可能快的更新磁盘,2恢复到一个稳定的状态。

 

CheckPointing

鉴于WAL的天性,它会持续增长并且一个集群从WAL中全部恢复可能需要大量的时间。为了解决这个,Ignite本地存储和持久内存支持Checkpoint过程。

checkpoint是一个过程,拷贝脏页从RAM到文件,脏页的定义是只更新了RAM但是还没到文件。(an update was just appended to the WAL)

这个过程可以实现保证文件中的页是最新的状态,允许从WAL Archive中移除过期的WAL段。

Checkpointing is triggered periodically depending on the frequency set in your Native Persistence configuration or other parameters.

 

事务性保证

Ignite本地存储是ACID,分布式store。每个事务先更新到WAL。恢复也不会漏下。

 

生产调优

如果一个集群跑在Unix环境然后本次存储用的是SSD,那么pageSize设置成4KB而不是2KB,那么checkPoint的效率会提升三倍。

<bean class="org.apache.ignite.configuration.IgniteConfiguration">
   ...		
   <property name="memoryConfiguration">
    		<bean class="org.apache.ignite.configuration.MemoryConfiguration">
        		<!-- Setting the page size to 4 KB -->
            <property name="pageSize" value="#{4 * 1024}"/>
        </bean>
    </property>
    ...
</bean>

 

上生产需要考虑的问题

  1. 机器I/O是否能够承受
  2. 需要SSD,需要多大的磁盘?
  3. 怎么判断多节点全部active了
  4. 数据需要调整或者脏了
    1. 可以把{IGNITE_HOME}/work路径下的文件全部删掉,启动loader重新生成一遍

 

 

引用:https://apacheignite.readme.io/docs/distributed-persistent-store

转载于:https://my.oschina.net/u/2481460/blog/1535294

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值