Jump to content
MediaWiki

Manual:Swift

From mediawiki.org

MediaWiki can store files in OpenStack Swift. The following are instructions for installing Swift for local development or a single-server production install.

On your Debian or Ubuntu system (tested on Ubuntu 22.04), as root:

# Install packages
apt-getinstallswiftswift-accountswift-containerswift-objectswift-object-expirer\
swift-proxypython3-swiftclientmemcached
# The package has object-server on port 6000, container-server on port 6001,
# account-server on 6002. Let's put the proxy server on port 6006.
# Generate the rings, with a minimum number of partitions.
# Call the device "dev0". With mount_check=false this just needs to be a
# directory on a filesystem with xattr support.
cd/etc/swift
swift-ring-builderobject.buildercreate011
swift-ring-builderobject.builderaddr1z1-127.0.0.1:6000/dev01
swift-ring-builderobject.builderrebalance
swift-ring-buildercontainer.buildercreate011
swift-ring-buildercontainer.builderaddr1z1-127.0.0.1:6001/dev01
swift-ring-buildercontainer.builderrebalance
swift-ring-builderaccount.buildercreate011
swift-ring-builderaccount.builderaddr1z1-127.0.0.1:6002/dev01
swift-ring-builderaccount.builderrebalance
printf'[swift-hash]\nswift_hash_path_suffix=%s\nswift_hash_path_prefix=%s\n'\
$(opensslrand-hex4)$(opensslrand-hex4)>swift.conf
# Default data directory is /srv/node. Let's use /data/swift instead.
install-oswift-gswift-d/data/swift/dev0
sed-i'4a\
devices=/data/swift\
mount_check = false'container-server.confobject-server.confaccount-server.conf
# The proxy configuration is fiddly. You need to tell it not only what features to
# enable, but also what order the features need to be loaded into a middleware
# pipeline, and how to locate its own classes.
user_key=$(opensslrand-hex8)
admin_key=$(opensslrand-hex8)
cat'[DEFAULT]
bind_port = 6006
workers = 2
[pipeline:main]
pipeline = catch_errors gatekeeper proxy-logging listing_formats healthcheck cache container_sync tempurl ratelimit tempauth copy dlo versioned_writes proxy-logging proxy-server
[filter:catch_errors]
use = egg:swift#catch_errors
[filter:gatekeeper]
use = egg:swift#gatekeeper
[filter:listing_formats]
use = egg:swift#listing_formats
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:cache]
use = egg:swift#memcache
[filter:container_sync]
use = egg:swift#container_sync
[filter:tempurl]
use = egg:swift#tempurl
[filter:ratelimit]
use = egg:swift#ratelimit
[filter:tempauth]
use = egg:swift#tempauth
user_admin_admin = '$admin_key' .admin .reseller_admin
user_mw_media = '$user_key' .admin
[filter:copy]
use = egg:swift#copy
[filter:dlo]
use = egg:swift#dlo
[filter:versioned_writes]
use = egg:swift#versioned_writes
[filter:proxy-logging]
use = egg:swift#proxy_logging
[app:proxy-server]
use = egg:swift#proxy
account_autocreate = true
'>proxy-server.conf
# The servers can be started now
systemctlstartswift-objectswift-containerswift-accountswift-proxy

In LocalSettings.php:

$wgFileBackends[] = [
	'class' => SwiftFileBackend::class,
	'name' => "local-swift",
	'swiftAuthUrl' => 'http://localhost:6006/auth',
	'swiftUser' => 'mw:media',
	'swiftKey' => $user_key,
	'parallelize' => 'implicit',
	'cacheAuthInfo' => true,
	'lockManager' => 'memcLockManager',
];
$wgLocalFileRepo = [
	'class' => LocalRepo::class,
	'name' => 'local',
	'backend' => 'local-swift',
	'url' => '/images',
];
$wgLockManagers[] = [
	'name' => 'memcLockManager',
	'class' => MemcLockManager::class,
	'lockServers' => [ '127.0.0.1:11211' ],
];

The default lock manager uses the filesystem, which is inconvenient for a Swift-backed wiki. Above, we used memcached. The server is shared with Swift. Production uses Redis, but that would need to be set up separately.

The web server hosting MediaWiki needs to proxy certain paths to Swift:

<Location"/images">
ProxyPass"http://localhost:6006/v1/AUTH_mw/mw_swift-local-public"
</Location>
<Location"/images/thumb">
ProxyPass"http://localhost:6006/v1/AUTH_mw/mw_swift-local-thumb"
</Location>

And that's it. You should be able to upload files to the wiki.

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