In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to use ramlog to transfer log files to memory in the Ubuntu system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use ramlog to transfer log files to memory in the Ubuntu system.
Ramlog runs as a system daemon. When the system boots, it creates a virtual disk (ramdisk), copies the files under / var/log to the virtual disk, and mounts the virtual disk as / var/log. Then all logs are updated to the virtual disk. When ramlog restarts or stops, the logs that need to be recorded on the hard disk are retained in the directory / var/log.hdd. When shutting down, the log files (on ramdisk) are re-saved to the hard drive to ensure log consistency. Ramlog 2.x uses the tmpfs file system by default, but it also supports ramfs and kernel ramdisk. Use rsync (Linux data Mirror backup tool) to synchronize logs.
Note: in the event of a sudden power outage or a kernel crash (kernel panic), logs that are not saved to the hard drive will be lost.
If you have enough available memory and want to put logs on a virtual disk, install ramlog. It is a good choice for notebook users, systems with UPS, or systems running directly in flash, and can save log writing time. The operation mechanism and steps of Ramlog are as follows:
Ramlog is started by the first daemon (depending on the other daemons you have installed).
Then create the directory / var/log.hdd and hard-link it to / var/log.
If you are using a tmpfs (default) or ramfs file system, mount it on / var/log.
If you are using a kernel ramdisk,ramdisk, it is created in / dev/ram9 and mounted to / var/log. By default, ramlog consumes all ramdisk memory, and its size is specified by the kernel parameter "ramdisk_size".
Then other daemons are started and the log is updated in ramdisk. Logrotate and ramdisk also work well together.
When you restart ramlog (once a day by default), the directory / var/log.hdd will be synchronized with / var/log with the help of rsync. The frequency of automatic log saving can be controlled by cron (Linux routine work scheduling). By default, ramlog's scheduling tasks are placed under the directory / etc/cron.daily.
When the system shuts down, ramlog shuts down before the last daemon shuts down.
During the ramlog shutdown, the files in / var/log.hdd are synchronized to / var/log, then / var/log and / var/log.hdd are uninstalled, and then the empty directory / var/log.hdd is deleted.
Install Ramlog in Ubuntu
First you need to download the .deb installation package from here with the following command:
Wget http://www.tremende.com/ramlog/download/ramlog_2.0.0_all.deb
After downloading the ramlog_2.0.0_all.deb installation package, install it using the following command:
The code is as follows:
Sudo dpkg-I ramlog_2.0.0_all.deb
This step will complete the entire installation, and now you need to run the following command:
The code is as follows:
Sudo update-rc.d ramlog start 2 2 3 4 5. Stop 99 0 1 6
.
Now, update the initialization order of sysklogd so that it shuts down correctly before ramlog stops running:
The code is as follows:
Sudo update-rc.d-f sysklogd remove
Sudo update-rc.d sysklogd start 10 2 3 4 5. Stop 90 0 1 6.
Then restart the system:
The code is as follows:
Sudo reboot
When the system is rebooted, run 'ramlog getlogsize' to get your current / var/log space. On top of this, allocate 40% more space to ensure that the ramdisk has enough space (this will be the size of the ramdisk as a whole).
Edit the boot configuration file, such as / etc/grub.conf, / boot/grub/menu.lst, or / etc/lilo.conf, and give your current kernel a new option, 'ramdisk_size=xxx', where xxx is the space size of ramdisk.
Configure Ramlog
On deb-based systems, the configuration file for Ramlog is located in / etc/default/ramlog, where you can set the following variables:
The code is as follows:
RAMDISKTYPE=0
# value:
# 0-tmpfs (which can be swapped to swap partition)-default
# 1-ramfs (the maximum space size cannot be set in the old kernel
# cannot be swapped to swap partition and is not compatible with SELinux)
# 2-Old Kernel ramdisk
TMPFS_RAMFS_SIZE=
# maximum memory size that can be used for tmpfs or ramfs
# this value can be a percentage or a numeric value (in Mb), for example:
# TMPFS_RAMFS_SIZE=40%
# TMPFS_RAMFS_SIZE=100m
# the empty value means that the size of the tmpfs/ramfs is 50% of the total memory
# for more options, please refer to the Mount options for tmpfs' section in 'man mount''.
# (add that in newer kernels, ramfs supports size limits
# although it is said in man that this mount option is not available)
# this option is only available for RAMDISKTYPE=0 or 1
KERNEL_RAMDISK_SIZE=MAX
# the kernel ramdisk size specified in kb, or use MAX to use the entire ramdisk.
# this option is only used when RAMDISKTYPE=2
LOGGING=1
# 0 = off, 1 = on. Record your own log to / var/log/ramdisk
LOGNAME=ramlog
# own log file name (for LOGGING=1)
VERBOSE=1
# 0 = off, 1 = on (set to 1, teststartstop will be called when start or stop fails to change the details
# write to log)
Uninstall ramlog in Ubuntu
Open the terminal and run the following command:
The code is as follows:
Sudo dpkg-P ramlog
Note: if ramlog is still running before uninstalling, you need to restart the system to complete the entire uninstall.
At this point, I believe you have a deeper understanding of "how to transfer log files to memory with ramlog in the Ubuntu system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.