Tags: Environment technology share double quotes source file production environment Export data production special classRecently developed a version of the functionality of the use of MongoDB paging, lazy to build data, and then studied the next from the production environment to export data to the local test. Study a bit, found that MongoDB backup restore and My
Backup of the data is very much in the two ways, of course, you can also take advantage of the snapshot:---------------------------------------------------------------------One, direct copy data file Mode backup restore----------------------------------------------------------------------Note: When calling the Db.fsyncunlock () and Db.fsynclock () commands, do not close the shell, because if you enable auth
When dealing with databases, it is inevitable that data backup and recovery will occur. The following are the instructions used. I will leave them here for the time being.
Data backup:
E: \ mongodb-win32-x86_64-2.2.1 \ bin> export dump.exe -- db CpsCommodityInfo E: \ tables 20130329
Data Recovery:
E: \ mongodb-wi
This batch code is used to automatically back up the MongoDB database on a Windows server, and a backup folder is automatically created for each backup
1. To prepare a bat file, which reads as follows:
Copy Code code as follows:
@ECHO off
MD d:\deployment\mongodb\data\
Tags: backup Use bin tab database dump head post showEnvironmental win10; Run the CMD CD into the directory MongoDB Bin directory: To connect to a remote MongoDB: Connection command: Mongo-u username-p pwd host:post/database (database name) When the user has the appropriate permissions, you can view the Collection==> View Collection command: Show collections Expo
--oplog-o/mnt/mongo/mongodata-u xucy–p passw0rd--authenticationDatabase admin GT Mongodump.log 2>1 You can observe the progress of the backup by viewing the log data in real time.Tail–f Mongodump.logStep three: Recover the database on a new instanceMongorestore to run if Mongod is not started, it writes directly to the file.Mongorestore--host=192.168.11.2:27017--oplogreplay--dbpath/data/var/lib/mongodb--dir
Tags: using strong file Data SP on C R databaseMongoDB database is also inseparable from the necessary maintenance, such as backup, recovery, import, export.In fact, backup and recovery is easier than import and export, and generally does not make mistakes, so most of the time using backup and recovery operations.1. Back Up MongoDBMongodump-h ruiyip-d Dataname-o/
Tags: mon instance dump--database God images ack span1.mongodb BackupThe Mongodump command can use a list of available options.This command backs up only the specified database, in the specified path
Grammar
Description
Example
Mongodump--host host_name--port port_number
This command will specify the Mongod instance to back up all the databases.
Mongodump--host yiibai.com--port 27017
M
Label:First introduce the following command syntax: ./mongodump-h 127.0.0.1:10001-d Lietou-o/usr/local/data -H:MONGDB the server address, for example: 127.0.0.1, you can also specify the port number: 127.0.0.1:10001 -D: The database instance that needs to be backed up, for example: Lietou -O: The data storage location of the backup, for example:/usr/local/data, after the backup is completed, the system aut
Label:MongoDB data backup and restore is mainly divided into two kinds, one is for the library of Mongodump and Mongorestore, one is for the table in the library mongoexport and Mongoimport. One, Mongodump backup database 1, Common command grid Mongodump-h IP--port Port-u user name-p password-d database-o file exists path If there are no users, you can remove-u and-P.If you export the native database, you c
Tags: res export database bat. exe start mongodump data exe Store1. Export Database/backup: @echo off
F:
cd F:\software1\mongdb\mongodb-win32-x86_64-3.0. 0 \
Bin 127.0. 0.1:27017 -D db-o F:\software1\mongdb Do not explain, modify the path information can be used directly; 2. Restore the backed up database: @echo off
F:
cd F:\software1\mongdb\mongodb-win32-x86_64-
Problem description: in a production environment, when the read Pressure on secondary replica members is high, you can add new secondary replica members to relieve the pressure. In order to ensure that the primary replica members do not stop and reduce the pressure on the primary replica members, mongodump backup data on the secondary replica members. In order to achieve rapid recovery of new secondary replica members, you can directly use NFS
Problem
at the same time as the export, storing all the oplog between the dump and dump end you startIn replica set, Oplog is a set of capped collection, the default size of which is 5% of the disk space (which can be modified by the--OPLOGSIZEMB parameter), which is located in the db.oplog.rs of the local library.It records all changes (insert/update/DELETE) operations of the database over time for the entire Mongod instance. Automatically overwrites oldest records when space runs out of timeIts cover
user--type csv--headerline--fileUser_csv.datConnected to:127.0.0.1Imported 3 objects[Email protected] bin]#Parameter description:-type indicates the file format to import-headerline The first row is not imported because the first row is a column name-file indicates the file path to importAttention:CSV format is good, mainstream database support export to CSV format, so this format is very beneficial to heterogeneous data migrationData backup Mongodum
Tags: mongodb backup recoveryBackup-d Specifies the database to be backed up,-o Specifies the backup location,bin>mongodump-d test-o Backup//(backup is the back up directory, created to the bin directory by default)Recovery-d Specifies the database to revert to, which restor
--fileUser_csv.datConnected to:127.0.0.1Imported 3 objects[Email protected] bin]#Parameter description:-type indicates the file format to import-headerline The first row is not imported because the first row is a column name-file indicates the file path to importAttention:CSV format is good, mainstream database support export to CSV format, so this format is very beneficial to heterogeneous data migration Data Backup Mongodump You can use Mongodump
Label:MongoDB Syntax MongoDB benefits Quite a lot, such as multi-column index, query can use some statistical functions, support multi-conditional query, but the current multi-table query is not supported, you can find a way to solve the problem of multi-table query through data redundancy. Query Colls all data Db.colls.find ()//select * from Colls Querying by specifying criteria Db.colls.find ({' last_name ': ' Smith '}),//select * from Colls whe
Due to the data structure of MongoDB, data storage space is much occupied compared with traditional relational databases.
The hard disk space utilization is not negligible for storing infrequently used backup data.
Take MYSQL as an example. Remember to check others' test results on the Internet. For the same data, MongoDB occupies 500 m + and MySQL InnoDB occup
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.