oplog
参考资料:https://www.cnblogs.com/ruizhang3/p/6539730.html
http://www.jb51.net/article/113432.htm
:
insert
Raw data {u'h': 0L, u'ts': Timestamp(1519780847, 1),
u'o': {u'eeeeeeeeee': u'2222222222222',
u'_id': ObjectId('5a9603eff419d56c6fc1afa0')},
u'v': 2, u'ns': u'python.wwjj', u'op': u'i'}
delete
Raw data {u'h': 0L, u'ts': Timestamp(1519782979, 1),
u'o': {u'_id': ObjectId('5a9603eff419d56c6fc1afa0')},
u'v': 2, u'ns': u'python.wwjj', u'op': u'd'}
:
> db.wwjj.insert({"eeeeeeeeee":'2222222222222'})
WriteResult({ "nInserted" : 1 })
> db.wwjj.remove({"eeeeeeeeee":'2222222222222'},{justOne:true})
WriteResult({ "nRemoved" : 1 })
:
> db.wwjj.update({"a":10},{$set:{"a":666666}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
:
update
Raw data {u'h': 0L, u'ts': Timestamp(1519784147, 1), u'o': {u'$set': {u'a': 666666.0}}, u'v': 2, u'ns': u'python.wwjj', u'o2': {u'_id': ObjectId('5a957a87f419d56c6fc1af9d')}, u'op': u'u'}
================================
mongo admin -u admin -p uqPfHx6sXsyF
show dbs
use local
show tables
==================每行中的_id==========
http://blog.csdn.net/Yelbosh/article/details/45953413
_id 为ObjectId类型,obj_id是一个对象,不是一个str,使用str类型作为_id的值无法找到记录,可以通过ObjectId方法把str转成ObjectId类型
from bson.objectid
import
ObjectId
from bson.objectid import ObjectId
print "_id 转换成ObjectId类型"
print coll.find_one({"_id": ObjectId(str(obj_id))})
========= 将mongod数据库的日志写入文件:--logpath /var/log/mongodb/aa.txt
如mongod --auth --replSet rs0 --wiredTigerCacheSizeGB 2.0 --logpath /var/log/mongodb/yy