Liferay 集群中在一个节点上上传照片另外一个节点无法看到的问题的解决
2012-07-09 08:35
441 查看
Reproduce the procedure:
上次他们有一个集群上的问题,就是从节点1的控制面板中,上传一个图片,然后关闭节点1, 从节点2中看不到这个图片。这个问题的流程如下:
Following are the steps for the clustering issues
Go to Control Panel.
Click on "Documents and Media" from Left Nav.
Add folder
Add Basic document . Browse Image
Add the Web content port let
And configure it to use the above add image.
我后来在深入研究这个过程之后,解决了这个问题:
解决方法1: 用数据库存储media资源,以Blob形式:
Solution:
(1) In each node ,add the following lines in ${liferay_home}/portal-ext.properties:
(2) In each node ,copy the portal-hbm-new.xml from the attachment to /ROOT/WEB-INF/classes/META-INF/ folder.
Reason for this solution:
When we add “Basic Document” to created folder in control panel ,the liferay system will do the following tasks:
You can read my article http://supercharles888.blog.51cto.com/609344/921761 for very detailed analysis process.
a. Add an entry in “DLFILEENTRY” table to stand for the new added document.
b. Add an entry in “DLFILEENTRYVERSION” table to record the version information of the new added document ,it will related to “DLFILEENTRY” table by foreign key “fileEntryId”
c. Update the new posted timestamp in “DLFOLDER” table ,which means the latest timestamp that this folder has been posted by some file.
d. Add an entry in “ASSETENTRY” table ,because file is also one kind of asset. This table will be related to “DLFILEENTRY” table by foreign key “classpk”
e. Upload the file to the store based on the liferay server configuration:
In DLStoreImpl class addFile method:
Actually ,the Liferay framework has supplied 5 kinds of implementations for Store :
The default one is FileSystemStore, and it was configured in portal.properties:
If we use the FileSystemStore ,the default location that store the file(such as image) is in each nodes $liferay_home/data/document_library, once a node is shutdown ,although the session is replicated to other node ,but the resource can’t be copied to other node (Which means ,the location of resource is not a Single point), so when the backup node need resource ,but the resource is in a shutdowned server ,how can this backup node get it?
That’s the reason.
So we changed it to DBStore ,since all nodes share the same database(Database is a Single point in cluster environment) ,so if we use database to store the resource ,all nodes can access it .so it work as our expected. In this way ,the resource (image for example) are stored in the form of “Blob” ,and stored in “DLCONTENT” table:
Reason why we need to re-configure the hibernate-configs?
If you read my solution carefully ,you can see that I don’t use the default hibernate.configs ,I change the “META-INF/portal-hbm.xml” to “META-INF/portal-hbm-new.xml” and do some modifications to this mapping file .Why?
Because when you persist the resource to “DLCONTENT” table , you may meet with the following exception:
The reason is in portal-hbm.xml Line 1416, the default type for dataBlob is “org.hibernate.type.BlobType” ,but when we want to persist into database ,what we want is “java.sql.Blob”
So I modify this type of dataBlob in portal-hbm-new.xml and let Liferay framework to read this new file (portal-hbm-new.xml) instead of the default( portal-hbm.xml) ,then problem solved.
解决方法2:用共享的文件服务器存储media资源
Suppose we put the shared folder in 192.168.0.138, this physical ip address is neither the same as node1 nor node2.
1. Keep everything setting default ,then in each node ,add the following line in ${liferay_home}/portal-ext.properties (You must use “ \\” instead of “\” as path separator):
#added by charles to use the file store to fixed the cluster
dl.store.file.system.root.dir=\\\\192.168.0.238\\WalmartShare\\Platform\\ClusterSharedFolder\\data\\document_library
2. Then restart the clustering environment and do the procedure as you supplied, you will see this issue is fixed.
You can check the location of shared file system,and will find the media files has been uploaded to this location successfully.
上次他们有一个集群上的问题,就是从节点1的控制面板中,上传一个图片,然后关闭节点1, 从节点2中看不到这个图片。这个问题的流程如下:
Following are the steps for the clustering issues
Go to Control Panel.
Click on "Documents and Media" from Left Nav.
Add folder
Add Basic document . Browse Image
Add the Web content port let
And configure it to use the above add image.
我后来在深入研究这个过程之后,解决了这个问题:
解决方法1: 用数据库存储media资源,以Blob形式:
Solution:
(1) In each node ,add the following lines in ${liferay_home}/portal-ext.properties:
#added by charles to use the DBStore instead of default FileSystemStore when configuring the document library dl.store.impl=com.liferay.portlet.documentlibrary.store.DBStore #added by charles to fix the dbStore problem ,use the new portal hibernate mapping file hibernate.configs=\ META-INF/mail-hbm.xml,\ META-INF/portal-hbm-new.xml,\ META-INF/ext-hbm.xml
(2) In each node ,copy the portal-hbm-new.xml from the attachment to /ROOT/WEB-INF/classes/META-INF/ folder.
Reason for this solution:
When we add “Basic Document” to created folder in control panel ,the liferay system will do the following tasks:
You can read my article http://supercharles888.blog.51cto.com/609344/921761 for very detailed analysis process.
a. Add an entry in “DLFILEENTRY” table to stand for the new added document.
b. Add an entry in “DLFILEENTRYVERSION” table to record the version information of the new added document ,it will related to “DLFILEENTRY” table by foreign key “fileEntryId”
c. Update the new posted timestamp in “DLFOLDER” table ,which means the latest timestamp that this folder has been posted by some file.
d. Add an entry in “ASSETENTRY” table ,because file is also one kind of asset. This table will be related to “DLFILEENTRY” table by foreign key “classpk”
e. Upload the file to the store based on the liferay server configuration:
In DLStoreImpl class addFile method:
public void addFile( long companyId, long repositoryId, String fileName, boolean validateFileExtension, File file) throws PortalException, SystemException { validate(fileName, validateFileExtension, file); if (PropsValues.DL_STORE_ANTIVIRUS_ENABLED) { AntivirusScannerUtil.scan(file); } store.addFile(companyId, repositoryId, fileName, file); }
Actually ,the Liferay framework has supplied 5 kinds of implementations for Store :
The default one is FileSystemStore, and it was configured in portal.properties:
# Set the name of a class that implements # com.liferay.portlet.documentlibrary.store.Store. The # document library server will use this to persist documents. # #dl.store.impl=com.liferay.portlet.documentlibrary.store.AdvancedFileSystemStore #dl.store.impl=com.liferay.portlet.documentlibrary.store.CMISStore #dl.store.impl=com.liferay.portlet.documentlibrary.store.DBStore dl.store.impl=com.liferay.portlet.documentlibrary.store.FileSystemStore #dl.store.impl=com.liferay.portlet.documentlibrary.store.JCRStore #dl.store.impl=com.liferay.portlet.documentlibrary.store.S3Store
If we use the FileSystemStore ,the default location that store the file(such as image) is in each nodes $liferay_home/data/document_library, once a node is shutdown ,although the session is replicated to other node ,but the resource can’t be copied to other node (Which means ,the location of resource is not a Single point), so when the backup node need resource ,but the resource is in a shutdowned server ,how can this backup node get it?
That’s the reason.
So we changed it to DBStore ,since all nodes share the same database(Database is a Single point in cluster environment) ,so if we use database to store the resource ,all nodes can access it .so it work as our expected. In this way ,the resource (image for example) are stored in the form of “Blob” ,and stored in “DLCONTENT” table:
Reason why we need to re-configure the hibernate-configs?
If you read my solution carefully ,you can see that I don’t use the default hibernate.configs ,I change the “META-INF/portal-hbm.xml” to “META-INF/portal-hbm-new.xml” and do some modifications to this mapping file .Why?
Because when you persist the resource to “DLCONTENT” table , you may meet with the following exception:
The reason is in portal-hbm.xml Line 1416, the default type for dataBlob is “org.hibernate.type.BlobType” ,but when we want to persist into database ,what we want is “java.sql.Blob”
So I modify this type of dataBlob in portal-hbm-new.xml and let Liferay framework to read this new file (portal-hbm-new.xml) instead of the default( portal-hbm.xml) ,then problem solved.
解决方法2:用共享的文件服务器存储media资源
Suppose we put the shared folder in 192.168.0.138, this physical ip address is neither the same as node1 nor node2.
1. Keep everything setting default ,then in each node ,add the following line in ${liferay_home}/portal-ext.properties (You must use “ \\” instead of “\” as path separator):
#added by charles to use the file store to fixed the cluster
dl.store.file.system.root.dir=\\\\192.168.0.238\\WalmartShare\\Platform\\ClusterSharedFolder\\data\\document_library
2. Then restart the clustering environment and do the procedure as you supplied, you will see this issue is fixed.
You can check the location of shared file system,and will find the media files has been uploaded to this location successfully.
相关文章推荐
- greenplum集群发生了某个节点报“could not open relation 1663/16384/32749972: 无此文件或目录”后再无法启动后的一个解决方法-唐成
- 【ecmall】解决无法上传店铺logo和banner照片问题
- 【ecmall】解决无法上传店铺logo和banner照片问题 (三)
- 【ecmall】解决无法上传店铺logo和banner照片问题
- VMWARE NAT模式下虚拟机集群节点无法连接外网问题解决
- 【ecmall】解决无法上传店铺logo和banner照片问题 (转)
- 【ecmall】解决无法上传店铺logo和banner照片问题(二)
- [Android]浮层视频效果,在另外一个Window使用SurfaceView无法正常显示的问题排查与解决
- Android 上传头像,解决小米3等手机无法直接得到裁剪照片问题
- HP unix集群一个节点无法服务遇到的诡异问题
- 【ecmall】解决无法上传店铺logo和banner照片问题(一)
- 利用exif.js插件解决ios手机上传竖拍照片旋转90度问题
- 解决集群开启Kerberos之后 storm UI在本地无法打开的问题(mac os+safari)
- 在线修改图片尺寸缩放网站(完美解决图片过大无法上传问题)
- 一个数以最少步骤分解为另外两个数和差问题的解决
- Android手机连接电脑过后,无法看到Logcat内容的问题解决方法
- 如何解决Oracle RAC 安装集群软件或数据库时无法自动识别节点
- Mac下svn问题——“.a”(静态库)文件无法上传解决
- 细谈 Web Api 图片上传,在使用 Task.ContinueWith 变量无法赋值问题的解决办法!
- 解决“listView点击一个Item,另外几个Item也跟着改变”的问题