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)06/01 Report--
I. preparatory work
1. Download and install the wt utility kit
Wget http://source.wiredtiger.com/releases/wiredtiger-2.9.1.tar.bz2
Tar xvf wiredtiger-2.9.1.tar.bz2 & & cd wiredtiger-2.9.1
Yum install snappy snappy-devel-y
. / configure-- enable-snappy
Make
Note: it is best to download the wt toolset that corresponds to the version of wiredtiger used in mongoDB. It can be obtained in the following ways
The wiredtiger version used by the current mongoDB, which is executed under the current MongoDB data directory:
two。 Prepare the data to be recovered
For example, if we want to recover the data of the collection-101--2183197387550357866.wt file in the metrics_db database
Create a new directory under the wireditger-2.9.1 directory to store the data to be recovered. Here, 20171024 is created. Note here:
The storage directory of the data file to be recovered must be the same as the structure of the original mongoDB data directory, otherwise a file not found error will occur.
In addition, some other original data files are required in addition to the data files to be recovered, as listed below
WiredTiger
WiredTiger.lock
WiredTiger.turtle
WiredTiger.wt
WiredTigerLAS.wt
_ mdb_catalog.wt
SizeStorer.wt
These files are all stored in the same directory structure as the original MongoDB data directory structure.
Second, restore data
1. Check how much data can be recovered
[root@sdw2 wiredtiger-2.9.1] #. / wt-v-h. / 20171024 /-C "extensions= [. / ext/compressors/snappy/.libs/libwiredtiger_snappy.so]"-R salvage metrics_db/collection-101--2183197387550357866.wt
You should pay attention to the relationship between the parameters here and the execution path of the command. After executing this command, you will output the following result.
WT_SESSION.salvage 100
The number in the background is the data that can be recovered.
two。 Use the wt tool to dump the data that can be recovered
[root@sdw2 wiredtiger-2.9.1] #. / wt-v-h. / 20171024 /-C "extensions= [. / ext/compressors/snappy/.libs/libwiredtiger_snappy.so]"-R dump-f collection.dump metrics_db/collection-101--2183197387550357866
Here the-f parameter specifies the output file of the dump data. Also note that in this step we do not need to specify the extension of the data file to be restored, that is, we omit the. wt three characters
3. Prepare a mongoDB instance to be used by users to recover data
Mongod-dbpath / data/mongo_data-storageEngine wiredTiger
4. Connect to this new instance and set up a user recovery database
[root@sdw2] mongo 127.0.0.1:27017
> use recovery
> db.t.insert ({id:1})
> db.t.remove ({}) # create a table, insert a piece of data and delete it. We mainly need to generate a wt file on the recovery directory.
> db.t.status () # View the wt file generated by the operation just now
Record the file name and directory, and then we will use the wt command to regenerate the file from the dump file and recover the data to be recovered. Now we need to stop this mongoDB instance, otherwise there will be an error when restoring the data below.
5. Load data to wt file
[root@sdw2 wiredtiger-2.9.1] #. / wt-v-h / data/mongo_data/-C "extensions= [. / ext/compressors/snappy/.libs/libwiredtiger_snappy.so]"-R load-f collection.dump-r recovery/collection-0--4285167332299985373
Table:recovery/collection-5-1786621982084020644: 11305
Note:
The-h parameter specifies the data directory that we specified when we just started mongoDB.
The-r parameter specifies the WT file we just generated for recovery.
6. Restart the mongoDB instance
Mongod-dbpath / data/mongo_data-storageEngine wiredTiger
7. Backing up data using mongodump
Because we have replaced the wt file, there is still some inconsistency in the original data, so we can't see the data we recovered in mongo. At this time, we have to use the mongodump and mongorestore commands to re-export and import the data, so that we can really restore the data.
Mongodump-h 127.0.0.1 27017Murd recovery
8 use mongorestore to restore data
Mongorestore-h227.0.0.1:27017--drop dump/
MySQL course recommendation
MySQL performance Management and Architecture Design
High performance Extensible MySQL Database Design and Architecture Optimization of E-commerce Project
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.