妄想日記 by 妄想エンジン


mastodon インスタンスをたてる(更新編)

ということで、1.3.3 から 1.4.1 に更新したのでその時の記録。
これをやるために jail で動かしているといっても過言ではない。

基本的なやり方としてはこうです。
・現状の環境をバックアップして、コピーを作成。
・コピー側を v1.4.1 に更新。
・nginx の接続先を v1.4.1 に切り替える。
・v1.3.3 のほうは止めて、環境自体は何かあった時のために残しておく。

まず、すべてのアーカイブを取ります。

親ホスト環境で

$ sudo qjail stop -z mastodon
$ sudo qjail archive -z mastodon -A

バックアップが完了したら、とりあえずふたたび動かしておきます。

$sudo qjail start -z mastodon

次に、更新用の環境を新規に作ります。
とりあえず、DBとredisとminio は今までのものにつなぐことにします。
先ほどアーカイブした mastodon_web をもとに、あらたにmastodon_web2を作成します。

$ sudo qjail create -z mastodon -a mastodon_web -4 192.168.0.44 -n em0 mastodon_web2
Successfully created mastodon_web2
$ sudo qjail list -z mastodon

Jails in zone mastodon
STATUS JID NIC IP Jailname
------ ---- ------ --------------- --------------------------------------------
DR 10 em0 192.168.0.41 mastodon_db
DR 5 em0 192.168.0.43 mastodon_minio
DR 11 em0 192.168.0.42 mastodon_redis
DR 12 em0 192.168.0.40 mastodon_web
DS N/A em0 192.168.0.44 mastodon_web2
DR 9 em0 192.168.0.45 naumanni

$ sudo qjail start -z mastodon mastodon_web2
Jail successfully started mastodon_web2
$ sudo qjail list -z mastodon

Jails in zone mastodon
STATUS JID NIC IP Jailname
------ ---- ------ --------------- --------------------------------------------
DR 10 em0 192.168.0.41 mastodon_db
DR 5 em0 192.168.0.43 mastodon_minio
DR 11 em0 192.168.0.42 mastodon_redis
DR 12 em0 192.168.0.40 mastodon_web
DR 13 em0 192.168.0.44 mastodon_web2
DR 9 em0 192.168.0.45 naumanni

あとは、新たに作ったmastodon_web2 に入って作業します。

$sudo qjail console -z mastodon mastodon_web2
#
# pkg install protobuf
# su - mastodon
$ cd live
$ git stash
Saved working directory and index state WIP on (no branch): a0f7453c Bump version to 1.3.3
HEAD is now at a0f7453c Bump version to 1.3.3
$ git fetch
remote: Counting objects: 2969, done.
remote: Total 2969 (delta 1240), reused 1240 (delta 1240), pack-reused 1728
Receiving objects: 100% (2969/2969), 1.28 MiB | 886.00 KiB/s, done.
Resolving deltas: 100% (2162/2162), completed with 442 local objects.
From https://github.com/tootsuite/mastodon
* [new branch] feature-ldap -> origin/feature-ldap
* [new branch] feature-multicolumn -> origin/feature-multicolumn
c3ef5d54..8963f8c3 master -> origin/master
6577ca05..5439a81c skylight -> origin/skylight
* [new tag] v1.4.1 -> v1.4.1
* [new tag] v1.4rc1 -> v1.4rc1
* [new tag] v1.4rc2 -> v1.4rc2
* [new tag] v1.4rc3 -> v1.4rc3
* [new tag] v1.4rc4 -> v1.4rc4
* [new tag] v1.4rc5 -> v1.4rc5
* [new tag] v1.4rc6 -> v1.4rc6
$ git checkout v1.4.1
Previous HEAD position was a0f7453c... Bump version to 1.3.3
HEAD is now at 8963f8c3... Bump version to 1.4.1
$ /home/mastodon/.rbenv/shims/bundle install --deployment --without development test
$ yarn install --pure-lockfile

できました。あとはdbの更新と assets の precompile です。

$ RAILS_ENV=production /home/mastodon/.rbenv/shims/bundle exec rails db:migrate
$ RAILS_ENV=production /home/mastodon/.rbenv/shims/bundle exec rails assets:precompile

準備完了。
一旦user mastodon から抜けて、root で nginx の設定を変えます。
/usr/local/etc/nginx/mastodon.conf の中で、mastodon_web になっているところを mastodon_web2 に変更します。
テストして大丈夫だったら動かしていきます。

# service mastodon-node start
# service mastodon-sidekiq start
# service mastodon-web start
# service nginx start

最後に、 mastodon_web に入って、 nginx の設定も修正します。
上と同様に、/usr/local/etc/nginx/mastodon.conf の中で、mastodon_web になっているところを mastodon_web2 に変更してrestartします。
こっちがわの mastodo-*は古いバージョンなので、とりあえず、このままで止めておきましょう。

# service mastodon-node stop
# service mastodon-sidekiq stop
# service mastodon-web stop
# sysrc mastodon_web_enable="NO"
mastodon_web_enable: YES -> NO
# sysrc mastodon_node_enable="NO"
mastodon_node_enable: YES -> NO
# sysrc mastodon_sidekiq_enable="NO"
mastodon_sidekiq_enable: YES -> NO

まとめ:
普通に手順通りやれば、どっぱまるところはほとんどありません。
1.3系列から1.4系列に上がる際に、 bootsnap と cld3 が追加されたため、FreeBSDで動かないという問題が発生していましたが、v1.4.1 で解決できたのでよかったです。
作業をしてくださった方々、ありがとうございました。

はまりどころ:
・qjail create -a する際に、領域を zfs で確保しているとちょっとおかしなことになりますが、強引にmvしてしまったら動いてます。なんとなく、これは qjail のバグのような気もする。
・追加で protobuf を入れないと、bundle install の途中でこけます。
・nginx は別の jail で動かしたほうがいい気がしてきた。今更ですが。

ツイート
|top |アフィリエイト |windowsネタ |料理メモ |コンタクト |twitter |
さわやかなエロスを目指す--妄想エンジン ©1996-2022
コンテンツ配信