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

    --------------------------备份--------------------------------------

    1.备份语句
    /usr/local/services/mongodb/bin/mongodump -h 172.17.70.190:28001 -u root -p 123456 --authenticationDatabase mgdb_livex --db=mgdb_livex -c ${table_name} -o /home/hxl/mongo_exportdata/${table_name}_${dump_date}

     

    --------------------------恢复--------------------------------------

    1.备份文件上传到服务器/tmp目录,然后进行解压
    [root@localhost tmp]# tar -xvf test1.tar.gz
    [root@localhost tmp]# tar -xvf test2.tar.gz

    解压后会生成目录
    [root@localhost tmp]# ls -1
    test1
    test2

    目录下是库名目录,库名下面是具体的数据文件
    [root@localhost mgdb_livex]# pwd
    /tmp/test1/mgdb_livex
    [root@localhost mgdb_livex]# ls -l
    total 17360
    -rw-r--r-- 1 test test 17768550 Sep 7 02:10 test1.bson
    -rw-r--r-- 1 test test 536 Sep 7 02:10 test1.metadata.json

    将数据恢复到另外的库:dbtest
    /usr/local/services/mongodb/bin/mongorestore --host 127.0.0.1 --port 28001 -u root -p 123456 --authenticationDatabase admin -d dbtest /tmp/t_chartroom_msg_20210907/mgdb_livex
    /usr/local/services/mongodb/bin/mongorestore --host 127.0.0.1 --port 28001 -u root -p 123456 --authenticationDatabase admin -d dbtest /tmp/t_chartroom_msg_client_20210907/mgdb_livex

  • 相关阅读:
    JAVA中int、String的类型转换
    MyEclipse 快捷键
    HTTP 协议详解(转)
    HTTP协议详解
    MYSQL类型与JAVA类型对应表
    XML中<beans>中属性概述
    poj 2342 && hdu 1520
    51nod 1873 初中的算术
    AtCoder Grand Contest 014 B
    “玲珑杯”线上赛 Round #17 河南专场 B.震惊,99%+的中国人都会算错的问题
  • 原文地址:https://www.cnblogs.com/hxlasky/p/15238176.html
Copyright © 2011-2022 走看看