清理MongoDB集群数据:
1、登录MongoDB集群(mongos):
# mongo -u username -p password --authenticationDatabase admin 127.0.0.1:27017/admin
2、查询2018-01-31之前的数据(mongos):
mongos> db.tcache.find({"ft":{"$lt":new Date("2018-01-31T00:00:00.000Z")}}).count()
# mongo-u username -p password --authenticationDatabase admin 127.0.0.1:27017/yqtrack_gather01 --eval 'db.tcache.find({"ft":{"$lt":new Date("2018-01-31T00:00:00.000Z")}}).count()'
3、删除2018-01-31之前的数据(mongos):
mongos> db.tcache.deleteMany({"ft":{"$lt":new Date("2018-01-31T00:00:00.000Z")}})
# mongo -u username -p password --authenticationDatabase admin 127.0.0.1:27017/yqtrack_gather01 --eval 'db.tcache.deleteMany({"ft":{"$lt":new Date("2018-01-31T00:00:00.000Z")}})'
--------------------------------