- MongoDB Administrator’s Guide
- Cyrus Dasadia
- 457字
- 2021-07-02 15:47:45
How to do it...
- Start mongod daemon with no special parameters:
/data/mongodb/bin/mongod --dbpath /data/db
- Connect to mongo shell, create a test db and insert a sample document:
mongo localhost:27017
> use mydb
> db.mycol.insert({foo:1})
- Inspect the /data/db directory structure, it should look something like this:
ls /data/db
total 244
drwxr-xr-x 4 root root 4096 May 21 08:45 .
drwxr-xr-x 10 root root 4096 May 21 08:42 ..
-rw-r--r-- 1 root root 16384 May 21 08:43 collection-0-626293768203557661.wt
-rw-r--r-- 1 root root 16384 May 21 08:43 collection-2-626293768203557661.wt
-rw-r--r-- 1 root root 16384 May 21 08:43 collection-5-626293768203557661.wt
drwxr-xr-x 2 root root 4096 May 21 08:45 diagnostic.data
-rw-r--r-- 1 root root 16384 May 21 08:43 index-1-626293768203557661.wt
-rw-r--r-- 1 root root 16384 May 21 08:43 index-3-626293768203557661.wt
-rw-r--r-- 1 root root 16384 May 21 08:43 index-4-626293768203557661.wt
-rw-r--r-- 1 root root 16384 May 21 08:43 index-6-626293768203557661.wt
drwxr-xr-x 2 root root 4096 May 21 08:42 journal
-rw-r--r-- 1 root root 16384 May 21 08:43 _mdb_catalog.wt
-rw-r--r-- 1 root root 6 May 21 08:42 mongod.lock
-rw-r--r-- 1 root root 16384 May 21 08:44 sizeStorer.wt
-rw-r--r-- 1 root root 95 May 21 08:42 storage.bson
-rw-r--r-- 1 root root 49 May 21 08:42 WiredTiger
-rw-r--r-- 1 root root 4096 May 21 08:42 WiredTigerLAS.wt
-rw-r--r-- 1 root root 21 May 21 08:42 WiredTiger.lock
-rw-r--r-- 1 root root 994 May 21 08:45 WiredTiger.turtle
-rw-r--r-- 1 root root 61440 May 21 08:45 WiredTiger.wt
- Shutdown the previous mongod instance.
- Create a new db path and start mongod with --directoryperdb option:
mkdir /data/newdb
/data/mongodb/bin/mongod --dbpath /data/newdb --directoryperdb
- Connect to the mongo shell, create a test db, and insert a sample document:
mongo localhost:27017
> use mydb
> db.mycol.insert({bar:1})
- Inspect the /data/newdb directory structure, it should look something like this:
ls /data/newdb
total 108
drwxr-xr-x 7 root root 4096 May 21 08:42 .
drwxr-xr-x 10 root root 4096 May 21 08:42 ..
drwxr-xr-x 2 root root 4096 May 21 08:41 admin
drwxr-xr-x 2 root root 4096 May 21 08:42 diagnostic.data
drwxr-xr-x 2 root root 4096 May 21 08:41 journal
drwxr-xr-x 2 root root 4096 May 21 08:41 local
-rw-r--r-- 1 root root 16384 May 21 08:42 _mdb_catalog.wt
-rw-r--r-- 1 root root 0 May 21 08:42 mongod.lock
drwxr-xr-x 2 root root 4096 May 21 08:41 mydb
-rw-r--r-- 1 root root 16384 May 21 08:42 sizeStorer.wt
-rw-r--r-- 1 root root 95 May 21 08:41 storage.bson
-rw-r--r-- 1 root root 49 May 21 08:41 WiredTiger
-rw-r--r-- 1 root root 4096 May 21 08:42 WiredTigerLAS.wt
-rw-r--r-- 1 root root 21 May 21 08:41 WiredTiger.lock
-rw-r--r-- 1 root root 986 May 21 08:42 WiredTiger.turtle
-rw-r--r-- 1 root root 28672 May 21 08:42 WiredTiger.wt
推薦閱讀
- The Complete Rust Programming Reference Guide
- Learning PostgreSQL
- JavaScript+jQuery開(kāi)發(fā)實(shí)戰(zhàn)
- 青少年美育趣味課堂:XMind思維導(dǎo)圖制作
- Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API
- Visual C
- Visual Basic程序設(shè)計(jì)實(shí)踐教程
- Mastering Xamarin.Forms(Second Edition)
- Learning AWS
- Microsoft 365 Certified Fundamentals MS-900 Exam Guide
- 一步一步跟我學(xué)Scratch3.0案例
- 貫通Tomcat開(kāi)發(fā)
- Visual Basic語(yǔ)言程序設(shè)計(jì)基礎(chǔ)(第3版)
- Hands-On ROS for Robotics Programming
- PHP程序設(shè)計(jì)高級(jí)教程