Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

README.md 5.6 KiB

il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 7 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 2 ans
il y a 6 ans
il y a 7 ans
il y a 8 ans
il y a 8 ans
il y a 7 ans
il y a 8 ans
il y a 5 ans
il y a 7 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. # Log2Ram
  2. Like ramlog for systemd (on debian 8 jessie for example).
  3. Usefull for **RaspberryPi** for not writing on the SD card all the time. You need it because your SD card doesn't want to suffer anymore!
  4. Explanations: The script creates a `/var/log` mount point in RAM. So any writing of the log to the `/var/log` folder will not actually be written to disk (in this case to the SD card for a Raspberry Pi) but directly to RAM. By default, every day, the CRON will launch a synchronization of the RAM to the folder located on the physical disk. The script will also make this copy of RAM to disk in case of machine shutdown (but cannot do it in case of power failure). This way you avoid excessive writing on the SD card.
  5. The script [log2ram](https://github.com/azlux/log2ram) can work on every linux system. So you can use it with your own daemon manager if you don't have systemd.
  6. Log2Ram is based on transient log for Systemd here : [A transient /var/log](https://www.debian-administration.org/article/661/A_transient_/var/log)
  7. _____
  8. ## Table of Contents
  9. 1. [Install](#install)
  10. 2. [Is it working?](#is-it-working)
  11. 3. [Upgrade](#upgrade)
  12. 4. [Customize](#customize)
  13. 5. [Troubleshooting](#troubleshooting)
  14. 6. [Uninstall](#uninstall-)
  15. ## Install
  16. ### With APT (recommended)
  17. echo "deb [signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian/ bullseye main" | sudo tee /etc/apt/sources.list.d/azlux.list
  18. sudo wget -O /usr/share/keyrings/azlux-archive-keyring.gpg https://azlux.fr/repo.gpg
  19. sudo apt update
  20. sudo apt install log2ram
  21. ### Manually
  22. curl -L https://github.com/azlux/log2ram/archive/master.tar.gz | tar zxf -
  23. cd log2ram-master
  24. chmod +x install.sh && sudo ./install.sh
  25. cd ..
  26. rm -r log2ram-master
  27. For better performances. `RSYNC` is a recommended package.
  28. **REBOOT** before installing anything else (for example apache2)
  29. ## Is it working?
  30. After installing and rebooting, use systemctl to check if Log2Ram started successfully:
  31. ```
  32. systemctl status log2ram
  33. ```
  34. This will show a color-coded status (green active/red failed) as well as the last few log lines. To show the full log (scrolled to the end), run:
  35. ```
  36. journalctl -u log2ram -e
  37. ```
  38. The log is also written to `/var/log/log2ram.log`.
  39. You can also inspect the mount folder in ram with (You will see lines with log2ram if working)
  40. ```
  41. # df -h | grep log2ram
  42. log2ram 40M 532K 40M 2% /var/log
  43. # mount | grep log2ram
  44. log2ram on /var/log type tmpfs (rw,nosuid,nodev,noexec,relatime,size=40960k,mode=755)
  45. ```
  46. ## Upgrade
  47. You need to stop log2ram (`service log2ram stop`) and start the [install](#install). (APT will do it automatically)
  48. ## Customize
  49. #### variables :
  50. In the file `/etc/log2ram.conf`, there are five variables:
  51. - `SIZE`: defines the size the log folder will reserve into the RAM (default is 40M).
  52. - `USE_RSYNC`: (commented out by default = `true`) use `cp` instead of `rsync` (if set to `false`).
  53. - `MAIL`: disables the error system mail if there is not enough place on RAM (if set to `false`).
  54. - `PATH_DISK`: activate log2ram for other path than default one. Paths should be separated with a `;`.
  55. - `ZL2R`: enable zram compatibility (`false` by default). Check the comment on the config file. See https://github.com/StuartIanNaylor/zram-swap-config to configure a zram space on your raspberry before enable this option.
  56. #### refresh time:
  57. By default Log2Ram writes to disk every day. If you think this is too much, you can run `systemctl edit log2ram-daily.timer` and add:
  58. ```ini
  59. [Timer]
  60. OnCalendar=
  61. OnCalendar=Mon *-*-* 23:55:00
  62. ```
  63. ... or even disable it with `systemctl disable log2ram-daily.timer`, if you prefer writing logs only at stop/reboot.
  64. #### compressor:
  65. Compressor for zram. Usefull for the `COMP_ALG` of ZRAM on the config file.
  66. | Compressor name | Ratio | Compression | Decompress. |
  67. |------------------------|----------|-------------|-------------|
  68. |zstd 1.3.4 -1 | 2.877 | 470 MB/s | 1380 MB/s |
  69. |zlib 1.2.11 -1 | 2.743 | 110 MB/s | 400 MB/s |
  70. |brotli 1.0.2 -0 | 2.701 | 410 MB/s | 430 MB/s |
  71. |quicklz 1.5.0 -1 | 2.238 | 550 MB/s | 710 MB/s |
  72. |lzo1x 2.09 -1 | 2.108 | 650 MB/s | 830 MB/s |
  73. |lz4 1.8.1 | 2.101 | 750 MB/s | 3700 MB/s |
  74. |snappy 1.1.4 | 2.091 | 530 MB/s | 1800 MB/s |
  75. |lzf 3.6 -1 | 2.077 | 400 MB/s | 860 MB/s |
  76. ###### Now, muffins for everyone!
  77. ## Troubleshooting
  78. ### Existing content in `/var/log` too large for RAM
  79. One thing that stops Log2Ram from starting is if `/var/log` is to large before starting Log2Ram the first time. This can happen if logs had been collected for a long time before installing Log2Ram. Find the largest directories in `/var/log` (this commands only shows the 3 largest):
  80. ```
  81. sudo du -hs /var/log/* | sort -h | tail -n 3
  82. ```
  83. If the `/var/log/journal` is very large, then there are a lot of system logs. Deletion of old "archived" logs can be fixed by adjusting a setting. Edit the `/etc/systemd/journald.conf` file and add the following option:
  84. ```
  85. SystemMaxUse=20M
  86. ```
  87. This should be set to a value smaller than the size of the RAM volume, for example half. Then apply the new setting:
  88. ```
  89. sudo systemctl restart systemd-journald
  90. ```
  91. This should shrink the size of "archived" logs to be below the limit. Reboot and check that Log2Ram succeds:
  92. ```
  93. sudo reboot
  94. systemctl status log2ram
  95. ```
  96. ## Uninstall :(
  97. (Because sometime we need it)
  98. ### With APT
  99. ```
  100. sudo apt remove log2ram
  101. ```
  102. You can use `--purge` to remove config files as well.
  103. ### Manually
  104. ```
  105. chmod +x /usr/local/bin/uninstall-log2ram.sh && sudo /usr/local/bin/uninstall-log2ram.sh
  106. ```