mongodb 配置&备份

原创
2020/06/24 10:07
阅读数 322
mongod -f //home/wyd/MongoDB/conf/mongod.conf -v --dbpath /home/wyd/MongoDB/shard-a-primary --logpath /home/wyd/MongoDB/log/shard-a-primary.log --pidfilepath /home/wyd/MongoDB/pid/shard-a-primary.pid --port 27017
=============================================
cat /home/wyd/MongoDB/conf/mongod.conf 
systemLog:
  destination: file
  logAppend: true
storage:
  journal:
    enabled: true
  directoryPerDB: true
  engine: wiredTiger
  wiredTiger:
    engineConfig:
      cacheSizeGB: 30
      directoryForIndexes: true
    indexConfig:
      prefixCompression: true
processManagement:
  fork: true
net:
  port : 27017
  bindIp : 0.0.0.0
=========================================
 
导出数据:${mdbdir}/mongodump -u ${user} -p ${pass} --host ${ip} --port ${hostport} --authenticationDatabase=admin --oplog  --out ${bakdir}/$1_${nowtime}
-d dbname
--forceTableScan 

mongodump默认使用snapshot,会通过扫描_id 索引,然后去读取实际的文档。TableScan会按照mongodb的物理存储顺序进行扫描,没有读取index的过程。但是tablescan潜在的问题是,如果一个文档在dump的过程中移动了(物理上),有可能会最终输出两次。

 
#恢复:/data/mongodb/mongos/bin/mongorestore -u ## -p ## --host ## --port ## --authenticationDatabase=admin --drop --oplogReplay --dir=/##/#/full
-d dbname
db.createUser( {user: "myUserAdmin",    pwd: "abc123",    roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]  })
展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部