You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Maintenance server: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
imported>BryanDavis
(Wikitech moved to cloudweb1003)
imported>Krinkle
(document where to find the scripts we run in prod)
 
Line 6: Line 6:
*[[mwmaint1002]], current '''active''' maintenance server in eqiad.
*[[mwmaint1002]], current '''active''' maintenance server in eqiad.
*[[mwmaint2002]], this one is passive, to be used if we switch activity to codfw ([[Switch Datacenter|switchover]]).
*[[mwmaint2002]], this one is passive, to be used if we switch activity to codfw ([[Switch Datacenter|switchover]]).
Note that maintenance scripts for [[Wikitech]] (<code>labswiki</code>), must be run from [[cloudweb1003|cloudweb]] hosts instead. ([[phab:T237773#7841755|T237773]])
*Note that maintenance scripts for [[Wikitech]] (<code>labswiki</code>), must be run from [[cloudweb1003|cloudweb]] hosts instead. ([[phab:T237773#7841755|T237773]])
We manage the scheduling in Puppet ([[git:operations/puppet/+/HEAD/modules/profile/manifests/mediawiki/maintenance.pp|puppet: profile/mediawiki/maintenance.pp]]), where we declare which scripts to run, when and how often, and what wikis to run them on. As of 2020, the scripts are run via systemd timers. Previously, we used cron to run the maintenance jobs.


To run maintenance scripts on the [[beta cluster]] you need to connect to the equivalent servers on deployment-prep. E.g.:
To run maintenance scripts on the [[beta cluster|Beta Cluster]] you need to connect to the equivalent servers on deployment-prep. E.g.:<pre>
<pre>
deployment-mwmaint02.deployment-prep.eqiad1.wikimedia.cloud
deployment-mwmaint02.deployment-prep.eqiad1.wikimedia.cloud
</pre>
</pre>

Latest revision as of 21:30, 22 September 2022

Maintenance servers are where we run scheduled and ad-hoc command-line scripts relating to MediaWiki.

Service

As of September 2021, the servers are:

We manage the scheduling in Puppet (puppet: profile/mediawiki/maintenance.pp), where we declare which scripts to run, when and how often, and what wikis to run them on. As of 2020, the scripts are run via systemd timers. Previously, we used cron to run the maintenance jobs.

To run maintenance scripts on the Beta Cluster you need to connect to the equivalent servers on deployment-prep. E.g.:

deployment-mwmaint02.deployment-prep.eqiad1.wikimedia.cloud

Runbook

Run a maintenance script on a wiki

When running a long-running maintenance script, consider using screen.

To run a maintenance script, log into the active maintenance server:

cd /srv/mediawiki/php-1.27.0-wmf.23

Use the mwscript command-line utility:

mwscript scriptname.php --wiki dbname

The above command will run the script scriptname.php located in the /maintenance directory of the specified wiki's php directory.

You can also use a path relative to the MediaWiki installation, for example to run a script from an extension rather than core. It is recommended that in this case you first change a MediaWiki directory to allow for tab completion:

, change to the directory for the version of MediaWiki that you want to run the maintenance script from (for example php-1.27.0-wmf.23)

$ cd /srv/mediawiki/php-1.xx-someversion/
$ mwscript extensions/MyExtension/maintenance/scriptname.php --wiki dbname

IIt will run the version of the maintenance script in /home/wikipedia/common. If you want to run the version under /usr/local/apache/common-local/, or you're on a box without /home mounted, you need to change to /usr/local/apache/common-local/multiversion and run ./MWScript.php instead.

Example:

$ mwscript eval.php enwiki
> print $wgDBname;
enwiki
> print $wgVersion;
1.18wmf1
> exit
$

If you need to pass parameters to your maintenance script, you can add them to the end. You may also want to explicitly declare the database parameter to avoid confusion:

mwscript scriptname.php --wiki=enwiki --days=1

In this case, the 'wiki' parameter is handled by mwscript and the 'days' parameter is handled by scriptname.php. The "wiki" must be in wikiversions.cdb so the maintenance script machinery can figure out what MediaWiki version it is running.

Many maintenance scripts are used to run heavy database queries; remember to check the replication lag and other possible byproducts.

See also