惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
C
CERT Recently Published Vulnerability Notes
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
P
Privacy & Cybersecurity Law Blog
Simon Willison's Weblog
Simon Willison's Weblog
Jina AI
Jina AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
博客园_首页
F
Fortinet All Blogs
博客园 - Franky
Latest news
Latest news
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
D
Docker
Project Zero
Project Zero
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
Cisco Talos Blog
Cisco Talos Blog
Y
Y Combinator Blog
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
H
Help Net Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
PCI Perspectives
PCI Perspectives
Cloudbric
Cloudbric
V
Visual Studio Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理

博客园 - 风易微凉

AI笔记-快捷键2 AI笔记 快捷键1 AI笔记-钢笔PEN 我的2025 倒影中的你 后座有你 踏入破解行业 一个人、一场梦、一座空城、一生心疼 人间有味是清欢 安卓开发中遇到耗电量高的问题解决方案 no no no no 敢说不 逆向工程-反编译,嵌入 AlarmManager的使用 基于项目中遇到的技术问题,谈谈SharedPreferences的使用的注意问题 根据当前进程号,获取进程下线程数目 mongodb数据库磁盘碎片整理。 mongodb库表信息监控脚本 mongodb mapreduce示例 mongodb表字段处理生成域名字段
MongoDB数据库日志备份压缩脚本
风易微凉 · 2014-01-14 · via 博客园 - 风易微凉

脚本1小时执行一次,对mongod,mongos,arbiter,config的日志进行logRotate,对生成的日志进行压缩。

定期删除job脚本

#bo1.li
0 1 * * * /usr/bin/find /home/cipcache/var/log/config/config*log.* -ctime +14 -exec rm {} \;
0 1 * * * /usr/bin/find /home/cipcache/var/log/arbiter/arbiter*log.* -ctime +14 -exec rm {} \;
0 1 * * * /usr/bin/find /home/cipcache/var/log/mongos/mongos.log.* -ctime +14 -exec rm {} \;
0 1 * * * /usr/bin/find /home/cipcache/var/log/mongod/shard.log.* -ctime +14 -exec rm {} \;

压缩备份脚本

#!/bin/bash
cd "$(dirname $0)";

curDate=`date '+%Y%m%d_%H%M%S'`
logpath="/home/cipcache/var/log"
mongodlogpath="$logpath/mongod"
mongoslogpath="$logpath/mongos"
arbiterlogpath="$logpath/arbiter"
configlogpath="$logpath/config"

mongodlogfile="$logpath/mongod/shard.log"
mongoslogfile="$logpath/mongos/mongos.log"

C_DC_PORT=(24001 24002 24003 24004)
A_DC_PORT=(21001 21002 21003 21004)


if [ ! -d "$newmongoslogpath" ];then
mkdir -p $newmongoslogpath
fi

if [ ! -d "$newmongodlogpath" ];then
mkdir -p $newmongodlogpath
fi

#if [ ! -d "$newarbiterlogpath" ];then
# mkdir -p $newarbiterlogpath
#fi

#if [ ! -d "$newconfiglogpath" ];then
# mkdir -p $newconfiglogpath
#fi


if [ -f $mongodlogfile ];then
/home/cipcache/sbin/mongodb/mongo admin --eval "db.runCommand( { logRotate : 1 } )"
newmongodlogName=`ls -t $mongodlogpath | grep "shard.log.\/*" | awk 'NR==1'`
if [ -n ${newmongodlogName} ] && [ -f "$mongodlogpath/$newmongodlogName" ] ;then
#mv $mongodlogpath/$newmongodlogName $newmongodlogpath/shard.log.$curDate
#cd $newmongodlogpath;/usr/bin/gzip shard.log.$curDate
/usr/bin/gzip "$mongodlogpath/$newmongodlogName"
fi
fi

if [ -f $mongoslogfile ];then
/home/cipcache/sbin/mongodb/mongo --port 30000 admin --eval "db.runCommand( { logRotate : 1 } )"
newmongoslogName=`ls -t $mongoslogpath | grep "mongos.log.\/*" | awk 'NR==1'`
if [ -n ${newmongoslogName} ] && [ -f "$mongoslogpath/$newmongoslogName" ] ;then
#mv $mongodlogpath/$newmongodlogName $newmongodlogpath/shard.log.$curDate
#cd $newmongodlogpath;/usr/bin/gzip shard.log.$curDate
/usr/bin/gzip "$mongoslogpath/$newmongoslogName"
fi
fi

for value in ${C_DC_PORT[*]}
do
/home/cipcache/sbin/mongodb/mongo --port $value admin --eval "db.runCommand( { logRotate : 1 } )"
newconfiglogName=`ls -t $configlogpath/config*log.* | awk 'NR==1'`
#mv $newconfiglogName $newconfiglogpath/config$value.log.$curDate
if [ -n ${newconfiglogName} ] ;then
/usr/bin/gzip "$newconfiglogName"
fi
done

for value in ${A_DC_PORT[*]}
do
/home/cipcache/sbin/mongodb/mongo --port $value admin --eval "db.runCommand( { logRotate : 1 } )"
newarbiterlogName=`ls -t $arbiterlogpath/arbiter*log.* | awk 'NR==1'`
#mv $newarbiterlogName $newarbiterlogpath/arbiter$value.log.$curDate
if [ -n ${newarbiterlogName} ];then
/usr/bin/gzip "$newarbiterlogName"
fi
done

exit 0