TOC
MediaWiki自体のアップグレードとRPi4からOPi5への引っ越しが重なる事態に
ことの起こりはRPi4からOPi5へ移設を続々としていてMediaWikiも引っ越すので、どうやってDocker Composeで構築したのかなと過去の記事を見ていて
MediaWikiで家庭内ナレッジを集約(docker-compose)
1.35のサポートがもうすぐ終わる&LTSが1.39に変わってるということに気付いたことでした。
で、外部からのアクセスがない環境で立てているMediaWikiでもサポート切れたものをそのまま使うのはまずいよねというのと、LTSを指定して構築したバージョンからLTSを指定して構築するバージョンが一緒じゃないという面倒なことになっていること、例によってPodman(Systemd)で管理するので色々細々しているのでちゃんとやろうということになりました。
また、MediaWikiは現在も開発が活発に行われているのでバージョンアップは単純な入れ替えで済んだことが(私は)ありません。
作業の出発点は前掲の過去記事の状態になります。また、Podmanシリーズとしては以下の記事の続きです。
Harborを題材に、Docker Compose風運用をPodmanでする
RPi4で動かしているMediawikiを1.34から1.39にアップグレード
ボリュームのバックアップ
単にオンプレミスでMediawikiを実行している場合はアップグレードスクリプトを端末上で実行すればいいのですが、Docker Composeで運用している都合上LTSの指しているMediawikiのバージョンが勝手に変わるのとスクリプトの実行手順が異なるのでそこを踏まえてアップグレードします。
以下のボリュームをバックアップします。
ディレクトリ | マウント先 |
---|---|
/mnt/usbhdd1/var/mediawiki-docker-images/images | /var/www/html/images |
/mnt/usbhdd1/var/mediawiki-docker-LocalSettingsPhp/LocalSettings.php | /var/www/html/LocalSettings.php |
/mnt/usbhdd1/var/mediawiki-docker-db/db | /var/lib/mysql |
まず最初にRPi4で動かしているdocker-composeのディレクトリに移動して、コンテナを落とします。
$ docker-compose down
Stopping docker-mediawiki_mediawiki_1 ... done
Stopping docker-mediawiki_database_1 ... done
Removing docker-mediawiki_mediawiki_1 ... done
Removing docker-mediawiki_database_1 ... done
Removing network docker-mediawiki_default
コンテナにマウントしているボリュームをバックアップします。作業はrootless dockerが実行しているユーザーのパーミッションで実行できる必要があるのでrootで実施します。
# cd /mnt/usbhdd1/var/
# tar Jcvf mediawiki-docker-db.txz mediawiki-docker-db
# tar Jcvf mediawiki-docker-images.txz mediawiki-docker-images
# tar Jcvf mediawiki-docker-LocalSettingsPhp.txz mediawiki-docker-LocalSettingsPhp
dockerイメージの更新
docker-composeでイメージを更新します。当時ltsを指定して構築したときは1.35を指していましたが、現在はltsは1.39を指しているのでそのままpullします。docker-compose.ymlのあるディレクトリで作業します。
$ docker-compose pull
Pulling database ... done
Pulling mediawiki ... done
コンテナを上げて動くか確認します。
$ docker-compose up -d
Creating network "docker-mediawiki_default" with the default driver
Creating docker-mediawiki_database_1 ... done
Creating docker-mediawiki_mediawiki_1 ... done
コンテナ自体は上がりましたが、ブラウザからアクセスしたら予想通り動いてませんでした。
アップデートスクリプトの実行
ということで、アップデートスクリプトを実行します。実行するスクリプトはdockerコンテナの中なので、コンテナ名を指定してphpコマンドを実行します。
$ docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------
docker- docker-entrypoint.sh Up 3306/tcp
mediawiki_database_1 mariadbd
docker- docker-php-entrypoint Up 0.0.0.0:18080-
mediawiki_mediawiki_1 apac ... >80/tcp,:::18080-
>80/tcp
このアップデートスクリプトですが実行に時間がかかります。今回は4分19秒でした。
$ docker exec -it docker-mediawiki_mediawiki_1 php /var/www/html/maintenance/update.php --quick
MediaWiki 1.39.4 Updater
Your composer.lock file is up to date with current dependencies!
Going to run database updates for my_wiki
Depending on the size of your database this may take a while!
...collations up-to-date.
...have rev_actor field in revision table.
...have img_description_id field in image table.
Migrating comments to the 'comments' table, printing progress markers. For large
databases, you may want to hit Ctrl-C and do this manually with
maintenance/migrateComments.php.
No need to migrate revision.rev_comment, field does not exist
No need to migrate archive.ar_comment, field does not exist
No need to migrate ipblocks.ipb_reason, field does not exist
No need to migrate image.img_description, field does not exist
No need to migrate oldimage.oi_description, field does not exist
No need to migrate filearchive.fa_deleted_reason, field does not exist
No need to migrate filearchive.fa_description, field does not exist
No need to migrate recentchanges.rc_comment, field does not exist
No need to migrate logging.log_comment, field does not exist
No need to migrate protected_titles.pt_reason, field does not exist
done.
...slots table already exists.
...have slot_origin field in slots table.
...content table already exists.
...slot_roles table already exists.
...content_models table already exists.
...actor table already exists.
...have ar_actor field in archive table.
...have ipb_by_actor field in ipblocks table.
...have img_actor field in image table.
...have oi_actor field in oldimage table.
...have fa_actor field in filearchive table.
...have rc_actor field in recentchanges table.
...have log_actor field in logging table.
Migrating actors to the 'actor' table, printing progress markers. For large
databases, you may want to hit Ctrl-C and do this manually with
maintenance/migrateActors.php.
Creating actor entries for all registered users
... 1 - 2
Completed actor creation, added 0 new actor(s)
No need to migrate revision.rev_user, field does not exist
No need to migrate archive.ar_user, field does not exist
No need to migrate ipblocks.ipb_by, field does not exist
No need to migrate image.img_user, field does not exist
No need to migrate oldimage.oi_user, field does not exist
No need to migrate filearchive.fa_user, field does not exist
No need to migrate recentchanges.rc_user, field does not exist
No need to migrate logging.log_user, field does not exist
Beginning migration of log_search
Completed migration, inserted 0 row(s) with 0 new actor(s), 0 error(s)
done.
Modifying table site_stats...done.
...index rc_namespace_title_timestamp already set on recentchanges table.
...change_tag_def table already exists.
Populating el_index_60 field, printing progress markers. For large
databases, you may want to hit Ctrl-C and do this manually with
maintenance/populateExternallinksIndex60.php.
Populating externallinks.el_index_60...
el_id 0 - 200 of 155
Done, 0 rows updated.
done.
Removing 'externallinks.el_index_60' default value.
Running maintenance/deduplicateArchiveRevId.php...
Deduplicating ar_rev_id...
... -
Finished deduplicating ar_rev_id. 0 rows deleted, 0 assigned new IDs.
done.
...have ct_tag_id field in change_tag table.
...index ar_revid_uniq already set on archive table.
Migrating revision data to the MCR 'slot' and 'content' tables, printing progress markers.
For large databases, you may want to hit Ctrl-C and do this manually with
maintenance/populateContentTables.php.
Populating revision...
No need to populate, revision.rev_text_id field does not exist
Populating archive...
No need to populate, archive.ar_text_id field does not exist
Done. Processed 0 rows in 0.016600847244263 seconds
done.
...index log_type_action already set on logging table.
...type_action key doesn't exist.
...index PRIMARY already set on interwiki table.
...index PRIMARY already set on page_props table.
...index PRIMARY already set on protected_titles table.
...index PRIMARY already set on site_identifiers table.
...index rc_this_oldid already set on recentchanges table.
...transcache doesn't exist.
Running maintenance/populateChangeTagDef.php...
done.
...change_tag_rc_tag key doesn't exist.
...have ipb_sitewide field in ipblocks table.
...ipblocks_restrictions table already exists.
...change_tag table does not contain ct_tag field.
...valid_tag doesn't exist.
...tag_summary doesn't exist.
...archive table does not contain ar_comment field.
...ipblocks table does not contain ipb_reason field.
...image table does not contain img_description field.
...oldimage table does not contain oi_description field.
...filearchive table does not contain fa_description field.
...recentchanges table does not contain rc_comment field.
...logging table does not contain log_comment field.
...protected_titles table does not contain pt_reason field.
Modifying table job...done.
...ar_usertext_timestamp key doesn't exist.
...usertext_timestamp key doesn't exist.
...archive table does not contain ar_user field.
...ipblocks table does not contain ip_by field.
...img_user_timestamp key doesn't exist.
...image table does not contain img_user field.
...oldimage table does not contain oi_user field.
...filearchive table does not contain fa_user field.
...recentchanges table does not contain rc_user field.
...logging table does not contain log_user field.
...index un_user_ip already set on user_newtalk table.
...watchlist_expiry table already exists.
Modifying page_restrictions field of table page...done.
...index ipb_address_unique already set on ipblocks table.
...revision table does not contain rev_text_id field.
...archive table does not contain ar_text_id field.
...lc_lang is up-to-date.
...ll_lang is up-to-date.
...site_language is up-to-date.
...index ipb_address_unique on table ipblocks has no field ipb_anon_only; added.
...ipb_address_unique index up-to-date.
Modifying actor_name field of table actor...done.
Modifying site_global_key field of table sites...done.
Modifying iwl_prefix field of table iwlinks...done.
Modifying rd_title field of table redirect...done.
Modifying pl_title field of table pagelinks...done.
Modifying tl_title field of table templatelinks...done.
Modifying il_to field of table imagelinks...done.
Modifying ll_title field of table langlinks...done.
Modifying iwl_title field of table iwlinks...done.
Modifying cat_title field of table category...done.
Modifying qc_title field of table querycache...done.
Modifying qcc_title field of table querycachetwo...done.
Modifying wl_title field of table watchlist...done.
Modifying user_last_timestamp field of table user_newtalk...done.
Modifying pt_title field of table protected_titles...done.
Removing 'protected_titles.pt_expiry' default value.
Removing 'ip_changes.ipc_rev_timestamp' default value.
Modifying ir_type field of table ipblocks_restrictions...done.
Renaming index namespace_title into wl_namespace_title to table watchlist...done.
Modifying job_title field of table job...done.
Modifying job_timestamp field of table job...done.
Modifying job_token_timestamp field of table job...done.
Modifying wl_notificationtimestamp field of table watchlist...done.
Modifying role_id field of table slot_roles...done.
Modifying model_id field of table content_models...done.
Modifying cl_to field of table categorylinks...done.
Modifying log_title field of table logging...done.
Modifying us_timestamp field of table uploadstash...done.
Renaming index user_properties_property into up_property to table user_properties...done.
Renaming index sites_global_key into site_global_key to table sites...done.
Renaming index type_time into log_type_time to table logging...done.
Modifying fa_name field of table filearchive...done.
Removing 'filearchive.fa_deleted_timestamp' default value.
Removing 'filearchive.fa_timestamp' default value.
Modifying oi_name field of table oldimage...done.
Removing 'oldimage.oi_timestamp' default value.
Modifying exptime field of table objectcache...done.
Removing 'ipblocks.ipb_timestamp' default value.
Removing 'ipblocks.ipb_expiry' default value.
Renaming index name_title_timestamp into ar_name_title_timestamp to table archive...done.
Modifying img_name field of table image...done.
Removing 'image.img_timestamp' default value.
Modifying img_timestamp field of table image...done.
Renaming index site_ids_key into si_key to table site_identifiers...done.
Modifying rc_title field of table recentchanges...done.
Removing 'recentchanges.rc_timestamp' default value.
Modifying rc_timestamp field of table recentchanges...done.
Modifying rc_id field of table recentchanges...done.
Renaming index new_name_timestamp into rc_new_name_timestamp to table recentchanges...done.
Removing 'archive.ar_timestamp' default value.
Modifying ar_title field of table archive...done.
Modifying page_title field of table page...done.
Removing 'page.page_touched' default value.
Modifying user_name field of table user...done.
Renaming index page_timestamp into rev_page_timestamp to table revision...done.
Adding modtoken field to table objectcache...done.
Removing 'revision.rev_timestamp' default value.
Adding index oi_timestamp to table oldimage...done.
Renaming index name_title into page_name_title to table page...done.
Renaming index change_tag_rc_tag_id into ct_rc_tag_id to table change_tag...done.
Converting djvu metadata...
Finished refreshing file metadata for 0 files. 0 needed to be refreshed, 0 did not need to be but were refreshed anyways, and 0 refreshes were suspicious.
...done.
Table page_restrictions contains pr_user field. Dropping...done.
Modifying fa_id field of table filearchive...done.
Modifying img_major_mime field of table image...done.
Creating linktarget table...done.
Dropping rev_page_id index from table revision...done.
Modifying pr_page field of table page_restrictions...done.
Modifying pp_page field of table page_props...done.
Modifying ir_value field of table ipblocks_restrictions...done.
Adding tl_target_id field to table templatelinks...done.
Creating user_autocreate_serial table...done.
Modifying ir_ipb_id field of table ipblocks_restrictions...done.
Modifying ipb_id field of table ipblocks...done.
Modifying user_editcount field of table user...done.
Running maintenance/migrateRevisionActorTemp.php...
Merging the revision_actor_temp table into the revision table...
... rev_id=200, updated 200
... rev_id=400, updated 400
... rev_id=600, updated 600
Completed merge of revision_actor into the revision table, 679 rows updated.
done.
Dropping table revision_actor_temp ...done.
Running maintenance/updateRestrictions.php...
...processing page IDs from 0 to 1000.
...Done!
done.
Table page contains page_restrictions field. Dropping...done.
Running migrateLinksTable.php on templatelinks...
Populating the tl_target_id column
Completed normalization of templatelinks, 0 rows updated.
done.
Modifying tl_namespace field of table templatelinks...done.
Table templatelinks contains tl_title field. Dropping...done.
...site_stats is populated...done.
Checking existence of old default messages...done.
Populating rev_len column
...doing rev_id from 1 to 200
...doing rev_id from 201 to 400
...doing rev_id from 401 to 600
...doing rev_id from 601 to 800
Populating ar_len column
...archive table seems to be empty.
rev_len and ar_len population complete [0 revision rows, 0 archive rows].
Populating rev_sha1 column
...doing rev_id from 1 to 200
...doing rev_id from 201 to 400
...doing rev_id from 401 to 600
...doing rev_id from 601 to 800
Populating ar_sha1 column
...archive table seems to be empty.
Populating ar_sha1 column legacy rows
rev_sha1 and ar_sha1 population complete [0 revision rows, 0 archive rows].
Populating img_sha1 field
Done 0 files in 0.0 seconds
Fixing protocol-relative entries in the externallinks table...
Done, 0 rows updated.
Populating fa_sha1 field from fa_storage_key
Done 0 files in 0.1 seconds
Updating *_from_namespace fields in links tables.
...doing page_id from 1 to 200
Adding empty categories with description pages...
Removing empty categories without description pages...
Category cleanup complete.
Populating page_props.pp_sortkey...
Populating page_props.pp_sortkey complete.
Updated a total of 0 rows
Copying IP revisions to ip_changes, from rev_id 0 to rev_id 679
...checking 199 revisions for IP edits that need copying, between rev_ids 0 and 200
...checking 201 revisions for IP edits that need copying, between rev_ids 201 and 401
...checking 201 revisions for IP edits that need copying, between rev_ids 402 and 602
...checking 77 revisions for IP edits that need copying, between rev_ids 603 and 679
Attempted to insert 678 IP revisions, 0 actually done.
Updating externallinks table index fields
el_id 0 - 155 of 155
Done, 0 rows updated, 0 deleted.
Purging caches...done.
Done in 4 min 19 s.
もう一度ブラウザからアクセスし、通常通り動作していることを確認したら1.34から1.39へのアップグレードは完了です。特別ページの中にバージョン情報というのがあることを初めて知ったので、これを確認することでアップグレードされたことを確認できます。
OPi5へのデータ移行とMediawiki構築
データ移行
もともとRPi4で動かしていたMediaWikiのデータをそのまま使うので、先にデータ移行をしてからOPi5でのMediaWikiを構築します。
scpでコピーするので、RPi側をrootユーザーでも参照できるように一時的にsshでのrootログインを許可します。(今回はコピー先でscpを実行するので、コピー元でscpを実行する場合は逆にOPi側をsshでrootログイン許可する)
/etc/ssh/sshd_config
で PermitRootLogin yes
を有効にして
# systemctl restart sshd.service
コピー先になるOPi5でscpを実行します。Podmanを実行するユーザーは作業ユーザーではない一般ユーザーになるので、scpはrootで行います。
# cd /var/containers
# scp -r 192.168.1.210:/mnt/usbhdd1/var/mediawiki-docker-db 192.168.1.210:/mnt/usbhdd1/var/mediawiki-docker-images 192.168.1.210:/mnt/usbhdd1/var/mediawiki-docker-LocalSettingsPhp .
パスワード認証の場合、リモートファイル(ディレクトリ)の数だけrootユーザーのログインパスワードを聞かれます。
OPi5ではPodmanを実行する一般ユーザーのuidは166536、gidは166537なので、コピーしたOPi5側でownerを変更します。
# chown 166536:166537 -R mediawiki-docker-db mediawiki-docker-images mediawiki-docker-LocalSettingsPhp
MediaWikiの構築
OPi5側は今回ltsでインストールすると1.39が入るのでそのまま1.39で構築して1.39に更新したボリュームを読み込ませます。
$ mkdir -p ~/podmancompose/mediawiki
$ cd ~/podmancompose/mediawiki
docker-compose.ymlを以下の内容で作成します。
# MediaWiki with MariaDB
#
# Access via "http://localhost:8080"
# (or "http://$(docker-machine ip):8080" if using docker-machine)
version: '3'
services:
mediawiki:
image: mediawiki:lts
restart: always
ports:
- 18080:80
links:
- database
volumes:
- /var/containers/mediawiki-docker-images/images:/var/www/html/images
- /var/containers/mediawiki-docker-LocalSettingsPhp/LocalSettings.php:/var/www/html/LocalSettings.php
# This key also defines the name of the database host used during setup instead of the default "localhost"
database:
image: mariadb
restart: always
environment:
# @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
MYSQL_DATABASE: my_wiki
MYSQL_USER: wikiuser
MYSQL_PASSWORD: example
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
volumes:
- /var/containers/mediawiki-docker-db/db:/var/lib/mysql
podman-composeでコンテナを起動した後、ブラウザから18080ポートにアクセスして元と同じデータでMediaWikiが起動していることを確認できたら完了です。
【追記】LocalSettings.phpにMediaWikiのURLを書く行があり、これを元のままで変更しないと変更前のURLにリダイレクトして元のMediaWikiにつながるので、/var/containers/mediawiki-docker-LocalSettingsPhp
の$wgServer
を変更します。
# diff -u LocalSettings.php{.org,}
--- LocalSettings.php.org 2023-09-24 06:28:04.729448773 +0900
+++ LocalSettings.php 2023-10-24 22:43:58.401447000 +0900
@@ -29,7 +29,7 @@
$wgScriptPath = "";
## The protocol and server name to use in fully-qualified URLs
-$wgServer = "http://192.168.1.210:18080";
+$wgServer = "http://192.168.1.212:18080";
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
podman-composeでコンテナを起動した後、ブラウザから18080ポートにアクセスして元と同じデータでMediaWikiが起動していることを確認できたら完了です。
$ podman-compose up -d
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 3.4.4
** excluding: set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=podmancompose', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'podmancompose_default']
['podman', 'network', 'create', '--label', 'io.podman.compose.project=podmancompose', '--label', 'com.docker.compose.project=podmancompose', 'podmancompose_default']
['podman', 'network', 'exists', 'podmancompose_default']
podman run --name=podmancompose_database_1 -d --label io.podman.compose.config-hash=896ebcefc455c42de1ec9a6add2e6d1a433ed2aabe97cb77addd1b7d85fad739 --label io.podman.compose.project=podmancompose --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@podmancompose.service --label com.docker.compose.project=podmancompose --label com.docker.compose.project.working_dir=/home/hogehoge/podmancompose --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=database -e MYSQL_DATABASE=my_wiki -e MYSQL_USER=wikiuser -e MYSQL_PASSWORD=example -e MYSQL_RANDOM_ROOT_PASSWORD=yes -v /var/containers/mediawiki-docker-db/db:/var/lib/mysql --net podmancompose_default --network-alias database --restart always mariadb
Resolving "mariadb" using unqualified-search registries (/home/hogehoge/.config/containers/registries.conf.d/dockerhub_routing.conf)
Trying to pull docker.io/library/mariadb:latest...
Getting image source signatures
Copying blob 7a368f5ed1fa done
Copying blob 637aa2386c42 done
Copying blob 8b5db5f6400d done
Copying blob 172e997ce2d5 done
Copying blob 7d8b2bda57d4 done
Copying blob 2d9f0b91cdf0 done
Copying blob f98ae087d21e done
Copying blob 52903b30562f done
Copying config 8ae57926d5 done
Writing manifest to image destination
Storing signatures
23bd4a2b81048b552a6421583aa676b48b103de26d70a870aba7c6a443fe0317
exit code: 0
['podman', 'network', 'exists', 'podmancompose_default']
podman run --name=podmancompose_mediawiki_1 -d --requires=podmancompose_database_1 --label io.podman.compose.config-hash=896ebcefc455c42de1ec9a6add2e6d1a433ed2aabe97cb77addd1b7d85fad739 --label io.podman.compose.project=podmancompose --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@podmancompose.service --label com.docker.compose.project=podmancompose --label com.docker.compose.project.working_dir=/home/hogehoge/podmancompose --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=mediawiki -v /var/containers/mediawiki-docker-images/images:/var/www/html/images -v /var/containers/mediawiki-docker-LocalSettingsPhp/LocalSettings.php:/var/www/html/LocalSettings.php --net podmancompose_default --network-alias mediawiki -p 18080:80 --restart always mediawiki:lts
Resolving "mediawiki" using unqualified-search registries (/home/hogehoge/.config/containers/registries.conf.d/dockerhub_routing.conf)
Trying to pull docker.io/library/mediawiki:lts...
Getting image source signatures
Copying blob 1c4b1c536306 done
Copying blob 59572f84f3fa done
Copying blob 7a6c7adc7b38 done
Copying blob 4a7e7400ce12 done
Copying blob f189cf2b806d done
Copying blob 49bc70b64a40 done
Copying blob e886f0f47ef5 done
Copying blob 4bd7f80a566c done
Copying blob 8bddfb77c65d done
Copying blob 089393cfb0e5 done
Copying blob baed59b11d61 done
Copying blob 1565697279a0 done
Copying blob 116cfb7065e1 done
Copying blob 246c9c50a64e done
Copying blob 24d48a8c6a15 done
Copying blob 21d91cbf77d0 done
Copying blob 72229a056d1f done
Copying blob e37b3b72767e done
Copying blob ad225ce35ed7 done
Copying blob 5a148385fd4c done
Copying config f16940ebea done
Writing manifest to image destination
Storing signatures
198a3a0e61e1df4cef4c7d772bd78f9e24ba98c8965ab2fa56dbdaaa37084e9d
exit code: 0
OPi5でのSystemdによるコンテナ起動
podman-composeではOSの再起動を跨いだコンテナの自動起動ができないので、podmanコンテナをsystemdで管理します。
Systemdのユニットファイル生成
ユニットファイル自体はpodmanで生成しますが、今回もHarborのときと同じ様にlinksが指定されている(この書き方は古くて意味がないらしいがdepends_onを包含する)ので、先にdatabaseを起動してmediawikiを起動するようにします。
podman-composeでコンテナが上がった状態でユニットファイルを生成します。
$ podman generate systemd --new --files --name mediawiki_database_1
/home/hogehoge/podmancompose/mediawiki/container-mediawiki_database_1.service
$ podman generate systemd --new --files --name mediawiki_mediawiki_1
/home/hogehoge/podmancompose/mediawiki/container-mediawiki_mediawiki_1.service
mediawiki_mediawiki_1の方のRequiresとAfterを次のように変更します。
--- container-mediawiki_mediawiki_1.service.org 2023-09-24 10:30:49.934228211 +0900
+++ container-mediawiki_mediawiki_1.service 2023-09-24 10:33:40.422836151 +0900
@@ -5,8 +5,8 @@
[Unit]
Description=Podman container-mediawiki_mediawiki_1.service
Documentation=man:podman-generate-systemd(1)
-Wants=network-online.target
-After=network-online.target
+Requires=container-mediawiki_database_1.service
+After=network-online.target container-mediawiki_database_1.service
RequiresMountsFor=%t/containers
[Service]
Systemdへの登録と動作確認
ユニットファイルをsystemdに登録しますが、同時に起動確認もしたいのでこの時点でpodman-composeでコンテナを落とします。
$ podman-compose down
先にdatabaseの方のユニットファイルを登録して起動します。
$ mv container-mediawiki_database_1.service ~/.config/systemd/user/
$ systemctl --user enable container-mediawiki_database_1.service
Created symlink /home/hogehoge/.config/systemd/user/default.target.wants/container-mediawiki_database_1.service → /home/hogehoge/.config/systemd/user/container-mediawiki_database_1.service.
$ systemctl --user start container-mediawiki_database_1.service
次にmediawikiのユニットファイルを登録して起動します。
$ mv container-mediawiki_mediawiki_1.service ~/.config/systemd/user/
$ systemctl --user enable container-mediawiki_mediawiki_1.service
Created symlink /home/hogehoge/.config/systemd/user/default.target.wants/container-mediawiki_mediawiki_1.service → /home/hogehoge/.config/systemd/user/container-mediawiki_mediawiki_1.service.
$ systemctl --user start container-mediawiki_mediawiki_1.service
どちらも上がっていることを確認したらブラウザからアクセスして確認完了です。
$ systemctl --user list-dependencies
default.target
● ├─container-mediawiki_database_1.service
● ├─container-mediawiki_mediawiki_1.service
気になる場合はOS再起動で正しく起動するかも確認しましょう。
最後にscpで一時的にrootログインを許可したのを元に戻して、バックアップを削除して作業終了です。
スポンサーリンク
comments powered by Disqus