Jump to content
MediaWiki

Manual:SQLite

From mediawiki.org
This page is a translated version of the page Manual:SQLite and the translation is 41% complete.
SQLite のロゴ
SQLite のロゴ

このページの目的は、MediaWiki を SQLite 上で実行する際の情報や経験を集約することです。

MediaWiki はバージョン 1.17 以降で SQLite をサポートしていますが、これは二次的なサポートであるため、いくつかのバグに遭遇する可能性が高いことに注意してください。 The database most commonly used with MediaWiki is MySQL . See Phabricator for a list of issues. MediaWiki requires SQLite 3.24.0 or later. しかし、データベースを変更する拡張機能での SQLite のサポート状況はさまざまです。

Is SQLite a good choice for MediaWiki?

MediaWiki で SQLite を使用するには、2 つの重要な注意点があります。 まず、多くの拡張機能が SQLite をサポートしている一方で、人気の拡張機能の一部は現在でも SQLite をサポートしていません。 さらに、SQLite は 1 つのサーバーを越えて拡張できません。ご利用のウィキが多くの同時利用者と大量のコンテンツを持つようになる可能性がある場合、MySQL のようなプライマリ レプリカ モデルをサポートするデータベース システムを使う方がいいでしょう。 その結果、ウィキがこれらの拡張機能の使用に依存する可能性がある場合、またはプライマリ レプリカ データベース システムを使用する必要がある場合は、ウィキに MySQL データベースを使用することが最善となります。 SQLite、MySQL、または他のデータベース システムを使用するかどうかは、理想的にはウィキを作成する前に決定されるべきです。なぜなら、いったんウィキを使い始めると、SQLite データベースから MySQL データベースへの変換が難しくなるからです。

SQLite について

SQLite はパブリック ドメインでリリースされているオープン ソースのデータベース ライブラリです。 クライアント サーバー型のデータベース管理システムとは異なり、SQLite の ライブラリは PHP にリンクされており、サーバー プロセスの不可分な一部となります。 MediaWiki は SQLite の機能を単純な関数呼び出しによって利用しており、関数呼び出しはプロセス間通信よりも効率的であるため、データベース アクセスのレイテンシが低減されます。

Using SQLite as database backend for MediaWiki has its own pros and cons:

長所
  • MySQL のようなスタンドアロンのデータベース サーバーをインストールして維持する必要がなくなり、管理に要する労力が大幅に軽減されるとともに、いくつかの障害要因を排除できます。
  • 前述の理由から、SQLite は USB メモリから実行するようなポータブルな MediaWiki インストールに非常に適しています。
  • You are not restricted by artificial database limitations on shared hosts.
  • The entire database is stored as a single cross-platform file, simplifying backups and migration.
短所
  • SQLite is not that scalable, so if you have a large and popular wiki, you should use MySQL.
  • Although SQLite has its own search engine, it's not supported by more advanced solutions such as Lucene.

SQLite のインストール

At least SQLite version 3.24.0 + is required. また、全文検索を利用するには、SQLite を FTS3 モジュール有効でコンパイルする必要があります (最近のビルドの多くは標準で有効になっています)。 SQLite3 works via PHP's PDO functions.

  • To install SQLite3 on a Debian or Ubuntu based system, use apt install php-sqlite3.
  • Windows binaries from php.net are OK.
  • The PHP PDO SQLite module needs to be loaded.

You should uncomment the following line in your php.ini

    • extension=pdo_sqlite
  • Where should you put the SQLite database itself? The default path seems to be $IP/../data/$dbname.sqlite.

ウェブ ルート外にあるものは安全であるべきです。近くに保管しておくのが良いでしょう。あるいは、気が向いた場合はウェブ ルート内のどこかに置き、ウェブ サーバーの設定を使用してアクセスを拒否することもできます。

SQLiteバックエンド上へのMediaWikiのインストール

  • If SQLite module for PHP is properly installed, MediaWiki installer (/mw-config/index.php) should offer you an option to use SQLite.
  • 「SQLite データ ディレクトリ」フィールドに何も入力しない場合、$wgSQLiteDataDir は空のままとなり、これはドキュメント ルートの親ディレクトリにある data ディレクトリに対応します。ただし、このディレクトリはウェブ スクリプトとメンテナンス スクリプト (コマンドラインから実行される) の場合で異なる可能性があるため、明示的に指定することをお勧めします。

検索エンジン

MediaWiki バージョン:
≧ 1.16

Search capabilities for SQLite backend was introduced in MediaWiki 1.16. They require SQLite with FTS3 module compiled-in, which is usually present in most modern builds. If you've recently updated your SQLite support to a version that includes FTS3, run the updater as if you're upgrading MediaWiki. After the updater script created the search index table, populate it with rebuildtextindex.php . Same applies to switches back to environments without FTS3: re-running the updater will downgrade the table to avoid SQL errors.

Backing up

データベースが現在オフラインなら、データベースファイルをコピーするだけでデータベースをバックアップできます。 そうではない場合は、メンテナンス スクリプト php maintenance/run.php SqliteMaintenance --backup-to <バックアップ ファイル名> を使用します。この操作はアトミック (すべての処理が実行されるか全く実行されないかのいずれか) なので、不整合が生じないことが保証されます。 ウィキのデータベースが非常に大きかったり、サーバーの負荷が重かったりしなければ、ウィキを編集しているユーザーは多少のもたつきを感じるだけでしょう。 ウィキを読んでいるだけの利用者は何も感じないでしょう。

トラブルシューティング

端末上でデータベースにアクセスできない

To get command-line access to the database, type on the terminal:

sqlite3 /var/data/database_name.sqlite

replacing /var/data with the directory that was set as the "SQLite data directory" during the installation process. Alternatively, look for $wgSQLiteDataDir inside LocalSettings.php .

This can be tricky if you are not experienced about SQLite and run sqlite3 database_name - because this will open a completely different database (creating it if it doesn't exist) since SQLite interprets the argument not as a system-wide database name, but instead as the file name that contains the db.

問題点

Bugs should be reported to Wikimedia's bug tracker. First check if your problem was already reported - check the dependencies of tag #sqlite and use search. If you can't find your problem, create a new issue. In any case please take some steps to make your bug easy to find and track: mention SQLite in its summary field and make it have the project tag SQLite.

Performance Tips

  • If possible, ensure you have the APCu php extension installed and $wgMainCacheType set to CACHE_ACCEL. If no cache is present, MediaWiki will use the database as a cache backend, which can lead to write contention. On Sqlite this can significantly slow down your wiki.
  • Make sure your SQLite database is in WAL mode (Write-Ahead Logging – WAL). This can have a major impact on performance when people are viewing and editing your site at the same time. You can do this by using the sqlite command line tool to open the DB, and run the command PRAGMA journal_mode=wal;.

関連項目

  • SQLite-specific configuration settings:

外部リンク

エンジン
現行
以前
技術的な説明文書
設定の構成
開発
コアのテーブル
現行
以前

AltStyle によって変換されたページ (->オリジナル) /