0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【2025年01月版】Ubuntu24.04 で systemd-journal-remote で journallog を転送する

Posted at

はじめに

いままで、rsyslogを使ってログの転送をしていたけど、journallogをそのまま転送できるらしいので試してみたメモ

受信側の設定

インストール

$ sudo apt install systemd-journal-remote

設定の編集

httpsではなく、httpで受信する(httpsの証明書とかしんどい)

$ sudo cp /lib/systemd/system/systemd-journal-remote.service /lib/systemd/system/systemd-journal-remote.service.back
$ sudo vim /lib/systemd/system/systemd-journal-remote.service
$ diff /lib/systemd/system/systemd-journal-remote.service /lib/systemd/system/systemd-journal-remote.service.back
16c16
< ExecStart=/usr/lib/systemd/systemd-journal-remote --listen-http=-3 --output=/var/log/journal/remote/
---
> ExecStart=/usr/lib/systemd/systemd-journal-remote --listen-https=-3 --output=/var/log/journal/remote/
$ sudo systemctl daemon-reload 

ログディレクトリの作成

$ sudo mkdir -p /var/log/journal/remote
$ sudo chown systemd-journal-remote /var/log/journal/remote

FWの穴を開ける

必要であれば

$ sudo ufw allow 19532

サービスの起動

$ sudo systemctl enable --now systemd-journal-remote.service 

送信側

インストール

$ sudo apt install systemd-journal-remote

設定

$ sudo vim /etc/systemd/journal-upload.conf

ホストのIPを設定する

[Upload]
URL=http://<ホストのIP>:19532

サービスの再起動

$ sudo systemctl restart systemd-journal-upload.service 

参照方法

受信側で journalctl で参照する
--directory 指定以外は普段と変わらない

$ sudo journalctl --directory=/var/log/journal/remote _HOSTNAME=<対象のホスト名>

複数ホストのログを同一ディレクトリに置いた場合は、-r-f が一つのホストのログでしか機能しないので注意

さいごに

かんたんでしたね

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?