How to view mongodb data from .ns files

I just explored a mongod. When I store data using mongo. It will save this data in a * .ns file.

So, how can I see the data stored in the .NS file?

When I tried to open this file in notepad ++, it shows a lot of NULL.

Is there any other way to check the data stored in mobgodb.?

+4
source share
1 answer

I believe that the data itself is not stored in NS files, but in files with the extension .0 , .1 , etc. with the same name. These files are not intended for reading by text editors.

Probably the easiest way is to start the mongod process by specifying the folder in which you have the files ( mongod --dbpath /path/to/your/files/ ). Then you can simply use the mongo shell to examine the contents.

You get some fragments of data files, but mostly it is unreadable with a regular text editor.

dbname.0 is a pre-allocated initial data file that starts with 64 MB

dbname.ns is intended for accounting purposes. ns stands for namespace. The default limit for a 16 megabyte .ns file supports 24,000 namespaces (collections + indexes) (see the -nssize option)

when MongoDB grows beyond the size of the last dbname.x file, it allocates a new data file with doubled size up to 2 GB. Once the file size reaches 2 GB, each subsequent file is also 2 GB.

+8
source

Source: https://habr.com/ru/post/1379651/


All Articles