試験運用中なLinux備忘録・旧記事

はてなダイアリーで公開していた2007年5月-2015年3月の記事を保存しています。

Beagleの概要と導入時の設定など

Beagleは、ハードディスクの中にある様々なデータを簡単に探し出す、デスクトップ検索アプリケーション。今回は、その導入時における覚え書き。
(2014/9/24)Beagleはその後開発が終了し、メンテナンスもされておらず、公式サイトも消えている。

  1. 対応しているファイルの種類
  2. 推奨されるカーネル設定
    1. inotify
    2. ファイルシステムの拡張属性
    3. 実際のカーネルの設定例(ファイルシステム関連)
  3. 起動
  4. インデックス作成の対象と除外ファイルタイプ
  5. 高負荷なインデックス作成(導入直後に効果的)
  6. Firefoxの履歴を記録して検索

対応しているファイルの種類

http://web.archive.org/web/20100708073932/http://beagle-project.org/Supported_Filetypes
を参照。かなり幅広くカバーしている。

推奨されるカーネル設定

inotityと拡張属性(extended attributes)の2つについて、動作すること自体に対して必須ではないものの、有効にすることを強く推奨している。

inotify
inotityという、Linuxカーネルが持つファイル変更通知機能を有効にすると、既にBeagleに登録されているファイルが変更された際、自動的にその変更がBeagleのインデックスに反映される。
これに関する本家サイトの記述を引用しておく。

[引用]http://web.archive.org/web/20100504210043/http://beagle-project.org/Inotify_Kernel より

Beagle does not require inotify, but it is strongly recommended as it will greatly improve your Beagle experience. Without it, Beagle will not automatically detect all changes to your home directory and index the data in a timely fashion. Beagle will also have to continuously recrawl your file system for changes, which can degrade system performance.

[引用]http://web.archive.org/web/20100701203304/http://beagle-project.org/FAQ より

Without it, reliable change notification throughout your entire home directory is impossible, meaning that files that are created, modified, or deleted aren't reflected in your index immediately. Features like live queries won't work in many cases. If you're just trying out beagle, don't worry about building an inotify kernel, but if you plan on running it on a regular basis, you really should.

(2008/5/5)端末に下のようなメッセージが出る場合

Warn: Inotify watches may be too low (8192) for some users!  Increase it to at least 65535 by setting fs.inotify.max_user_watches in /etc/sysctl.conf

指示どおり、以下の設定を追加する。値はもっと大きくてもよい。
ファイル名: /etc/sysctl.conf

fs.inotify.max_user_watches 65535

/proc/sys/fs/inotify/max_user_watchesにセットされる値で、「各inotifyインスタンスに関連づける監視対象の数の上限」らしい。
関連URL:

ファイルシステムの拡張属性
CONFIG_EXT3_FS_XATTRのような、拡張属性のサポートをファイルシステムごとに有効にすることで、それぞれのファイルに対する拡張属性として小さなデータを書き込む。これにより、拡張属性を使用しない場合と比べて動作が軽くなるが、拡張属性の書き込み時、ctime(ファイルの内容もしくは属性が最後に変更された日時で、作成時刻ではない)が更新されるため、ctimeを扱うツールを使う際に問題が出る場合は、環境変数BEAGLE_DISABLE_XATTRをセットして、この機能を無効にするとよいらしい(当然、遅くはなる)。

[引用]http://web.archive.org/web/20100701203304/http://beagle-project.org/FAQ より

There is an sqlite-based fallback in place, but using this as the primary store is slow and noticably degrades performance.

Note that, with extended attributes. beagle will use some extra space for storing the attributes of each file. It depends on the filesystem how much is used for each attribute and it is a small amount. However, it can add up to some 10s of MBs for several GBs of files. Also, writing extended attributes changes the ctime of a file; this might cause problem if you are using any backup utility that compares ctime to backup changed files. If you want to run with extended attributes disabled, set the environment variale BEAGLE_DISABLE_XATTR. Keep in mind that beagle will run slower with extended attribute disabled.

実際のカーネルの設定例(ファイルシステム関連)

File systems  --->
<*> Second extended fs support                [CONFIG_EXT2_FS]
[*]   Ext2 extended attributes                [CONFIG_EXT2_FS_XATTR]
...
<*> Ext3 journalling file system support      [CONFIG_EXT3_FS]
[*]   Ext3 extended attributes                [CONFIG_EXT3_FS_XATTR]
...
<*> Reiserfs support                          [CONFIG_REISERFS_FS]
...
[*]   ReiserFS extended attributes            [CONFIG_REISERFS_FS_XATTR]
...
[*] Inotify file change notification support  [CONFIG_INOTIFY]
[*]   Inotify support for userspace           [CONFIG_INOTIFY_USER]

ext4に関しても拡張属性の項目があるので、将来移行する際にはこれも付けることになる。

起動

デスクトップ環境(GNOME,KDE,Xfce4)を使用していれば、自動的に起動されるような仕組みになっていて、以下のファイルによって自動起動される。手動で実行させる場合、かっこの中のコマンドを実行する。

  • /etc/xdg/autostart/beagled-autostart.desktop(beagled --replace): Beagleのデーモン
  • /etc/xdg/autostart/beagle-search-autostart.desktop(beagle-search --icon): 検索インターフェース

システムトレイに虫眼鏡のアイコンが出てくるので、そこから検索を実行できる。

インデックス作成の対象と除外ファイルタイプ

GTK+の検索インターフェース(beagle-search)の設定ダイアログ内、「インデックスの作成」タブで、対象のディレクトリを指定できる。
ホームディレクトリに関しては、チェックボックスで切り替えできるが、それ以外の場所は、「追加」ボタンで場所を指定して、対象ディレクトリを追加していく。
ホームディレクトリ以下にデータを保管している場合でも、ホーム以下には(検索の対象にする必要のない)設定ファイルなども置かれるため、ホームディレクトリのチェックは外し、データの保管されているディレクトリのみ登録することで、負荷を多少は下げられるかもしれない。
また、インデックス作成の対象外のディレクトリやファイル名のパターンの指定も、下の「プライバシー」で行える。ここの指定は面倒だが、検索結果に余分なものが入らないため、負荷を少しでも下げるため、といったことのために、きちんと設定しておきたい。

高負荷なインデックス作成(導入直後に効果的)

インストール直後には、環境変数BEAGLE_EXERCISE_THE_DOGをセットすることで、高負荷なインデックス作成を行い、検索結果がまともに出るまでの時間を短縮するとよい。
(2007/8/31)実際の操作としては

$ BEAGLE_EXERCISE_THE_DOG=1 beagled --replace

を実行し、ある程度進んだところで

$ beagled --replace

として通常モードに戻す。

Firefoxの履歴を記録して検索

Firefoxで参照したWebページの履歴を検索の対象に含めることができるが、専用の拡張機能をインストールする必要がある。

Gentoo Linuxでは「beagle」パッケージに含まれる/usr/share/beagle/beagle.xpiFirefoxで開いて手動で拡張をインストールする。
Debian lenny(2007年8月末時点)では「beagle」パッケージに含まれる/usr/share/doc/beagle/mozilla-extension/beagle.xpiを同様にインストール。
Ubuntu feistyでは、「mozilla-beagle」パッケージで直接拡張がインストールされるようだ。
Firefox上で、「Beagle Indexer」の拡張の設定を開くと、インデックス作成の対象外ドメインを指定できる。ここも、できる限り指定しておきたい。
(2014/9/24)複数のリンク先を修正・リンク切れの一部記述を削除