logrotate

Tomcat的catalina.out文件过大问题(logrotate方式)

爱⌒轻易说出口 提交于 2019-11-30 09:37:54
问题 sudo du -sh /opt/tomcat/logs/* ... 4.5G /opt/tomcat/logs/catalina.out ... Tomcat在Cent OS上面的日志文件catalina.out达到了4G多。 解决 logrotate 创建配置文件 vi /etc/logrotate.d/tomcat 编写配置文件: /opt/tomcat/logs/catalina.out { copytruncate daily rotate 7 compress missingok size 5M } 配置说明: /opt/tomcat/logs/catalina.out :需要归档的日志路径 copytruncate :复制截断模式 daily :每天触发一次 rotate :最多7个日志文件 compress : 使用压缩 missingok :如果缺少日志文件,请继续执行下一个日志文件而不发出错误消息 size : 仅当日志文件大小超过字节大小时才会轮换日志文件 这样logrotate就每天自动触发一次日志切割归档。 测试logrotate轮写日志 logrotate -v /etc/logrotate.conf ... rotating pattern: /opt/tomcat/logs/catalina.out 5242880 bytes (7

MongoDB日志文件过大清理完整版

假如想象 提交于 2019-11-30 09:35:47
MongoDB日志文件过大 MongoDB启动的时候指定了--logpath为一个日志文件。随着时间此文件会变得越来越大,达到好几个G。 因为不想让MongoDB进程重新启动,所以不能停止进程删除此文件。解决的方法网上给方式有两种。 第一种方式 进入到mongo的命令行交互程序,输入: admin数据库账户要给于root权限才行 use admin; db.auth('root','leguan168#'); db.runCommand({logRotate:1}); 或用 db.adminCommand({logRotate:1}) use admin db.runCommand({logRotate: 1}) 经过测试发现,此种方式只能让主mongo的日志滚动。如果是集群部署的话,其他机上的mongo日志并不会滚动。 所以还需要使用下面的方式。 第二种方式 在Linux的命令上输入如下命令: ps aux|grep mongo 找到mongodb的进程ID,记下来。在输入命令: kill -SIGUSR1 <pid> 此种方式只能修改当前机器上的mongo日志滚动。如果是集群部署,需要在所有运行mongodb的机上执行此命令。 参考: https://docs.mongodb.com/manual/tutorial/rotate-log-files/ http://blog

MongoDB配置按天存储日志文件完结篇

假如想象 提交于 2019-11-30 09:35:29
MongoDB配置按天存储日志文件 2017年11月28日 10:14:39 羊子雄起 阅读数 2059 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010499087/article/details/78652114 mongodb默认不提供直接按天来输出日志文件的配置,但是提供一个日志清理的命令:logRotate。如果日志不及时清理会导致mongo访问越来越慢,甚至卡死。 要使用logRotate命令需要进入到mongo shell,然后执行: use admin #db.auth('username','password'); db.runCommand({logRotate:1}); 必须要进到admin库中才生效,如果配置auth需要填写用户名和密码 执行完毕后会在logpath目录中生成一个当前时间节点的备份文件,并且原来的日志文件内容会被清除掉。 具体的logRotate的介绍见: http://docs.mongodb.org/manual/tutorial/rotate-log-files/ 在生产环境上不可能每天定时由人工来执行日志文件清理,所以可以写一个脚本,由crontab定时在每天定时执行转储工作,具体脚本内容如下: mongo 127.0.0.1:27021/admin --eval "db

软件安装 RPM SRPM YUM

余生颓废 提交于 2019-11-29 21:43:42
RPM介绍 RPM是已经编译好的软件安装库。编译是有相应环境相适应的,包括系统,版本等相关信息都要跟编译版本一致才行,否则肯定会出现安装不成功的情况,强制安装的话,也会出现各种各样的问题。 在这种情况下,就出现了SRPM的格式,带源码的安装库文件。 RPM和SRPM的相关区别,如下图 YUM原理图 rpm使用详解 强制安装 同理,如果要安装U盘中的软件,也需要如此来进行操作 RPM 升级与更新 RPM查询软件是否安装 [root@localhost ~]# rpm -q lograotate 未安装软件包 lograotate [root@localhost ~]# rpm -q logrotate logrotate-3.8.6-17.el7.x86_64 [root@localhost ~]# rpm -q logrotating 未安装软件包 logrotating [root@localhost ~]# rpm -ql logrotate /etc/cron.daily/logrotate /etc/logrotate.conf /etc/logrotate.d /etc/rwtab.d/logrotate /usr/sbin/logrotate /usr/share/doc/logrotate-3.8.6 /usr/share/doc/logrotate-3.8.6

Is it possible to run one logrotate check manually?

北慕城南 提交于 2019-11-29 18:33:40
Is it possible to run one iteration of logrotate manually without scheduling it on some interval? Yes: logrotate --force $CONFIG_FILE sandover logrotate -d [your_config_file] invokes debug mode, giving you a verbose description of what would happen, but leaving the log files untouched. If you want to force-run a single specific directory or daemon's log files, you can usually find the configuration in /etc/logrotate.d , and they will work standalone. Keep in mind that global configuration specified in /etc/logrotate.conf will not apply, so if you do this you should ensure you specify all the

Linux命令:logrotate

跟風遠走 提交于 2019-11-29 18:23:28
logrotate命令 logrotate命令 用于对系统日志进行轮转、压缩和删除,也可以将日志发送到指定邮箱。使用logrotate指令,可让你轻松管理系统所产生的记录文件。每个记录文件都可被设置成每日,每周或每月处理,也能在文件太大时立即处理。您必须自行编辑,指定配置文件,预设的配置文件存放在 /etc/logrotate.conf 文件中。 语法 logrotate(选项)(参数) 选项 -?或--help:在线帮助; -d或--debug:详细显示指令执行过程,便于排错或了解程序执行的情况; -f或--force :强行启动记录文件维护操作,纵使logrotate指令认为没有需要亦然; -s<状态文件>或--state=<状态文件>:使用指定的状态文件; -v或--version:显示指令执行过程; -usage:显示指令基本用法。 参数 配置文件:指定lograote指令的配置文件。 来源: https://blog.csdn.net/liver_life/article/details/100879152

linux下logrotate 配置和理解

你。 提交于 2019-11-29 07:34:19
对于Linux 的系统安全来说,日志文件是极其重要的工具。系统管理员可以使用logrotate 程序用来管理系统中的最新的事件,对于Linux 的系统安全来说,日志文件是极其重要的工具。系统管理员可以使用logrotate 程序用来管理系统中的最新的事件。logrotate 还可以用来备份日志文件,本篇将通过以下几部分来介绍 日志文件的管理: 1、logrotate 配置 2、缺省配置 logrotate 3、使用include 选项读取其他配置文件 4、使用include 选项覆盖缺省配置 5、为指定的文件配置转储参数 一、logrotate 配置 logrotate 程序是一个日志文件管理工具。用来把旧的日志文件删除,并创建新的日志文件,我们把它叫做“转储”。我们可以根据日志文件的大小,也可以根据其天数来转储,这个过程一般通过 cron 程序来执行。 logrotate 程序还可以用于压缩日志文件,以及发送日志到指定的E-mail 。 logrotate 的配置文件是 /etc/logrotate.conf。主要参数如下表: 参数 功能 compress 通过gzip 压缩转储以后的日志 nocompress 不需要压缩时,用这个参数 copytruncate 用于还在打开中的日志文件,把当前日志备份并截断 nocopytruncate 备份日志文件但是不截断 create

MongoDB 日志切换(Rotate Log Files)实战

倾然丶 夕夏残阳落幕 提交于 2019-11-29 07:33:19
MongoDB 日志切换(Rotate Log Files)实战 2019.03.09 14:42 274浏览 MongoDB 日志切换(Rotate Log Files)实战 1. 在mongo shell下,执行logRotate命令: use admin db.runCommand({logRotate:1}) 需要在mongos,mongod,config server运行。 该方式的变种: a) 在unix shell下运行: mongo localhost/admin –eval “dbo.runCommand({logRotate:1})” b) Bash脚本: #!/bin/sh ### log rotate mongo localhost/admin –evel “db.runCommand({logRotate:1})” ### compress newly rotated for f in /var/log/mongodb/mongod.log.????-??-??T??-??-??; do 7za a “$f.z” “$f” rm –f “$f” done c) 将如下脚本保存到logRotate.js文件: db.getMongo().getDB(“admin”).runCommand({logRotate:1}) 创建脚本logRotate.sh: #!

MongoDB日志切换(RotateLogFiles)实战

空扰寡人 提交于 2019-11-29 07:33:05
MongoDB日志切换(RotateLogFiles)实战  原创  2016-06-07 14:55:53  0  236 MongoDB 日志切换(Rotate Log Files)实战 1. 在mongo shell下,执行logRotate命令: useadmindb.runCommand({logRotate:1}) 需要在mongos,mongod,config server运行。 该方式的变种: a) 在unix shell下运行: mongolocalhost/admin–eval“dbo.runComma MongoDB 日志切换(Rotate Log Files)实战 1. 在mongo shell下,执行logRotate命令: 1 2 use admin db.runCommand({logRotate:1}) 需要在mongos,mongod,config server运行。 该方式的变种: a) 在unix shell下运行: 1 mongo localhost /admin – eval “dbo.runCommand({logRotate:1})” b) Bash脚本: 1 2 3 4 5 6 7 8 9 #!/bin/sh ### log rotate mongo localhost /admin –evel “db.runCommand(

Logrotate files with date in the file name

烂漫一生 提交于 2019-11-28 17:29:58
I am trying to configure logrotate in RHEL for tomcat6 logs. Currently, logrotate works fine for catalina.out log, it is rotated and compressed properly. The problem is with the files with date in them like: catalina.2012-01-20.log catalina.2012-01-21.log catalina.2012-01-22.log These files are not being rotated. I understand that I have to configure these in /etc/logrotate.d/tomcat6 file where rotation for catalina.out is configured. But I am not able to configure it. All I want is these older files to be compressed daily, except the current date log file. Can anybody help me out on this,