In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
DBA application skills in how to use MySQL skills to learn MongoDB, in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
(1) mongorestore recovery tool Let's first take a look at the help information of this tool:
Double-click the code 12 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 Magazine 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] #
For example, we first delete the "foo" library:
Double click the code 12 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 >
Then we will show you how to restore this library:
Double click code 12 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] #
Through the information returned by the tool, we can see that the data in foo has been restored. Next, let's go to the library to verify it:
Double click the code to select all 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 >
It turns out that the foo database table has been successfully restored.
The answer to the question about how to use MySQL skills to learn MongoDB in DBA application skills is shared here. I hope the above content can be of some help to everyone. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.