如何查看updatedb 数据库内容,然后排除某些文件/路径?

rub*_*o77 7 debian-squeeze

我的 debian (squeeze) 服务器上的 updatedb 数据库很慢。

  • 数据库在哪里
  • 我如何查看它的内容并找出是否有一些路径包含无用的东西,我可以添加到 prunepaths 中?
  • 如何修剪所有包含*/.git/*, */.svn/*和类似的路径?
  • 为什么不排除文件,我在 中定义PRUNEPATHS

/etc/updatedb.conf看起来像这样:

...
# filesystems which are pruned from updatedb database
PRUNEFS="NFS nfs nfs4 afs binfmt_misc proc smbfs autofs iso9660 ncpfs coda devpts ftpfs devfs mfs shfs sysfs cifs lustre_lite tmpfs usbfs udf"
export PRUNEFS
# paths which are pruned from updatedb database
PRUNEPATHS="/tmp /usr/tmp /var/tmp /afs /amd /alex /var/spool /sfs /media /var/backups/rsnapshot /var/mod_pagespeed/"
...
Run Code Online (Sandbox Code Playgroud)

编辑:

  • 定位数据库在 /var/cache/locate/locatedb
  • locate /将列出数据库中的所有文件和目录(我通过将其导出到文件中来查看结果:locate />/tmp/locatedb.txt,下载此 txt 文件并找到大量无用的东西)

Sec*_*coe 6

PRUNENAMES如中所述使用man updatedb.conf

不应该被 updatedb(8) 扫描的以空格分隔的目录名称列表(没有路径)。默认情况下,不会跳过任何目录名称。

指某东西的用途

PRUNENAMES=".git .hg .svn"

应该可以解决问题(上面的行是 Fedora 18 上的标准值)。


Jas*_*nCG 6

You are probably using the GNU findutils version of locate, which doesn't support the PRUNENAMES option. Installing mlocate will provide these configuration options:

apt-get remove locate
mv /etc/updatedb.conf /etc/updatedb.conf-GNU.old
apt-get install mlocate
Run Code Online (Sandbox Code Playgroud)

Now with the mlocate packge you can edit or create /etc/updatedb.conf and add these lines:

PRUNENAMES=".git .bzr .hg .svn"
PRUNEPATHS="/tmp /var/spool /var/cache /media /usr/tmp /var/tmp /sfs /afs /amd /alex /var/backups/rsnapshot /var/mod_pagespeed"
# the paths in `PRUNEPATHS` must be without trailing slashes
Run Code Online (Sandbox Code Playgroud)

Then actualize the database with:

updatedb
Run Code Online (Sandbox Code Playgroud)

You probably can remove the huge old locate database:

rm /var/cache/locate/locatedb
Run Code Online (Sandbox Code Playgroud)

(mlocate 数据库存储在/var/lib/mlocate/mlocate.db

查看https://apps.ubuntu.com/cat/applications/mlocate/以获取有关该软件包的更多信息。

(我花了很多时间试图解决类似的问题!)