search

Home  >  Q&A  >  body text

mongodb - 使用mongodump如何备份远端数据?

mongodump -u mongodbuser -p xx -d db -h 远端IP地址 --port 27017 -o xx
command如上,备份远端数据库,错误提示为Failed: error connecting to db server: no reachable servers
将-h 改为本地ip就是正确的,那么备份远端mongodb数据要怎么办??

怪我咯怪我咯2816 days ago692

reply all(2)I'll reply

  • 阿神

    阿神2017-04-26 09:03:19

    mongodump -h x.x.x.x --port xxx -u xxx --password xxx

    ./mongodump --help

    options:
    --help Display help information
    -v [ --verbose ] Print out more information, such as time, etc. -vvvvv
    --version print version information
    -h [ --host ] arg specifies the connected mongodb host. When setting the replica set, set it to /s1, s2
    --port arg specifies the mongodb port number, you can also specify --host hostname:port
    --ipv6 Enable IPv6 support
    -u [ --username ] arg username
    -p [ --password ] arg password
    --authenticationDatabase arg user source (defaults to dbname)
    --authenticationMechanism arg (=MONGODB-CR)
    authentication mechanism
    --dbpath arg directly accesses the mongod database file instead of connecting to the mongodb server. The data directory needs to be locked. If mongod is currently accessing the same path, it cannot be used. In other words, you cannot use --dbpath when mongod is running. You can directly specify --dbpath when mongod is not running
    --directoryperdb A separate directory for each db, you need to specify the dbpath
    --journal enables journaling, you need to specify dbpath
    -d [ --db ] arg specifies database
    -c [ --collection ] arg specifies collection
    -o [ --out ] arg (=dump) specifies the output directory, "-" indicates standard output
    -q [ --query ] arg json query
    --oplog Use oplog to produce point-in-time snapshots
    --repair Try to recover a crashed database
    --forceTableScan Force table scan, do not use $snapshot

    reply
    0
  • PHP中文网

    PHP中文网2017-04-26 09:03:19

    Make sure your mongo instance is not just listening to the local network:
    grep bind /etc/mongod.conf
    bind_ip=0.0.0.0

    Remote backup method is the same as local backup
    mongodump --host xx --port xx --quiet --username xx --password xx -o /data/mongotmp

    reply
    0
  • Cancelreply