网站建设资讯

NEWS

网站建设资讯

DBA应用技巧中如何利用MySQL技能学习MongoDB

DBA应用技巧中如何利用MySQL技能学习MongoDB,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

在安阳县等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、成都网站建设 网站设计制作按需制作网站,公司网站建设,企业网站建设,高端网站设计,营销型网站建设,外贸网站制作,安阳县网站建设费用合理。

(1)、mongorestore恢复工具  我们先看一下此工具的帮助信息:

双击代码全选
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24[root@localhost bin]# ./mongorestore --helpusage: ./mongorestore [options] [directory or filename to restore from]options:   --help                  produce help message   -v [ --verbose ]        be more verbose (include multiple times for more                           verbosity e.g. -vvvvv)   -h [ --host ] arg       mongo host to connect to ( /s1,s2 for sets)   --port arg              server port. Can also use --host hostname:port   --ipv6                  enable IPv6 support (disabled by default)   -u [ --username ] arg   username   -p [ --password ] arg   password   --dbpath arg            directly access mongod database files in the given                           path, instead of connecting to a mongod  server -                           needs to lock the data directory, so cannot be used                           if a mongod is currently accessing the same path   --directoryperdb        if dbpath specified, each db is in a separate                           directory   -d [ --db ] arg         database to use   -c [ --collection ] arg collection to use (some commands)   --objcheck              validate object before inserting   --filter arg            filter to apply before inserting   --drop                  drop each collection before import   --oplogReplay           replay oplog for point-in-time restore[root@localhost bin]#

例如我们先将”foo”库删除了:

双击代码全选
1 2 3 4 5 6 7 8 9 10 11 12[root@localhost bin]# ./mongoMongoDB shell version: 1.8.1connecting to: test> use fooswitched to db foo> db.dropDatabase();{ "dropped" : "foo", "ok" : 1 }> show dbsadmin   0.0625GBlocal   (empty)test    0.0625GB>

然后下面我们将演示如何恢复这个库:

双击代码全选
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18[root@localhost bin]# ./mongorestore --directoryperdb /data/dumpconnected to: 127.0.0.1Sun Apr 22 12:01:27 /data/dump/foo/t1.bsonSun Apr 22 12:01:27      going into namespace [foo.t1]Sun Apr 22 12:01:27      2 objects foundSun Apr 22 12:01:27 /data/dump/foo/t2.bsonSun Apr 22 12:01:27      going into namespace [foo.t2]Sun Apr 22 12:01:27      1 objects foundSun Apr 22 12:01:27 /data/dump/foo/system.users.bsonSun Apr 22 12:01:27      going into namespace [foo.system.users]Sun Apr 22 12:01:27      1 objects foundSun Apr 22 12:01:27 /data/dump/foo/system.indexes.bsonSun Apr 22 12:01:27      going into namespace [foo.system.indexes]Sun Apr 22 12:01:27 { name: "_id_", ns: "foo.system.users", key: { _id: 1 }, v: 0 }Sun Apr 22 12:01:27 { name: "_id_", ns: "foo.t2", key: { _id: 1 }, v: 0 }Sun Apr 22 12:01:27 { name: "_id_", ns: "foo.t1", key: { _id: 1 }, v: 0 }Sun Apr 22 12:01:27      3 objects found[root@localhost bin]#

通过工具返回信息,我们可以看到foo中的数据已经被恢复回来了, 接下来我们到库里去验证一下:

双击代码全选
1 2 3 4 5 6 7 8 9 10 11[root@localhost bin]# ./mongoMongoDB shell version: 1.8.1connecting to: test> use fooswitched to db foo> show collections;system.indexessystem.userst1t2>

结果证明foo库表已经被成功恢复回来了。

关于DBA应用技巧中如何利用MySQL技能学习MongoDB问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。


文章题目:DBA应用技巧中如何利用MySQL技能学习MongoDB
本文地址:http://njwzjz.com/article/gpgpsi.html