我想在Docker容器中运行MediaWiki。我使用here跟随了教程official mediawiki image。我想使用sqlite而不是MySQL,以减少使用单独的容器及其文件的麻烦。我已经运行了图像,安装了wiki,并将数据库和其他目录从容器复制到本地目录:
$ tree -d -L 2
.
└── Social
├── config
├── data
├── extensions
└── images
然后我杀死并删除了docker映像,并使用以下命令再次运行它:
docker run --name social-mediawiki -p 8080:80 \
-v ~/Mediawiki/Social/config/LocalSettings.php:/var/www/html/LocalSettings.php \
-v ~/Mediawiki/Social/images:/var/www/html/images \
-v ~/Mediawiki/Social/extensions:/var/www/html/extensions \
-v ~/Mediawiki/Social/data:/var/www/data \
-d mediawiki
不幸的是,它无法正常工作,因为http://localhost:8080/index.php/Main_Page页面因以下异常而爆炸
[847547d534f8a6acfbb81a43] /index.php/Main_Page Wikimedia\Rdbms\DBTransactionStateError from line 1312 of /var/www/html/includes/libs/rdbms/database/Database.php: Cannot execute query from MediaWiki\Storage\SqlBlobStore::fetchBlob while transaction status is ERROR.
Backtrace:
#0 /var/www/html/includes/libs/rdbms/database/Database.php(1095): Wikimedia\Rdbms\Database->assertTransactionStatus(string, string)
#1 /var/www/html/includes/libs/rdbms/database/Database.php(1653): Wikimedia\Rdbms\Database->query(string, string)
#2 /var/www/html/includes/libs/rdbms/database/Database.php(1730): Wikimedia\Rdbms\Database->select(string, array, array, string, array, array)
#3 /var/www/html/includes/Storage/SqlBlobStore.php(329): Wikimedia\Rdbms\Database->selectRow(string, array, array, string, array)
#4 /var/www/html/includes/Storage/SqlBlobStore.php(277): MediaWiki\Storage\SqlBlobStore->fetchBlob(string, integer)
#5 /var/www/html/includes/libs/objectcache/WANObjectCache.php(1240): MediaWiki\Storage\SqlBlobStore->MediaWiki\Storage\{closure}(boolean, integer, array, NULL)
#6 /var/www/html/includes/libs/objectcache/WANObjectCache.php(1114): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)
#7 /var/www/html/includes/Storage/SqlBlobStore.php(279): WANObjectCache->getWithSetCallback(string, integer, Closure, array)
#8 /var/www/html/includes/Storage/RevisionStore.php(921): MediaWiki\Storage\SqlBlobStore->getBlob(string, integer)
#9 /var/www/html/includes/Storage/RevisionStore.php(865): MediaWiki\Storage\RevisionStore->loadSlotContent(MediaWiki\Storage\SlotRecord, NULL, NULL, NULL, integer)
#10 [internal function]: MediaWiki\Storage\RevisionStore->MediaWiki\Storage\{closure}(MediaWiki\Storage\SlotRecord)
#11 /var/www/html/includes/Storage/SlotRecord.php(308): call_user_func(Closure, MediaWiki\Storage\SlotRecord)
#12 /var/www/html/includes/Storage/RevisionRecord.php(173): MediaWiki\Storage\SlotRecord->getContent()
#13 /var/www/html/includes/Revision.php(937): MediaWiki\Storage\RevisionRecord->getContent(string, integer, User)
#14 /var/www/html/includes/page/Article.php(368): Revision->getContent(integer, User)
#15 /var/www/html/includes/page/Article.php(562): Article->fetchContentObject()
#16 /var/www/html/includes/actions/ViewAction.php(68): Article->view()
#17 /var/www/html/includes/MediaWiki.php(500): ViewAction->show()
#18 /var/www/html/includes/MediaWiki.php(294): MediaWiki->performAction(Article, Title)
#19 /var/www/html/includes/MediaWiki.php(861): MediaWiki->performRequest()
#20 /var/www/html/includes/MediaWiki.php(524): MediaWiki->main()
#21 /var/www/html/index.php(42): MediaWiki->run()
#22 {main}
Sqlite文件本身看起来不错:
$ sudo sqlite3 my_wiki.sqlite
sqlite> PRAGMA integrity_check;
ok
sqlite> select * from page;
1|0|Main_Page||0|1|0.468882297482|20181231020833||1|735|wikitext|
sqlite>
将数据库转储到新文件(广告描述为here)并没有帮助。除调试信息外,未对LocalSettings.php
进行任何更改:
$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;
$wgShowSQLErrors = true;
我该如何做?
答案 0 :(得分:1)
发现了问题。在容器中检查日志文件并在LocalSettings.php
$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;
$wgShowSQLErrors = true;
$wgDebugDumpSql = true;
$wgDebugDBTransactions = true;
$wgDebugLogFile = '/tmp/log';
我发现了很多写访问错误:
[DBQuery] SQL ERROR: attempt to write a readonly database
事实证明,当我安装sqlite数据库数据时,它具有以下权限设置:
# cd /var/www
# ls -l
total 8
drwxr-xr-x 3 root root 4096 Dec 31 03:27 data
drwxrwxrwx 15 www-data www-data 4096 Dec 31 03:30 html
目录的用户和组及其内容也应为www-data
。用以下方法修复后:
# chown -R www-data:www-data /var/www/data
现在一切正常。