{"rsdb":{"rid":"155945","subhead":"","postdate":"0","aid":"117062","fid":"57","uid":"1","topic":"1","content":"

\u4e00\u3001MongoDB\u65e5\u5fd7\u6e05\u7406\u6b65\u9aa4<\/p>

1.\u4f7f\u7528\u6570\u636e\u5e93<\/a>\u547d\u4ee4rotate\u65e5\u5fd7,\u5206\u522b\u767b\u9646\u5230mongod\u548cmongos\u5b9e\u4f8b\u4e0a<\/p>

# mongo --host localhost:27xxx
MongoDB shell version: 2.6.x
connecting to: localhost:27xxx\/test
replicaset003:SECONDARY> db
test
replicaset003:SECONDARY> use admin
switched to db admin
replicaset003:SECONDARY> db.runCommand({logRotate:1})
{ \"ok\" : 1 }
replicaset003:SECONDARY>
replicaset001:ARBITER> exit
bye
# ll
total 22195424
-rw-r--r-- 1 mongod mongod 1124 Dec 20 11:04 mongoc.log
-rw-r--r-- 1 mongod mongod 33341517 Dec 20 10:59 mongoc.log.2016-12-20T03-01-17
-rw-r--r-- 1 mongod mongod 4944 Dec 20 11:07 mongod1.log
-rw-r--r-- 1 mongod mongod 680817815 Dec 20 11:03 mongod1.log.2016-12-20T03-04-01
-rw-r--r-- 1 mongod mongod 1030 Dec 20 11:07 mongod2.log
-rw-r--r-- 1 mongod mongod 1813798574 Dec 20 11:07 mongod2.log.2016-12-20T03-07-43
-rw-r--r-- 1 mongod mongod 2413 Dec 20 11:07 mongod.log
-rw-r--r-- 1 mongod mongod 1880520643 Dec 20 11:06 mongod.log.2016-12-20T03-06-17
-rw-r--r-- 1 mongod mongod 2071 Dec 20 11:05 mongos.log
-rw-r--r-- 1 mongod mongod 18319577575 Dec 20 10:52 mongos.log.2016-12-20T02-53-04<\/p>

2.\u4f7f\u7528\u7cfb\u7edf\u547d\u4ee4\u6e05\u7a7a\u65e5\u5fd7\u6587\u4ef6\uff0c\u4fdd\u7559\u65e5\u5fd7<\/p>

# cat \/dev\/null > mongos.log.2016-12-20T02-53-04
# cat \/dev\/null > mongod.log.2016-12-20T03-06-17
# cat \/dev\/null > mongod2.log.2016-12-20T03-07-43
# cat \/dev\/null > mongod1.log.2016-12-20T03-04-01
# cat \/dev\/null > mongoc.log.2016-12-20T03-01-17
#
[root@dev-mongo-001-242 mongo]# ll
total 28
-rw-r--r-- 1 mongod mongod 1338 Dec 20 11:09 mongoc.log
-rw-r--r-- 1 mongod mongod 0 Dec 20 11:10 mongoc.log.2016-12-20T03-01-17
-rw-r--r-- 1 mongod mongod 7670 Dec 20 11:10 mongod1.log
-rw-r--r-- 1 mongod mongod 0 Dec 20 11:10 mongod1.log.2016-12-20T03-04-01
-rw-r--r-- 1 mongod mongod 3594 Dec 20 11:10 mongod2.log
-rw-r--r-- 1 mongod mongod 0 Dec 20 11:10 mongod2.log.2016-12-20T03-07-43
-rw-r--r-- 1 mongod mongod 5247 Dec 20 11:10 mongod.log
-rw-r--r-- 1 mongod mongod 0 Dec 20 11:09 mongod.log.2016-12-20T03-06-17
-rw-r--r-- 1 mongod mongod 2297 Dec 20 11:10 mongos.log
-rw-r--r-- 1 mongod mongod 0 Dec 20 11:09 mongos.log.2016-12-20T02-53-04<\/p>

\u4e8c\u3001\u601d\u8def<\/p>

1.\u4e00\u822c\u60c5\u51b5\u4e0b\u6570\u636e\u5e93<\/a>\u7684\u65e5\u5fd7\u7406\u6e05\u90fd\u4f1a\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u4e00\u79cd\u662f\u901a\u8fc7\u6570\u636e\u5e93\u547d\u4ee4\uff0c\u4e00\u79cd\u662f\u7cfb\u7edf\u547d\u4ee4\u3002<\/p>

2.\u65e5\u5fd7\u7684\u6e05\u7406\u539f\u6587\u4ef6\u4e00\u5b9a\u8981\u4fdd\u7559\uff0c\u4e0d\u80fd\u4f7f\u7528rm\u6765\u5220\u9664\u6587\u4ef6\uff0c\u5207\u5fcc\uff0c\u6211\u4eec\u76ee\u7684\u662f\u91ca\u653e\u7a7a\u95f4\u3002<\/p>

3.\u90e8\u5206\u516c\u53f8\u8981\u6c42\u628a\u65e5\u5fd7\u5f52\u6863\u5230\u5927\u6570\u636e\u5e73\u53f0\u4ee5\u4f9b\u5206\u6790\u4f7f\u7528\uff0c\u56e0\u6b64\uff0c\u5728\u6e05\u7406\u65e5\u5fd7\u6587\u4ef6\u7684\u65f6\u5019\u9700\u8981\u641e\u6e05\u695a\uff0c\u5207\u52ff\u76f2\u76ee\u86ee\u5e72\u3002<\/p>

\u4e09\u3001\u5b98\u65b9\u6587\u6863<\/p>

1 https:\/\/docs.mongodb.com\/v2.6\/tutorial\/rotate-log-files\/<\/a><\/p>

\u82f1\u8bed\u5b66\u597d\u7684\u540c\u5b66\uff0c\u505adba\u662f\u975e\u5e38\u5bb9\u6613\u7684\u4e8b\u60c5,\u6240\u4ee5\u5927\u5bb6\u8981\u52aa\u529b\u5b66\u597d\u82f1\u8bed\uff01<\/p>

\u66f4\u591aMongoDB<\/span>\u76f8\u5173\u6559\u7a0b\u89c1\u4ee5\u4e0b\u5185\u5bb9<\/strong><\/span>\uff1a<\/p>

<\/p>","orderid":"0","title":"MongoDB 2.6.x \u6e05\u7406\u8fc7\u5927\u65e5\u5fd7\u6587\u4ef6\u7684\u65b9\u6cd5","smalltitle":"","mid":"0","fname":"\u6570\u636e\u5e93\u7f16\u7a0b","special_id":"0","bak_id":"0","info":"0","hits":"46","pages":"1","comments":"0","posttime":"2017-01-02 08:14:57","list":"1483316097","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"http:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"MongoDB<\/A> 2.6.x<\/A> \u6e05\u7406<\/A> \u65e5\u5fd7<\/A> \u6587\u4ef6<\/A> \u65b9\u6cd5<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.31","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"MongoDB 2.6.x \u6e05\u7406\u8fc7\u5927\u65e5\u5fd7\u6587\u4ef6\u7684\u65b9\u6cd5","lastview":"1493025636","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}