Ubuntu22.04から24.04へ移行
アップグレード前の確認事項
- 22.04 LTSのセキュリティサポートは
2027年6月頃まで有効です。 - 作業前に一通り熟読し、作業フローを理解して下さい。
- OSアップグレードのため、作業は慎重に実施してください。
1. 事前準備
スナップショットの作成
スナップショットの作成
アップグレード前に必ず、VPSのサーバー管理画面から現時点のスナップショット(バックアップ)を作成してください。
万一アップグレードに失敗した場合、素早く復旧できます。
SSH鍵の種類を確認する
SSH接続用のローカルパソコンに保存されている、SSH秘密鍵ファイルの種類を確認してください。
- id_rsa
- ssh_ed25519
のどちらか
SSHターミナルバージョン最新化
WindowsでR-loginをご利用の場合は、最新のRLoginを使用して下さい。
作業対象サーバログイン
接続方法
作業対象サーバログイン〜Ubuntuバージョン確認は通常のSSH接続で作業してください。
ノード停止
sudo systemctl stop cardano-node自動起動の停止
sudo systemctl disable cardano-nodePython依存関係の正常化
update-alternativesでpythonを管理しているか確認します。
update-alternatives --get-selections | grep -E '^(python|python3)\s' || echo "未登録"
未登録と表示された場合、以下の手順は不要です。
未登録以外(python3 auto /usr/bin/python3.12等)が表示された場合は、以下の手順で対応してください。
サードパーティリポジトリ(deadsnakes PPA等)からpython3.10以外のバージョン(python3.8、python3.11、python3.12等)をインストールしているか確認します。
dpkg-query -W -f='${Package} ${Version}\n' 2>/dev/null | grep -E '^(python3\.(8|9|11|12|13)|libpython3\.(8|9|11|12|13)|idle-python3\.(8|9|11|12|13))' || echo "該当なし"
該当なしと表示された場合、以下の手順は不要です。
python3.8、python3.11、python3.12等のパッケージが表示された場合は、以下の手順で対応してください。
システムアップデート
sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -yLTSアップグレード設定の確認
grep Prompt /etc/update-manager/release-upgradesPrompt=ltsUbuntuバージョン確認
現在のバージョンを確認します。
lsb_release -dDescription: Ubuntu 22.04.* LTSアップグレードコマンドの確認します。
which do-release-upgrade || sudo apt install ubuntu-release-upgrader-core -yアップグレード可能なバージョンを確認します。
sudo do-release-upgrade -cChecking for a new Ubuntu release
New release '24.04.* LTS' available.
Run 'do-release-upgrade' to upgrade to it. アップグレード前にその他アップグレードが必要なパッケージがあるかどうか確認します。
apt list --upgradableパッケージが表示されなければ問題ありません。
apt-mark showhold何も表示されなければ問題ありません。
リレーサーバーにGrafanaを搭載している場合の対応
サーバー再起動
sudo reboot2. Ubuntuアップグレード
アップグレードの注意点
Ubuntu24.04アップグレード(以下の作業)において、SSH接続での作業は不意な切断が発生した場合に復旧が困難になるため非推奨となっております。
そのため、契約事業者(VPS)のマイページまたはサーバーパネルに付随しているコンソール画面(VNCまたはKVNなど)からの作業をオススメします。
ただし以下の点にご了承頂ける場合はSSH接続で作業することも可能です。
- 事前にスナップショット(バックアップ)作成が可能な方
- 不意なSSH切断でアップグレードが中断してもご自身で復旧出来る方
SSHで作業する場合
- 予備のSSHポートを開放してください。
※ただしAWSやIONOSなど、VPSサーバー管理画面からファイアウォールを設定する場合は、以下のコードは実行せずVPS管理画面から設定してください。
sudo ufw allow 1022/tcpsudo ufw reload確認
sudo ufw status numbered- R-loginを使用する場合は、不意な切断を防ぐため以下の設定を行って下さい。
「
ファイル」→「サーバーに接続」→ 接続先右クリックし「接続を編集する」→「プロトコル」→ SSH枠の「KeepAliveパケット送信間隔(sec)」にチェックを入れ、空欄に**20**を入力してください。
アップグレード実行
接続パターン
- パターン1:VPSサーバー管理画面のコンソールからの接続
- パターン2:ローカルPCにインストールしたVNCクライアントからの接続(主にContabo)
- パターン3:通常通りSSHでの接続
SSH接続でアップグレードする場合、tmux環境内で実行します。
tmux new -s ubuntu-upgradetmuxセッション内でアップグレードを実行します。
sudo do-release-upgradeSSHが切断された場合(復帰方法)
再接続後、以下で tmux に復帰できます。
tmux a -t ubuntu-upgradeアップグレードメッセージ
以下、確認メッセージ例です。
ご利用のサーバーによって表示内容が異なる場合があります。
表示された内容をよく読んで下さい。
注意
設定ファイルに関する確認メッセージが表示された場合は、
必ず keep the local version currently installed(現在の設定を維持する) を選択してください。
サーバーによっては chrony や sshd など複数の設定ファイルで同様のメッセージが表示される場合がありますが、
いずれの場合も keep the local version currently installed を選択します。
1. Ubuntuの案内メッセージ(README)
y を入力後 Enter
Ubuntu is a Linux distribution for your desktop or server, with a fast
and easy install, regular releases, a tight selection of excellent
applications installed by default, and almost any other software you
can imagine available through the network.
We hope you enjoy Ubuntu.
== Feedback and Helping ==
If you would like to help shape Ubuntu, take a look at the list of
ways you can participate at
http://www.ubuntu.com/community/participate/
Your comments, bug reports, patches and suggestions will help ensure
that our next release is the best release of Ubuntu ever. If you feel
that you have found a bug please read:
http://help.ubuntu.com/community/ReportingBugs
Then report bugs using apport in Ubuntu. For example:
ubuntu-bug linux
will open a bug report in Launchpad regarding the linux package.
If you have a question, or if you think you may have found a bug but
aren't sure, first try asking on the #ubuntu or #ubuntu-bugs IRC
channels on Libera.Chat, on the Ubuntu Users mailing list, or on the
Ubuntu forums:
http://help.ubuntu.com/community/InternetRelayChat
http://lists.ubuntu.com/mailman/listinfo/ubuntu-users
http://www.ubuntuforums.org/
== More Information ==
You can find out more about Ubuntu on our website, IRC channel and wiki.
If you're new to Ubuntu, please visit:
http://www.ubuntu.com/
To sign up for future Ubuntu announcements, please subscribe to Ubuntu's
very low volume announcement list at:
http://lists.ubuntu.com/mailman/listinfo/ubuntu-announce
Continue [yN] y # y を入力後Enter2. アップグレードを開始しますか?
y を入力後 Enter
Do you want to start the upgrade?
54 packages are going to be removed. 172 new packages are going to be
installed. 630 packages are going to be upgraded.
You have to download a total of 1,419 M. This download will take
about 4 minutes with a 40Mbit connection and about 37 minutes with a
5Mbit connection.
Fetching and installing the upgrade can take several hours. Once the
download has finished, the process cannot be canceled.
Continue [yN] Details [d] y # y 入力後Enter3. 変更されている chrony.conf の設定ファイルをどうしますか?
keep the local version currently installed を選択後 Enter
4. このサーバーのキーボード配列はどれですか?
English (US) を選択後 Enter
5. このマシンのキーボードに対応するレイアウトを選択してください。
English (US) を選択後 Enter
6. nginxの設定
デフォルトのN を入力後 Enter
Configuration file '/etc/nginx/nginx.conf'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** nginx.conf (Y/I/N/O/D/Z) [default=N] ? n # n 入力後Enter7. sudoersの設定
デフォルトのN を入力後 Enter
Configuration file '/etc/sudoers'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** sudoers (Y/I/N/O/D/Z) [default=N] ? n # n 入力後Enter8. sysctlの設定
デフォルトのN を入力後 Enter
Configuration file '/etc/sysctl.conf'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** sysctl.conf (Y/I/N/O/D/Z) [default=N] ? n # n 入力後Enter9. この変更された SSH 設定ファイルをどうしますか?
keep the local version currently installed を選択後 Enter
10. この変更された GRUB 設定ファイルをどうしますか?
keep the local version currently installed を選択後 Enter
11. GRUB(ブートローダー)をどのディスクにインストールするか?
/dev/sda 上でスペースキーを押して選択し、Tabキーを押して Ok を選択した後、Enter
12. 古い不要パッケージを削除しますか?
y を入力後 Enter
Remove obsolete packages?
114 packages are going to be removed.
Removing the packages can take several hours.
Continue [yN] Details [d] y # y 入力後Enter13. アップグレードが完了しました。再起動しますか?
y を入力後 Enter
System upgrade is complete.
Restart required
To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.
Continue [yN] y # y 入力後Enter3. アップグレード確認(SSH接続)
接続方法
3. アップグレード確認(SSH接続)〜5. sysctlの設定はSSH接続で作業してください。
現在のUbuntuバージョン確認
lsb_release -dNo LSB modules are available.
Description: Ubuntu 24.04.4 LTS ヒント
24.04はブラケットペーストモードが有効になっているためコマンドペースト後、ENTERで実行する必要があります。
ブラケットペーストモードOFF
grep -qxF 'set enable-bracketed-paste off' ~/.inputrc || echo 'set enable-bracketed-paste off' >> ~/.inputrcSSH再接続
exitSSHで再接続してください。
リレーサーバーにGrafanaを搭載している場合の対応
4. 依存関係再インストール
システムアップデート
sudo apt update && sudo apt upgrade -ysudo apt install bc curl htop nano needrestart protobuf-compiler rsync ufw zstd automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libncurses-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libtool autoconf liblmdb-dev liburing-dev libsnappy-dev -yデーモン再起動自動化
sudo grep -qxF "\$nrconf{restart} = 'a';" /etc/needrestart/conf.d/50local.conf || \
echo "\$nrconf{restart} = 'a';" | sudo tee -a /etc/needrestart/conf.d/50local.conf > /dev/nullsudo sed -i '/^\$nrconf{blacklist_rc}/d' /etc/needrestart/conf.d/50local.confsudo grep -qxF "\$nrconf{blacklist_rc} = [qr(^cardano-node\\.service$) => 0,];" /etc/needrestart/conf.d/50local.conf || \
echo "\$nrconf{blacklist_rc} = [qr(^cardano-node\\.service$) => 0,];" | sudo tee -a /etc/needrestart/conf.d/50local.conf > /dev/null自動起動有効化
sudo systemctl enable --now cardano-nodeノード同期状況の確認
sudo journalctl -u cardano-node -fコンパイル済みHaskellパッケージ削除
cd ~/.cabal/store
rm -rf ghc-8.*sudo apt install bc curl htop nano needrestart protobuf-compiler python3-pip python3-venv python3-full rsync ufw zstd automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libncurses-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libtool autoconf liblmdb-dev liburing-dev libsnappy-dev -yPython依存関係エラーの対処
アップグレード後にaptコマンドで以下のような依存関係エラーが表示された場合の対処です。
The following packages have unmet dependencies:
python3.12-full : Depends: python3.12 (= 3.12.3-1ubuntu0.13) but 3.12.13-1+jammy1 is to be installed
python3.12-venv : Depends: python3.12 (= 3.12.3-1ubuntu0.13) but 3.12.13-1+jammy1 is to be installed
+jammy1の部分は+focal1等、サーバーのアップグレード履歴によって異なります。
python3 -m venv ~/notify-venv
~/notify-venv/bin/pip install -U pip
~/notify-venv/bin/pip install watchdog pytz python-dateutil requests discordwebhook slackweb i18nice[YAML] python-dotenv確認
~/notify-venv/bin/python -c "import watchdog, pytz, dateutil, requests, discordwebhook, slackweb, i18n, dotenv; print('OK')"OKsudo systemctl stop cnode-blocknotify.servicecat > $NODE_HOME/service/cnode-blocknotify.service << EOF
# file: /etc/systemd/system/cnode-blocknotify.service
[Unit]
Description=Cardano Node - SPO Blocknotify
BindsTo=cnode-cncli-sync.service
After=cnode-cncli-sync.service
[Service]
Type=simple
User=$(whoami)
WorkingDirectory=${NODE_HOME}/scripts/block-notify
ExecStart=/home/${USER}/notify-venv/bin/python -u ${NODE_HOME}/scripts/block-notify/block_notify.py
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=cnode-blocknotify
[Install]
WantedBy=cnode-cncli-sync.service
EOFsudo cp $NODE_HOME/service/cnode-blocknotify.service /etc/systemd/system/cnode-blocknotify.servicesudo chmod 644 /etc/systemd/system/cnode-blocknotify.servicesudo systemctl daemon-reloadsudo systemctl enable --now cnode-blocknotify.serviceデーモン再起動自動化
sudo grep -qxF "\$nrconf{restart} = 'a';" /etc/needrestart/conf.d/50local.conf || \
echo "\$nrconf{restart} = 'a';" | sudo tee -a /etc/needrestart/conf.d/50local.conf > /dev/nullsudo sed -i '/^\$nrconf{blacklist_rc}/d' /etc/needrestart/conf.d/50local.confsudo grep -qxF "\$nrconf{blacklist_rc} = [qr(^cardano-node\\.service$) => 0, qr(^cnode-blocknotify\\.service$) => 0, qr(^cnode-cncli-sync\\.service$) => 0,];" /etc/needrestart/conf.d/50local.conf || \
echo "\$nrconf{blacklist_rc} = [qr(^cardano-node\\.service$) => 0, qr(^cnode-blocknotify\\.service$) => 0, qr(^cnode-cncli-sync\\.service$) => 0,];" | sudo tee -a /etc/needrestart/conf.d/50local.conf > /dev/null自動起動有効化
sudo systemctl enable --now cardano-nodeノード同期状況の確認
sudo journalctl -u cardano-node -fコンパイル済みHaskellパッケージ削除
cd ~/.cabal/store
rm -rf ghc-8.*起動確認
blocknotify[***] SPO Block Notify(v2.*.*)を起動しましたノードが起動していなければ上記の表示になりません
最新バージョンにアップデート
現在の最新バージョンはv2.5.*なのでそれ以下の方は、4. アップデート手順を実施して更新してください。
SSHでアップグレードを実施した場合
予備SSHポート(1022)を削除する前に、現在のSSHポートを許可します。
※AWSやIONOSなどはVPS管理画面から削除してください。
ステータスを確認します。
sudo ufw statusStatus: active予備SSHポート(1022)を削除します。
sudo ufw delete allow 1022/tcp確認
sudo ufw status numbered5. sysctlの設定
バックアップを取得しておきます。
sysctl \
net.ipv4.conf.all.rp_filter \
net.ipv4.conf.default.rp_filter \
net.ipv4.icmp_echo_ignore_broadcasts \
net.ipv4.conf.all.accept_source_route \
net.ipv4.conf.default.accept_source_route \
net.ipv4.conf.all.accept_redirects \
net.ipv4.conf.default.accept_redirects \
net.ipv4.conf.all.secure_redirects \
net.ipv4.conf.default.secure_redirects \
net.ipv4.conf.all.log_martians \
net.ipv4.tcp_syncookies \
net.core.somaxconn \
net.ipv4.tcp_max_syn_backlog \
net.core.netdev_max_backlog \
net.ipv4.ip_local_port_range \
> "$HOME/sysctl-before-cardano-relay-$(date +%F).txt"sudo tee /etc/sysctl.d/99-cardano-relay.conf > /dev/null << 'EOF'
# ------------------------------
# Security hardening
# ------------------------------
# Ignore ICMP broadcast
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Disable source routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
# Disable ICMP redirects
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
# Log suspicious packets
net.ipv4.conf.all.log_martians = 1
# SYN flood protection
net.ipv4.tcp_syncookies = 1
# ------------------------------
# Relay network performance
# ------------------------------
# Increase TCP listen queue
net.core.somaxconn = 4096
# Increase SYN backlog
net.ipv4.tcp_max_syn_backlog = 4096
# Improve network buffer
net.core.netdev_max_backlog = 5000
# Increase ephemeral port range
net.ipv4.ip_local_port_range = 10000 65535
EOFバックアップを取得しておきます。
sysctl \
net.ipv4.conf.all.rp_filter \
net.ipv4.conf.default.rp_filter \
net.ipv4.icmp_echo_ignore_broadcasts \
net.ipv4.conf.all.accept_source_route \
net.ipv4.conf.default.accept_source_route \
net.ipv4.conf.all.accept_redirects \
net.ipv4.conf.default.accept_redirects \
net.ipv4.conf.all.secure_redirects \
net.ipv4.conf.default.secure_redirects \
net.ipv4.conf.all.log_martians \
net.ipv4.tcp_syncookies \
> "$HOME/sysctl-before-cardano-bp-$(date +%F).txt"sudo tee /etc/sysctl.d/99-cardano-bp.conf > /dev/null << 'EOF'
# ------------------------------
# Security hardening
# ------------------------------
# Ignore ICMP broadcast
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Disable source routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
# Disable ICMP redirects
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
# Log suspicious packets
net.ipv4.conf.all.log_martians = 1
# SYN flood protection
net.ipv4.tcp_syncookies = 1
EOF設定反映
sudo sysctl --system既存設定の確認
cat $HOME/sysctl-before-cardano-*.txt6. ノード再インストール
ソースコードからビルドしたcardano-node/cardano-cliを使用していた場合、もしくはノードアップデートする場合に以下の手順を実行してください。
ヒント
Last updated on