H2 is written in Java, in-memory HSQL databases, can be embedded in Java applications or run in the client-server mode.
H2 supports a simple clustering / high availability mechanism. The architecture is: two database servers run on two different computers, and on both computers is a copy of the same database. If both servers run, each database operation is executed on both computers. If one server fails (power, hardware or network failure), the other server can still continue to work. From this point on, the operations will be executed only on one server until the other server is back up.
Clustering can only be used in the server mode (the embedded mode does not support clustering, but maybe oneday in the future, the 'mixed clustering mode' will add this to the feature request list; it should be quite easy to implement.). It is possible to restore the cluster without stopping the server, however it is critical that no other application is changing the data in the first database while the second database is restored, so restoring the cluster is currently a manual process.
Suppose two server:
server1: java -cp "h2.jar;%H2DRIVERS%;%CLASSPATH%" org.h2.tools.Server -tcp -tcpPort 9101 -baseDir server1
server2: java -cp "h2.jar;%H2DRIVERS%;%CLASSPATH%" org.h2.tools.Server -tcp -tcpPort 9102 -baseDir server2
Createcluster1:
java -cp "h2.jar;%H2DRIVERS%;%CLASSPATH%" org.h2.tools.CreateCluster -urlSource jdbc:h2:tcp://localhost:9101/./test -urlTarget jdbc:h2:tcp://localhost:9102/./test -user sa -serverlist localhost:9101,localhost:9102
Createcluster2:
java -cp "h2.jar;%H2DRIVERS%;%CLASSPATH%" org.h2.tools.CreateCluster -urlSource jdbc:h2:tcp://localhost:9102/./test -urlTarget jdbc:h2:tcp://localhost:9101/./test -user sa -serverlist localhost:9101,localhost:9102
In this mode, Read-only queries(such as select) are only executed against the first cluster node - server1(9101), but all other statements are executed against all nodes. There is currently no load balancing made to avoid problems with transactions. The following functions may yield different results on different cluster nodes and must be executed with care: RANDOM_UUID(), SECURE_RAND(), SESSION_ID(), MEMORY_FREE(), MEMORY_USED(), CSVREAD(), CSVWRITE(), RAND() [when not using a seed]. Those functions should not be used directly in modifying statements (for example INSERT, UPDATE, or MERGE). However, they can be used in read-only statements and the result can then be used for modifying statements.
Data restore:
If server2 crash, insert/update/delete statements are only submitted to server1 without exception. we should delete server2's db file first, and then restart server2 mannually, and then redo Createcluster1 command, H2 will do data synchronization automatically (from server1 to server2), and after that, insert/update/delete statements will be executed against server1 and server2.
If server1 crash, we should delete server1's db file first, and then restart server1, then do another Createcluster2 command instead of Createcluster1 , otherwise the exception(target db's file should be empty) will be thrown, that's to say, H2's culstering data synchronization is baed on -urlSource and -urlTarget, and the target db file must be empty. But in this way, the select queries will be executed against server2, not server1.
分享到:
相关推荐
几篇关于空间数据库的聚类算法的研究《基于空间数据库的数据挖掘方法研究》《基于SVM的空间数据库的层次聚类分析》《从空间数据库发现聚类》
应用于大型数据库的聚类技术研究
最新纯JAVA数据库,支持集群,支持私有内存数据库,
数据库挖掘聚类分析PPT学习教案.pptx
该人脸数据库用于人脸识别,聚类分析,图像处理等问题
本文件为常见聚类算法测试数据集 ,UCI上常用的聚类算法数据集
聚类分析常用的人工数据集,包括:UCI:wine、Iris、yeast,还有4k2_far、leuk72_3k等数据集。它们在聚类分析、数据挖掘、机器学习、模式识别领域经常用到。
聚类数据集,有人工、真实数据集。带标签
使用mysql 进行数据库连接,把分析聚类的结果再存储到 mysql数据库中,代码实现了连接数据库, 分析数据,把结果返回数据库的相关内容。有注释。
模式识别中k均值聚类的程序及数据:包括初始中心点的选择、新中心点的选择,距离的定义等
用于聚类方法的数据集,包括不同数目的块状聚类、月牙形、同心环形及螺旋形分布,可用于Kmeans、谱聚类等聚类方法的测试。
UCI常用数据集-聚类、分类
聚类数据集 %% 利用不同方法对债券样本进行聚类 %说明 %分别采用不同的方法,对数据进行聚类 %可以选择的pdist/clustering距离 % methods = {'euclidean'; 'seuclidean'; 'cityblock'; 'chebychev'; ... % '...
对聚类算法进行测试的数据
该数据集可以供广大数据挖掘爱好者们下载使用 经本人整理后已经做成了文本格式,有matlab 直接使用
内包含:模糊聚类 遗传算法聚类 层次聚类法的各方法以及动态聚类的各个算法
一些聚类常用的数据集,自己做实验也在用的,很好用也很齐全。
公共数据集,一共有30多中,包括iris、wine、seeds、bands、balance、zoo、wdbc、breasttissue等数据集 可用于分类聚类等
K均值聚类算法-对数据进行聚类分析,适合数据处理
模式识别聚类分析模式识别02