第一次尝试——fusepy——失败
调整示例
我刚拿
def write(self, path, buf, offset, fh):
os.lseek(fh, offset, os.SEEK_SET)
return os.write(fh, buf)
从
https://medium.com/the-python-corner/writing-a-fuse-filesystem-in-python-5e0f2de3a813
或更准确地说,来自
https://github.com/skorokithakis/python-fuse-sample/blob/master/passthrough.py
并将其替换为
def write(self, path, buf, offset, fh):
print('path: ', path, 'len(buf): ', len(buf), 'offset: ', offset)
return len(buf)
这意味着不会将任何内容写入已安装路径中的任何文件或 fh(= 文件句柄)。(os.write(...)
通常会返回写入字节的长度。)
将索引隐藏在我自己的文件系统后面
为了安装它,我使用了
cd /var/lib/tomcat7/webapps/geonetwork/WEB-INF/data/
mv ./index/ ./index_for_fuse/
mkdir ./index/
python3 /opt/python-fuse-sample/passthrough.py ./index_for_fuse/ ./index/
错误 1
2018-07-24 12:02:07,300 ERROR [jeeves.engine] - {Stack=java.lang.RuntimeException: Unable to create directory: /var/lib/tomcat7/webapps/geonetwork/WEB-INF/data/index
at org.fao.geonet.GeonetworkDataDirectory.setResourceDir(GeonetworkDataDirectory.java:323)
at org.fao.geonet.GeonetworkDataDirectory.setDataDirectory(GeonetworkDataDirectory.java:201)
at org.fao.geonet.GeonetworkDataDirectory.<init>(GeonetworkDataDirectory.java:61)
at org.fao.geonet.Geonetwork.start(Geonetwork.java:165)
at jeeves.server.JeevesEngine.initAppHandler(JeevesEngine.java:600)
at jeeves.server.JeevesEngine.init(JeevesEngine.java:206)
at jeeves.server.sources.http.JeevesServlet.init(JeevesServlet.java:91)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1240)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1184)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5256)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5539)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
at java.lang.Thread.run(Thread.java:748)
, Exception=java.lang.RuntimeException: Unable to create directory: /var/lib/tomcat7/webapps/geonetwork/WEB-INF/data/index, Message=Unable to create directory: /var/lib/tomcat7/webapps/geonetwork/WEB-INF/data/index, Handler=org.fao.geonet.Geonetwork, Error=Raised exception while starting appl handler. Skipped.}
解决方案 1
把它放在代码中:
FUSE(Passthrough(root), mountpoint, nothreads=True, foreground=True, debug=True, allow_other=True)
尤其allow_other=True
重要的是,Tomcat可以写入文件夹。在这里找到:
https://github.com/fusepy/fusepy/wiki/Sharing-fusepy-mount-via-Samba
错误 2
Exception in thread "Lucene Merge Thread #0" org.apache.lucene.index.MergePolicy$MergeException: java.io.EOFException: read past EOF: MMapIndexInput(path="/var/lib/tomcat7/webapps/geonetwork/WEB-INF/data/index/taxonomy/_1.fnm")
at org.apache.lucene.index.ConcurrentMergeScheduler.handleMergeException(ConcurrentMergeScheduler.java:541)
at org.apache.lucene.index.ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:514)
Caused by: java.io.EOFException: read past EOF: MMapIndexInput(path="/var/lib/tomcat7/webapps/geonetwork/WEB-INF/data/index/taxonomy/_1.fnm")
at org.apache.lucene.store.ByteBufferIndexInput.readByte(ByteBufferIndexInput.java:77)
at org.apache.lucene.store.DataInput.readInt(DataInput.java:84)
at org.apache.lucene.store.ByteBufferIndexInput.readInt(ByteBufferIndexInput.java:128)
at org.apache.lucene.codecs.CodecUtil.checkHeader(CodecUtil.java:126)
at org.apache.lucene.codecs.lucene40.Lucene40FieldInfosReader.read(Lucene40FieldInfosReader.java:56)
at org.apache.lucene.index.SegmentCoreReaders.<init>(SegmentCoreReaders.java:101)
at org.apache.lucene.index.SegmentReader.<init>(SegmentReader.java:57)
at org.apache.lucene.index.ReadersAndLiveDocs.getMergeReader(ReadersAndLiveDocs.java:153)
at org.apache.lucene.index.IndexWriter.mergeMiddle(IndexWriter.java:3635)
at org.apache.lucene.index.IndexWriter.merge(IndexWriter.java:3303)
at org.apache.lucene.index.ConcurrentMergeScheduler.doMerge(ConcurrentMergeScheduler.java:401)
at org.apache.lucene.index.ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:478)
无解 2
看起来合并线程无法合并索引,因为他检查了他写的内容。^^
第二次尝试——BASH :)
未完待续。