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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
Webroot Blog
Webroot Blog
T
Troy Hunt's Blog
S
Secure Thoughts
S
Security @ Cisco Blogs
S
Security Affairs
Forbes - Security
Forbes - Security
W
WeLiveSecurity
H
Hacker News: Front Page
T
Threatpost
Google Online Security Blog
Google Online Security Blog
S
Schneier on Security
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - Franky
腾讯CDC
IT之家
IT之家
博客园 - 聂微东
L
LINUX DO - 最新话题
罗磊的独立博客
Hacker News - Newest:
Hacker News - Newest: "LLM"
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 三生石上(FineUI控件)
Hacker News: Ask HN
Hacker News: Ask HN
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
C
CERT Recently Published Vulnerability Notes
Know Your Adversary
Know Your Adversary
V
Vulnerabilities – Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cisco Talos Blog
Cisco Talos Blog
S
SegmentFault 最新的问题
酷 壳 – CoolShell
酷 壳 – CoolShell
Hugging Face - Blog
Hugging Face - Blog
L
LINUX DO - 热门话题
美团技术团队
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
AI
AI
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Jina AI
Jina AI
Help Net Security
Help Net Security
N
News | PayPal Newsroom
月光博客
月光博客
Spread Privacy
Spread Privacy
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
N
News and Events Feed by Topic

博客园 - 风易微凉

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