The previous article has the salt installation process and the Salt module, not clear can go to look, this article mainly realizes nginx+php uses the logrotate to carry on the cutting to the log, then simply uses under the Salt this tool;
The architecture is as follows:
The following. pp files are under/etc/puppet/modules/logrotate/manifests, as follows
Init.pp
Class
System Environment
Ubuntu 14.04LTSNginx 1.4.7 Edit the Nginx file under Logrotate
$ Vim/etc/logrotate.d/nginx
/usr/local/nginx/logs/*.log {//log location
su root list //Use root permission , if not used may report permissions related to the issue following the mention
daily// run once a day
Missingok //If the log file is missing, do not error continue to perform the next
rotate 7 // Log save 7 days
dateext//File suffix i
Many software comes with cutting logs, such as Tomcat, which can be named by time. Rsyslog can generate files by date, but does not support "% $year%-% $month%-% $day%" These variables to read the file (current version number: rsyslog-8.17.0-1.el6.x86_64).Then, you need to use the log polling logrotate.
overview, configuration.Global configuration:/etc/logrotate.confLocal configuration:/etc/logrotate.d/for ease of administration, custom confi
log_throttle_queries_not_using_indexes to limit the number of logs that do not use indexes per minute.Slow log outputMySQL slow query log by default is all written to a file, the file will be more and more large, very inconvenient for us to analyze. Use logrotate to cut MySQL slow query log, error log, to facilitate analysis and find problems.Define the log theory roll strategy [Email protected]_db_40 ~]# Cat Mysql-log-rotate/opt/mysql/data/idc_db_40
1, under the LOGROTATE.D a new file, file name random
Touch/etc/logrotate.d/tomcat-log-cut
2, the contents of the document:
/home/mes/tomcat8-mes/logs/catalina.out {
Su root rootDailyRotate 14DateextDateFormat.%y%m%d#size 100NotifemptyMissingokCopytruncate}
Parameter explanation Please refer to: http://blog.csdn.net/maosijunzi/article/details/78813573
3, execute the following command to test a
/usr/sbin/logrotate/etc/logrotate.conf
4, if not s
Label: better embedded operating system space planScenario: in the actual application environment, we need to independently mount the log directory to a partition or a virtual memory disk. If you mount/var/log to the memory virtual disk and the file format is tmpfs, You need to calculate it carefully. After all, memory resources are always limited, not to mention embedded operating systems. Therefore, it is best to allocate proper memory space during mounting. The so-called fit should be the max
Tags: how to record file Many people ask how to know when the system will perform log storage and rollback, view the details of cron. daily, and view the scripts in logroate: #! /Bin/sh /Usr/sbin/logrotate/etc/logrotate. conf Exitvalue = $? If [$ exitvalue! = 0]; then /Usr/bin/logger-T logrotate "alert exited abnormally with [$ exitvalue]" Else /Usr/bin/
Use logrotate to poll nginx and Apache Log document directories [Hide]
Configure nginx
Configure Apache
Using logrotate to poll logs is convenient and easy to configure. Configure nginx 1. Create the/etc/logrotate. d/nginx file.
VI/etc/logrotate. d/nginx
2. Write the following co
Detailed Introduction http://blog.csdn.net/hepeng597/article/details/7768615Reference http://www.linuxidc.com/Linux/2011-04/34116.htm1 For example we want to cut Nginx log, first we enter/etc/logrotate.d/this directory, and then build nginx this fileVI Nginx/data/wwwlogs/*nginx.log {# #日志所在的目录dailyrotate 5missingokdateextcompressnotifemptysharedscriptspostrotate [-E/ Var/run/nginx.pid] kill-usr1 ' cat/var/run/nginx.pid ' Endscript}Parameter descripti
The understanding of the Logrotate operating mechanism is as follows:1, scheduled execution by Cron, script location/etc/cron.daily/logrotate2, logrotate script default profile/etc/logrotate.conf3, cron execution logrotate time not found the exact time currently (Times this self-defined)The test found that due to the rotation log date can only be the current date
I,
Crontab routine check: If it is self-developedProgramTo open the file, you need to change the current working directory by absolute path or chdir.
Use getcwd to obtain the current working directory.
Ii. log rolling
Run the following command first:
[Root @ local cron. daily] #/usr/sbin/logrotate-F/etc/logrotate. confError: Error accessing/var/log/conman: no such file or directory
Error: conman: 5
Tags: mysqlDepending on your needs, you can make a day-to-days dump of the MySQL-related log files (error logs, common query log files, and slow query log files) and keep only the backup files for a specified number of days, as an example:1), install Crond service (if yum install logrotate crontabsis not installed)Rpm-qa | grep crontabsYum Install CrontabsChkconfig Crond--list #如果未设置为自动重启这执行如下命令修改Chkconfig Crond onService Crond Restart2), create the M
1. Download LogrotateInstallation in Fedora and CentOSInstall logrotate crontabsOn Debian and UbuntuInstall logrotate cron2. Create a log filecd/var/log/Touchfilefile. log3. Create a File.log profile to addvim/etc/logrotate.d/File/vsr/log/file.log{Monthly log files per month round daily daily weakly yealyRotate 5 Stores 5 archived logs, the longest automatic deletion for the six
One
Crontab routine Check: If you are developing your own program, opening the file requires an absolute path or chdir to change the current working directory.
Use GETCWD to get the current working directory.
Second, log scrolling
Use the Execute command first:
[Root@local cron.daily]#/usr/sbin/logrotate-f/etc/logrotate.confError:error accessing/var/log/conman:no such file or directory
Error:conman:5 Glob failed for/var/log/conman/*
If the
Recently found in a server MySQL audit (http://jim123.blog.51cto.com/4763600/1955487) plug-in log no data, just started to think that is configured to the problem in the database check to see that there is no problem, Later found in the MySQL audit specified file path issued by the existing rotation log, the preliminary analysis is in the use of the system logrotate (http://jim123.blog.51cto.com/4763600/1880582) to do the log rotation to/etc/ LOGROTAT
Believe that the RSYSLOGD logrotate transfer cutting log students, will find the log after the file, will appear inaccurate date problem
For example: The June 21-generated log was transferred to the June 22 document for no reason, and the date was one day ahead of schedule.
Or even if the 21st log is transferred to the number 21st file, when you open but found that there are 20th of the contents.
After a few days of verification, finally found that t
Virtualmin occurs when checking to verify that the error is present logrotate configuration is not valid:Error:stat Of/var/log/cron failed:no such file or directory
1. Main reasons
Log file rotation feature restricted
This is due to the syslog daemon not running. Check If the service is running and restart. Your server may have syslogd daemon on rsyslogd depending on Your OS.
2. Solutions
Let's look at the status first.
/etc/init.d/rsyslog statu
, and ~SizeDump is performed only when the log file reaches the specified Size. The Size can be bytes (default), KB (sizek), or MB (sizem ).
The system executes and operates logrotate:In/etc/cron. there is a logrotate shell script in the daily/path. Therefore, the cron program calls the logrotate program once a day, and then the logrotate program checks whether t
configuration file/etc/syslog. conf is written, the scope
For example, for the log server 218.192.87.24
If the Info-level auth information is sent to the log server
Add auth.info @ 218.192.87.24 to the row.
Log dumping Service
After the system has been working for a certain period of time, the content of log files increases with the increase of time and traffic,
Log files are also growing. When the log file exceeds the system control range
. The dump mode can be set to annual dump
Tutorial purpose:Use the built-in Linux command logrotate to cut Nginx logs.Nginx installation directory:/usr/local/nginx/Nginx log Directory:/usr/local/nginx/logs/,/usr/local/nginx/logs/nginx_logs/1. Add an nginx log cutting scriptCd/etc/logrotate. d # enter the DirectoryVi/etc/logrotate. d/nginx # edit the script/Usr
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.