Red Hatã®æ£®è¥ã§ãã
ä»åã¯systemd-journald ã¨ãsystemd-journaldããã°æ å ±ãä¿åããjournalã®ãã¼ãã¼ãã«ã¤ãã¦ã®è©±ã§ãã
- çµè«
- systemd-journald ã¨ã¯?
- journalãã¡ã¤ã«ç¾¤
- journalã®ãã¼ãã¼ãã¨åé¤
- 1000人ã®ã¦ã¼ã¶ãããã·ã¹ãã
- SplitModeè¨å®
- çµè«(å)
- ã¾ã¨ã
çµè«
ã¦ã¼ã¶ãå¤ãç°å¢ã§ã¯ /etc/systemd/journald.conf 㧠SplitMode=noneã«å¤æ´ãããã
systemd-journald ã¨ã¯?
systemd-journaldã¯ãsystemdã¨çµ±åããããã°åéã»ä¿åãµã¼ãã¹ã§ãã å¾æ¥ãã syslogã§ä½¿ããã¦ãã /dev/log ã systemd unitã®æ¨æºåºåã»æ¨æºã¨ã©ã¼åºåãªã©æ§ã ãªå ¥åãããã¤ãã å°ç¨ã® journal ã¨ãã°ãããã¤ããªãã°ã¸ä¿åãã¾ãã
å¾æ¥ã®syslogã«ãããã°ã¨æ¯è¼ãã¦ãjournalã§ã¯ãã¼ã¿ãæ§é åããã¦ãã¦ãã¨ãã°ãã°åªå 度ã ãxæyæ¥10:10ãã10:30ã¾ã§ãã®ãããªæ¤ç´¢ãã§ããã»ãã ãã¤ã¯ãç§åä½ã®ã¿ã¤ã ã¹ã¿ã³ã群ãé¢é£ããsystemd unitãªã©è¿½å ã®ã¡ã¿ãã¼ã¿ãå«ãã§ãã¦ã¢ããªã±ã¼ã·ã§ã³ããã®æ¡å¼µãå¯è½ã§ä¾¿å©ã«å©ç¨ã§ãã¾ãã
RHEL 7,8,9ã®ããã©ã«ãã§ã¯ãjournalã¯tmpfsä¸ã«ä½æãããåèµ·åã«ããæ¶ãã¾ãã rsyslogã®imjournal pluginãjournalãèªã¿ã/var/log/messagesãªã©ã«ä¿åãã¾ãã ã¤ã¾ãjournalã¯ä¸»ã«rsyslogã¸ã®ä¸ç¶å½¹ã¨ãã¦å©ç¨ããã¦ãã¾ãã
journalã¯ä¸ç¶å½¹ã¨ãã¦ä½¿ãã ãã§ã¯ãªãå°ç¨ã®ã³ãã³ã journalctl ãå©ç¨ãã¦æ¤ç´¢ã»é²è¦§ã§ãã¾ãã
ãã®ã¨ãããã»ã©ã®ã¡ã¿ãã¼ã¿ã«ããæ¤ç´¢ãå½¹ã«ç«ã¡ã¾ãã
systemctl status chronyd.service
ã®ãããªã³ãã³ãã§ãµã¼ãã¹ã«é¢é£ããæè¿ã®ãã°ã表示ãããã®ã
journalãæ´»ç¨ãããã®ã§ãã
journalã¯tmpfsä¸ã§å©ç¨ããã»ãã«ãé常ã®ãã¡ã¤ã«ã·ã¹ãã ä¸ã¸ä¿åãã¦å©ç¨ãããã¨ãã§ãã¾ãã å©ç¨éå§ã¯é常ã«ç°¡åã§ãroot権é㧠/var/log/journal ãã£ã¬ã¯ããªãä½æããsystemd-journaldãåèµ·åããã ãã§ãã
# mkdir /var/log/journal # systemctl restart systemd-journald
journalã¯ä¾¿å©ã§ãããé·æéã»å¤§éã®ãã°ã«å¯¾å¿ãããã°ç®¡çã½ãªã¥ã¼ã·ã§ã³ã§ã¯ããã¾ããã ãã¨ãã°journalctlã«ããæ¤ç´¢ã»è¡¨ç¤ºã¯journalå ¨ä½ãèªã¿è¾¼ã¿ã¾ããæ°GBã10GBç¨åº¦ã«ããã¾ãç¯å²ã§å©ç¨ããã®ãããã§ãããã
journalãã¡ã¤ã«ç¾¤
journal ã¯ãè¤æ°ã®ãã¡ã¤ã«ãããªã£ã¦ãã¾ããé常ã®ã·ã¹ãã 管çã§ç´æ¥æä½ãããã¨ã¯ããã¾ãããã /run/log/journal ã¾ã㯠/var/log/journal ãã£ã¬ã¯ããªã®ä¸èº«ãè¦ã¦ã¿ã¾ãã journalãæ§æããåãã¡ã¤ã«ããjournalãã¡ã¤ã«ãã¨å¼ãã§journalã¨åºå¥ãã¾ãã
以ä¸ã®ä¾ã¯ç§ããã¹ã¯ãããç¨éã«å¸¸ç¨ãã¦ããç°å¢ã®ãã®ã§ããã¦ã¼ã¶æ°ãè¨å®ã«ããç´°ããªéãã¯ããã¾ãããè¦ãç®ã¯ãããããã®ããã«ãªãã¾ãã
$ tree /var/log/journal/ /var/log/journal/ âââ 0e5c275b71674a68a37d977e8902c7c7 (ä¸ç¥) âââ system@9946b0564b1841efba5ba6f72db3d490-00000000000f8e55-0005f02c9e33e417.journal âââ system@9946b0564b1841efba5ba6f72db3d490-00000000000fe0e8-0005f040c28107ac.journal âââ system.journal (ä¸ç¥) âââ user-1000@e5f646cd6f8249748eb5d5759a730a90-00000000000f8e69-0005f02cbe48cdc9.journal âââ user-1000@e5f646cd6f8249748eb5d5759a730a90-00000000000fe1b3-0005f040c284aad9.journal âââ user-1000.journal
ãã¡ã¤ã«åãé·ãã¦é¢åããã§ãããåè¿°ã®ã¨ãããããã®ãã¡ã¤ã«ç¾¤ãç´æ¥æä½ãããã¨ã¯åºæ¬çã«ããã¾ããã 以ä¸ç°¡åã«ã¾ã¨ãã¾ãã
- /run/log/journal ã¾ã㯠/var/log/journal ã®ä¸ã®ãã£ã¬ã¯ããªã¯ãmachine-id ã§ããè¤æ°ãã·ã³ã®journalãéç´ãã¦ã競åããªãããã«ãã·ã¹ãã æ¯ã«ä¸æãªmachine-idã§ãã£ã¬ã¯ããªãä½æããã¦ãã¾ãã
- system.journal 㨠user-<UID>.journal ããææ°ã® journal ãã¡ã¤ã«ã§ããæ°ãããã°ã¯ãã®ãã¡ã¤ã«ã«ä¿åããã¾ããjournalãã¡ã¤ã«ã¯å
容ããã°1è¡ç¸å½ã§ãæä½8MiBã§ä½æãããå¿
è¦ã«å¿ãã¦8MiBåä½ã§å¤§ãããªãã¾ãã
- å½åè¦åããæ³åãã¤ãããã«ãå¤æ°ã®ã¦ã¼ã¶ããã°ã¤ã³ããç°å¢ã§ã¯ user-<UID>.journal ã¯åã¦ã¼ã¶ã«å¯¾å¿ãã¾ãã
- 1度ã§ããã°ã¤ã³ãããã¨ãããå ¨ã¦ã¼ã¶ã®journalãã¡ã¤ã«ãä½æããã¾ããsshæ¥ç¶ãã³ã³ã½ã¼ã«ããã®ãã°ã¤ã³ãGUIã»ãã·ã§ã³ãªã©ã®ã¦ã¼ã¶ã®å¯¾è©±çãªã»ãã·ã§ã³å ã§çºçãããã°ã¯ãã¡ãã«ä¿åããã¾ãã
- journalãã¡ã¤ã«ã®uidã¯rootã§gidã¯systemd-journalã§ãããã ã該å½ã¦ã¼ã¶ã«èªã¿è¾¼ã¿ã許å¯ããACLãè¨å®ããããããã¦ã¼ã¶ã¯ç¹æ¨©ãsystemd-journalã°ã«ã¼ãã¸ã®åå ãªãã§èªã¿è¾¼ãã¾ããã¤ã¾ã
journalctl --user
ã³ãã³ãã§èªåã®ã»ãã·ã§ã³ã®ãã°ãé²è¦§ã§ãã¾ãã - ãã°ã¤ã³ãã¨ããªããªããåã«UIDãè¨å®ãããã ãã®ãµã¼ãã¹ã®ãã°ã¯system.journalã«ä¿åããã¾ãã
- system@9946b0564b1841efba5ba6f72db3d490-00000000000f8e55-0005f02c9e33e417.journal ã®ãããªé·ããã¡ã¤ã«åã®ãã¡ã¤ã«ã¯ããã¼ãã¼ããããéå»ã®journalã§ãã èå³ãããæ¹ã®ããã«ç´¹ä»ãã㨠(ãã¨ã®ãã¡ã¤ã«åã®baseé¨å)@(namespaceã§æ±ºã¾ãé·ãæ°å)-(journalã®ã«ã¼ã½ã«ä½ç½®)-(æå»).journal ã®ãããªè¦åã§å½åããã¦ãã¾ãã
journalã®ãã¼ãã¼ãã¨åé¤
systemd-journaldã¯ãã°ãjournalã«ä¿åããã¿ã¤ãã³ã°ã§ãæéã»ãµã¤ãºãªã©ã®æ¡ä»¶ãå¤å®ãã¦journalãèªåçã«ãã¼ãã¼ããã¾ããããã©ã«ãã§ã¯è¨é²ãã¯ããã¦30æ¥çµéãããå ¨ä½ã§å©ç¨ã§ãã容é(ããã©ã«ã㯠4GiBã¾ãã¯ãã¼ãã£ã·ã§ã³ã®10%ã®ã©ã¡ããå°ããªãµã¤ãº )ã®1/8ã®ãµã¤ãºã«ãªãçã®å¥æ©ã§ãã¼ãã¼ããã¾ãã
systemd-journaldã«ãããã¼ãã¼ãã¯logrotateã¨ç°ãªãå®æçã«å®è¡ãããã®ã§ã¯ãªãããã°åºåã¿ã¤ãã³ã°ã§è¡ãããç¹ã«éåæãããããããã¾ãããsystem.journal ã¯ã·ã¹ãã ãåç´ã«åä½ãã¦ããã ãã§ããã°ãåºåããã¾ãããuser-<UID>.journal ã¯è©²å½ããã¦ã¼ã¶ã®ãã°ã¤ã³ããªããã°å
¨ãåºåããã¾ããããããã¼ãã¼ãããã£ã¨è¡ããã¾ããã
ä¸é¨journalãã¡ã¤ã«ãå¤ããã¦æ°ã«ãªããããªå ´åã¯ãjournalctl --rotate
ã³ãã³ãã§å¼·å¶çã«ãã¼ãã¼ããçºçããããã¨ãã§ãã¾ãã
ãã¼ãã¼ããããéå»ã®journalã¯ããã¯ããã°åºåã®ã¿ã¤ãã³ã°ã§è¨å®ã«å¾ãåé¤ããã¾ããææ°ã®journalãã¡ã¤ã«ãåé¤ããããã¨ã¯ããã¾ããã
1000人ã®ã¦ã¼ã¶ãããã·ã¹ãã
ãã¦ã1000人ã®ã¦ã¼ã¶ãæ£çºçã«ãã°ã¤ã³ãã¦å©ç¨ããã·ã¹ãã ãèãã¦ã¿ã¾ããå ±ç¨ãããHPCã¯ã©ã¹ã¿ã大å¦ã®æ¼ç¿ç°å¢ã®ãããªã¤ã¡ã¼ã¸ã§ãã
- user-<UID>.journal ã1000å(!)ã§ãã¾ãã1ã¤æä½8MiBã§ããããæä½ã§8GiBå¼±ã«ãªãã¾ãã
- 8GiBå¼±ã®ãµã¤ãºã¯ãsystemd-journaldãããã©ã«ãã§è¨å®ããã4GiBã¾ãã¯ãã¼ãã£ã·ã§ã³ã®10%ã®ã©ã¡ããå°ããªãµã¤ãºããè¶ãã¦ãã¾ãã
- ææ°ã®journalãã¡ã¤ã«ã¯åé¤ããã¾ãããããã¼ãã¼ãã«ããä½æãããéå»ã®journalã¯ããµã¤ãºä¸éã«å½±é¿ãããã®ã§ä½æå¾ããã«åé¤ããã¾ãã
ãã®ç¶æ³ã§system.journalã«ãã¼ãã¼ããçºçããã¨ãjournalãããµã¼ãã¹ãªã©ã®éå»ã®ãã°ãã»ã¨ãã©æ¶ãã¦ãã¾ãã¾ãããã®å¾å¾ã ã«ãã°ãèç©ããã¦ããã次åã®ãã¼ãã¼ãã§ã¾ãæ¶ããã¨ããåä½ã®ç¹°ãè¿ãã«ãªãã¾ããããã¯ç¨éã«ãããã¾ããåä½ã§ãã
SplitModeè¨å®
ãã®ãããªã±ã¼ã¹ã§ã¯ãåã¦ã¼ã¶ã»ãã·ã§ã³ã®ãã°ã1ã¤ã®journalãã¡ã¤ã«ã«ã¾ã¨ãã¦è¨é²ããæ¹ãæå¾ ã«è¿ãåä½ã«ãªãã¾ãã /etc/systemd/journald.conf ã§ä»¥ä¸ã®è¨å®ãè¡ãã¾ããããã©ã«ãã§ã¯ "uid" ã¨ãªã£ã¦ãã¾ãããããã "none" ã¨ããã¨å ¨ä½ã systemd.journalã«è¨é²ããã¾ãã
SplitMode=none
ãã¡ã¤ã«ãã¦ã¼ã¶æ¯ã«åå²ããªããã¨ã§ããã¼ãã¼ã·ã§ã³æã«åç §ã§ããéå»ã®ãã°ã極端ã«å°ãªããªãç¾è±¡ãé¿ãããã¾ãã 1ã¤ã®ãã¡ã¤ã«ã«ã¾ã¨ããçµæã¨ãã¦ãåã¦ã¼ã¶ãããã©ã«ãã§ã¯èªåã®ã»ãã·ã§ã³ã®ãã°ãèªãã¾ãããã·ã¹ãã å ¨ä½ã®ãã°ãèªãã®ã¨åã権éãå¿ è¦ã«ãªãã¾ãã
çµè«(å)
ã¦ã¼ã¶ãå¤ãç°å¢ã§ã¯ /etc/systemd/journald.conf 㧠SplitMode=noneã«å¤æ´ãããã
ã¾ã¨ã
journal å©ç¨ä¸ã®ãã¤ã³ã
- journalã¯è¤æ°ã®ãã¡ã¤ã«ã«åããããå½¢ã§åå¨ãã
- journalã®æä½ã¯journalctlã³ãã³ã㨠systemd-journald ã®è¨å®ã§ãããªã
- logrotateã§ã¯ãªã systemd-journaldèªèº«ããã¼ãã¼ãããããªã
- å¤ãjournalã¯systemd-journaldããã¼ãã¼ãã®ã¿ã¤ãã³ã°ã§åé¤ãã
- åé¤æ¡ä»¶ã¯è¤æ°ããããµã¤ãºä¸éã®å ¸åçãªå¤ã¯4GiB
- ææ°ã®journalã¯æ¡ä»¶ã«ãããåé¤ãããªã
ã¦ã¼ã¶ãå¤ãã¨ãã®journalã®æ³¨æç¹
- ææ°ã®journalãã¡ã¤ã«ã¯å 容ã«ããã1㤠8MiB以ä¸
- SplitMode=uid 㧠容é4GiBã®ããã©ã«ãã®ä¸éè¨å®ã§ã¯500ã¦ã¼ã¶ã§ç¢ºå®ã«ãµã¤ãºã®ä¸éãè¶ãã
- ãµã¤ãºä¸éãè¶ããå ´åå®ç¨ä¸ã®åé¡ãããåä½ã«ãªã
- ãµã¤ãºä¸éãè¶ããªããã SplitMode=none ã®è¨å®ãè¡ã