zoukankan      html  css  js  c++  java
  • mongo备份恢复

    1.mongoexport 与mongoimport 

    export

    mongoexport --host "localhost:27017" --username="user" --password="xxxx" --authenticationDatabase=testdb --db=testdb --collection=testc --out /back/testc.josn

    import

    mongoimport --host "localhost:27017" --username="user" --password="xxxx" --authenticationDatabase=testdb --db=testdb_v3 --collection=testc --file /back/testc.josn

    2.mongodump与mongostore

    mongodump -h "localhost:port" --username="user" --password="pwd" --authenticationDatabase=authdb -d dbname -o /root/back

    restory
    mongorestore -h "localhost:port" --username="user" --password="pwd" --authenticationDatabase=authdb -d dbname --dir /root/back/fission_balance/

    3.hot backup   -- Percona Server for MongoDB支持,社区版本不支持

    Percona Server for MongoDB includes an integrated open-source hot backup system for the default WiredTiger and
    alternative MongoRocks storage engine. It creates a physical data backup on a running server without notable performance
    and operating degradation.
    To take a hot backup of the database in your current dbpath, run the createBackup command as administrator
    on the admin database and specify the backup directory.

    1 > use admin
    2 switched to db admin
    3 > db.runCommand({createBackup: 1, backupDir: "/my/backup/data/path"})
    4 { "ok" : 1 }
    View Code

    If the backup was successful, you should receive an { "ok" : 1 } object. If there was an error, you will receive
    a failing ok status with the error message, for example:

    1 > db.runCommand({createBackup: 1, backupDir: ""})
    2 { "ok" : 0, "errmsg" : "Destination path must be absolute" }
    View Code

    备份恢复相关参考博客

    MongoDB在线热备神器-createBackup

    从炉石传说数据库故障谈谈MongoDB的数据库备份和恢复手段

    Mongodump的archive(归档)模式原理解析

  • 相关阅读:
    继承与钻石继承
    面向对象----对象的组合和
    认知类和对象的关系
    初识面向对象----类和对象的关系
    其他题目
    三级菜单
    用户登陆
    购物车题目
    函数练习题目
    类加载的过程
  • 原文地址:https://www.cnblogs.com/geek-ace/p/7692999.html
Copyright © 2011-2022 走看看