美文网首页
Mongodb-备份(mongodump)与恢复(mongore

Mongodb-备份(mongodump)与恢复(mongore

作者: 黑客不黑撒 | 来源:发表于2018-08-16 09:22 被阅读0次

    [root@localhost ~]# docker exec -it mytest /bin/bash

    [root@1c178edd6a92 /]# cd /home/Java/mongodb

    [root@1c178edd6a92 mongodb]# bin/mongo --port 17016

    > use cloudcc

    switched to db cloudcc

    > db.test.insert({"username":"hacker", "age":26})

    WriteResult({ "nInserted" : 1 })

    > exit

    bye

    [root@1c178edd6a92 mongodb]# clear

    [root@1c178edd6a92 mongodb]# bin/mongodump -h 172.17.0.5:17016 -d cloudcc -o /home/Java

    2017-07-19T09:32:06.571+0000    writing cloudcc.test to

    2017-07-19T09:32:06.573+0000    done dumping cloudcc.test (1 document)

    [root@1c178edd6a92 mongodb]# ls /home/Java/

    cloudcc  mongodb  mongodb-linux-x86_64-rhel70-3.4.5.tgz

    [root@1c178edd6a92 mongodb]# ls /home/Java/cloudcc/

    test.bson  test.metadata.json

    [root@1c178edd6a92 mongodb]#

    [root@1c178edd6a92 mongodb]# bin/mongo --port 17016

    > use cloudcc

    switched to db cloudcc

    > db.dropDatabase()

    { "dropped" : "cloudcc", "ok" : 1 }

    > exit

    bye

    [root@1c178edd6a92 mongodb]# bin/mongorestore -h 172.17.0.5:17016 -d cloudcc /home/Java/cloudcc/

    相关文章

      网友评论

          本文标题:Mongodb-备份(mongodump)与恢复(mongore

          本文链接:https://www.haomeiwen.com/subject/gqknbftx.html