Manual:SQLite/es

SQLite logo
SQLite logo

El propósito de esta página es recopilar información y experiencias sobre la ejecución de MediaWiki en SQLite.

MediaWiki soporta SQLite desde la versión 1.17, pero ten en cuenta que este soporte es de segunda categoría, y es probable que te encuentres con algunos errores. La base de datos más comúnmente usada con MediaWiki es MySQL. Consulta Phabricator para ver una lista de problemas. MediaWiki requiere SQLite 3.24.0 o una versión posterior. El soporte para SQLite por parte de las extensiones que realizan cambios en la base de datos es variable.

¿Es SQLite una buena opción para MediaWiki?

Hay dos advertencias importantes al usar SQLite para MediaWiki. Primero, aunque muchas extensiones sí soportan SQLite, hay algunas extensiones populares que hasta el día de hoy aún no lo hacen. Segundo, SQLite no escala más allá de un solo servidor. En caso de que tu wiki pueda crecer para tener muchos usuarios concurrentes y una gran cantidad de contenido, sería mejor usar un sistema de bases de datos que soporte el modelo primario-replicante, como MySQL. Como resultado, si tu wiki puede depender del uso de estas extensiones, o si necesita utilizar un sistema de base de datos primario-replicante, es mejor usar una base de datos MySQL para tu wiki. La decisión de usar SQLite, MySQL u otro sistema de base de datos debería idealmente tomarse antes de crear tu wiki, ya que es difícil convertir una base de datos SQLite a una base de datos MySQL una vez que has comenzado a usar tu wiki.

Acerca de SQLite

SQLite es una biblioteca de base de datos de código abierto liberada al dominio público. A diferencia de los sistemas de gestión de bases de datos cliente-servidor, la biblioteca SQLite está vinculada a PHP y, por lo tanto, se convierte en una parte integral del proceso del servidor. MediaWiki utiliza la funcionalidad de SQLite a través de llamadas simples a funciones, lo que reduce la latencia en el acceso a la base de datos, ya que las llamadas a funciones son más eficientes que la comunicación entre procesos.

Usar SQLite como sistema de base de datos para MediaWiki tiene sus propias ventajas y desventajas:

Ventajas
  • No tienes que instalar ni mantener un servidor de base de datos independiente como MySQL; esto reduce significativamente el esfuerzo dedicado a la administración y elimina algunos puntos de falla.
  • Lo anterior también significa que SQLite es mucho más adecuado para instalaciones portátiles de MediaWiki que se ejecutan desde una memoria USB.
  • No estás restringido por limitaciones artificiales de la base de datos en alojamientos compartidos.
  • Toda la base de datos se almacena como un solo archivo multiplataforma, lo que simplifica las copias de seguridad y la migración.
Desventajas
  • 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 installation

At least SQLite version 3.24.0+ is required. Also, in order to use full text search, SQLite must be compiled with FTS3 module enabled (most builds have it out of the box these days). 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.

Anything outside of the webroot should be safe; it's good to keep it nearby. Or, if you feel like it, you could put it in the web root somewhere and make sure to use webserver config to deny access to it.

Installing MediaWiki on SQLite backend

  • If SQLite module for PHP is properly installed, MediaWiki installer (/mw-config/index.php) should offer you an option to use SQLite.
  • If you enter nothing into the "SQLite data directory" field, your $wgSQLiteDataDir will be left empty, which corresponds to data directory in the parent of the document root, however this directory might be different for web scripts and maintenance scripts run from command line, so specifying it explicitly is recommended.

Search engine

Versión de 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

Si tu wiki está fuera de línea, puedes hacer una copia de su base de datos simplemente copiando el archivo en el que se encuentra. De lo contrario, usa el script de mantenimiento: tmpl|0=php maintenance/run.php SqliteMaintenance --backup-to <$1>, que se asegurará de que la operación sea atómica y que no haya inconsistencias. Si tu base de datos no es excesivamente grande y tu servidor no está bajo una fuerte carga de trabajo, los usuarios que estén editando el wiki tan sólo percibirán un ligero retardo. Los usuarios que sólo estén leyendo no notarán nada en cualquier caso.

Troubleshooting

Unable to access the database on the terminal

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.

Problems

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;.

See also

  • SQLite-specific configuration settings:
Category:Database/es#SQLite Category:Installation/es#SQLite
Category:Database/es Category:Installation/es