我们正在运行WebLogic Server 10.3.4中的Spring 3.0.5 Web应用程序
使用Sun JVM 1.6.0_x 64位的Solaris使用EhCache 2.4.2作为缓存
图书馆。 WLS被设置为具有2个节点的集群,两个节点都运行在
同样的物理机器,通过标准启动
startManagedWebLogic.sh
脚本(不使用NodeManager /管理控制台)。
在我们的ehcache.xml
中,我们设置了这样的磁盘存储路径:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false">
<!-- Location of persistent caches on disk -->
<diskStore path="ehcache.disk.store.dir" />
..
根据the 2.4 series documentation of EhCache 此设置允许设置JVM系统属性 指定磁盘存储路径。
使用。startManagedWebLogic.sh
设置系统属性
标准JAVA_OPTIONS
元素:
JAVA_OPTIONS="-Dehcache.disk.store.dir=/var/tmp/EhCache-${SERVER_NAME} <other stuff>"
export JAVA_OPTIONS
在此之前在同一脚本中定义SERVER_NAME
选项。
在启动群集节点期间,我可以看到正在设置的属性 正确(包装以提高可读性):
/usr/jdk/jdk1.6.0_21/bin/java -d64 -server -Xms4096m -Xmx4096m
-XX:PermSize=512m -XX:MaxPermSize=512m -XX:+UseParallelOldGC
-verbose:gc -XX:+PrintGCTimeStamps -Dweblogic.Name=Node2 [..]
-Dehcache.disk.store.dir=/var/tmp/EhCache-Node2 [..]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
weblogic.Server
然而,然后使用该应用程序,我可以看到占位符是 没有正确替换,因此使用占位符名称而不是 实际路径设置:
2012-08-22 11:52:59,426 DEBUG [net.sf.ehcache.CacheManager] - [Creating new CacheManager with default config]
2012-08-22 11:52:59,429 DEBUG [net.sf.ehcache.CacheManager] - [Configuring ehcache from classpath.]
..
2012-08-22 11:52:59,458 DEBUG [net.sf.ehcache.config.DiskStoreConfiguration] - [Disk Store Path: ehcache.disk.store.dir]
..
2012-08-22 11:52:59,586 DEBUG [net.sf.ehcache.store.DiskStore] - [IOException reading index. Creating new index. ]
2012-08-22 11:52:59,587 DEBUG [net.sf.ehcache.store.DiskStore] - [Index file ehcache.disk.store.dir/bookmarksCountForUserCache.index deleted.]
2012-08-22 11:52:59,588 DEBUG [net.sf.ehcache.store.DiskStore] - [Index file ehcache.disk.store.dir/bookmarksCountForUserCache.index created successfully]
2012-08-22 11:52:59,588 DEBUG [net.sf.ehcache.store.DiskStore] - [Index file dirty or empty. Deleting data file bookmarksCountForUserCache.data]
2012-08-22 11:52:59,597 DEBUG [net.sf.ehcache.store.MemoryStore] - [Initialized net.sf.ehcache.store.LruMemoryStore for bookmarksCountForUserCache]
2012-08-22 11:52:59,600 DEBUG [net.sf.ehcache.store.LruMemoryStore] - [bookmarksCountForUserCache Cache: Using SpoolingLinkedHashMap implementation]
2012-08-22 11:52:59,601 DEBUG [net.sf.ehcache.Cache] - [Initialised cache: bookmarksCountForUserCache]
在我的WLS域内的文件系统中,我可以看到一个新文件夹
创建了ehcache.disk.store.dir
,因此路径被解释为
相对路径。
我没有尝试使用普通字符串ehcache.disk.store.dir
使用标准模式${ehcache.disk.store.dir}
,但仅限于此
更改了使用${..}
创建的文件夹名称。
有没有办法使用system指定每个节点的磁盘存储路径 所有节点的属性和相同的EhCache配置?
我们的ehcache.xml
位于已部署的.war文件中,因此将成为。{1}}
所有群集节点都相同。更改应用程序代码不是一个选项,因为我们已经过了此版本的代码冻结。但是,我可以调整服务器的启动设置以设置系统属性,如上所述。
感谢您的帮助!
答案 0 :(得分:4)
使用-Dehcache.disk.store.dir
系统属性仍应有效
我也无法通过hibernate配置设置属性。
答案 1 :(得分:1)
您是否尝试过-Djava.io.tmpdir = / var / tmp / EhCache - $ {SERVER_NAME}?
答案 2 :(得分:-2)
不幸的是,我们无法弄清楚这种行为的原因。
作为解决方法,我们通过评论diskStore
中的ehcache.xml
元素完全禁用了磁盘存储:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false">
<!-- Location of persistent caches on disk
<diskStore path="ehcache.disk.store.dir" />
-->
..
并为所有缓存设置overflowToDisk
和diskPersistent
属性为false
。