0

我有一个包含以下文件的 Lucene 索引(来自 Geonetwork 2.10.4)。

_8yw_f.del           _8yw_Lucene41_0.pos  _8yx.cfe    _8yy.si   _8z0.si   _8z2.si   _8z4.si   _8z7.si   _8za.si   _8zc.si   _8ze.si       write.lock
_8yw.fdt             _8yw_Lucene41_0.tim  _8yx.cfs    _8yz.cfe  _8z1.cfe  _8z3.cfe  _8z6.cfe  _8z9.cfe  _8zb.cfe  _8zd.cfe  _8zf.cfe
_8yw.fdx             _8yw_Lucene41_0.tip  _8yx.si     _8yz.cfs  _8z1.cfs  _8z3.cfs  _8z6.cfs  _8z9.cfs  _8zb.cfs  _8zd.cfs  _8zf.cfs
_8yw.fnm             _8yw_nrm.cfe         _8yy_1.del  _8yz.si   _8z1.si   _8z3.si   _8z6.si   _8z9.si   _8zb.si   _8zd.si   _8zf.si
_8yw_Lucene41_0.doc  _8yw_nrm.cfs         _8yy.cfe    _8z0.cfe  _8z2.cfe  _8z4.cfe  _8z7.cfe  _8za.cfe  _8zc.cfe  _8ze.cfe  segments_57i
_8yw_Lucene41_0.pay  _8yw.si              _8yy.cfs    _8z0.cfs  _8z2.cfs  _8z4.cfs  _8z7.cfs  _8za.cfs  _8zc.cfs  _8ze.cfs  segments.gen

当我将文件夹或文件设置为只读时,Geonetwork 会引发严重错误。由于我不想更改 Tomcat 应用程序,因此我暂时忽略了该错误。

现在我的想法/问题:Linux(Ubuntu等)有没有办法放弃写操作并允许读操作?(chmod 0444不会导致目标。)我正在考虑 Tomcat 应用程序和丢弃写入操作的文件系统之间的程序或层。所以 Geonetwork 在索引中写入了一些东西,但实际上这个写入过程被丢弃了,索引不会改变或保持在写入过程之前的状态。

4

1 回答 1

0

第一次尝试——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 :)

未完待续。

于 2018-07-26T15:32:16.633 回答