MongoDB初探系列之二:認識MongoDB提供的一些常用工具,mongodb系列之二

來源:互聯網
上載者:User

MongoDB初探系列之二:認識MongoDB提供的一些常用工具,mongodb系列之二

在初探一中,我們已經可以順利的將MongoDB在我們自己的機器上跑起來了。但是在其bin目錄下面還有一些我們不熟知的工具。接下來,將介紹一下各個小工具的用途以及初探一中MongoDB在data檔案夾下建立的檔案的用途。


1、bin目錄下面的各種小工具簡介及使用方式

bsondump.exe 

用於將匯出的BSON檔案格式轉換為JSON格式mongo.exe mongoDB的用戶端

mongod.exe 

用於啟動mongoDB的Server

mongodump.exe 

用於從mongodb資料庫中匯出BSON格式的檔案,類似於mysql的dump工具mysqldump

mongoexport.exe 

用於將mongodb中的資料庫,匯出為JSON,CSV或TSV的格式。

使用樣本:mongoexport --host mongodb1.example.net --port 37017 --username user --password pass --collection contacts

mongofiles.exe 

用於和mongoDB的GridFS檔案系統互動的命令,並可操作其中的檔案,它提供了我們本地系統與GridFS檔案系統之間的儲存物件介面。

使用樣本:mongofiles --hostname db1.example.net --port 37017 -d records list

mongoimport.exe 用

於將JSON,CSV或TSV等檔案格式,匯入到mongoDB資料庫中。

使用樣本:mongoimport --db users --collection contacts --type csv --file /opt/backups/contacts.csv

mongooplog.exe 

用於從啟動並執行mongod服務中拷貝作業記錄到指定的伺服器,主要用於增量備份。

使用樣本:mongooplog --from mongodb0.example.net --host mongodb1.example.net,備份還可以參看一下這篇BLOG:http://www.ttlsa.com/html/2052.html

mongoperf.exe 用於獨立檢查mongoDB的I/O效能的工具。

使用樣本:mongoperf.exe < testPrefJson.txt (註:testPrefJson.txt存放測試的參數,以json格式,如:{nThreads:16,fileSizeMB:1000,r:true},更多參數參看該命令的協助),在linux上配置iostat命令觀察寫入的效果

mongorestore.exe

用於恢複匯出的BSON檔案到mongodb資料庫中

mongos.exe 

用於註冊系統處理

mongostat.exe 

當前mongod狀態監控工具,像linux中監控linux的vmstat

mongotop.exe

提供了一個跟蹤mongod資料庫花費在讀寫資料的時間,為每個collection都會記錄,預設記錄時間是按秒記錄。

mongosniff (linux及unix有此工具)用於監控串連到mongodb的TCP/IP串連,類似於tcpdump。應用可以查看這篇BLOG:http://blog.nosqlfan.com/html/521.html


2、MongoDB建立的資料檔案簡介

dbname.0 

資料檔案

dbname.ns檔案

dbname.ns檔案儲存體命名空間資訊。在mongodb裡,每個collection都具有一個命名空間,名字為dbname.collection_name。dbname.ns檔案儲存體的是一個雜湊表節點數組。key是根據命名空間的名字,value是命名空間資訊。雜湊表節點的大小是628位元組,dbname.ns檔案的預設大小是16M,一共可以存放26715個命名空間。

mongod.lock

儲存當前MongoDB的進程資訊

著作權聲明:轉載請註明博文地址,尊重作者勞動成果。歡迎關注http://blog.csdn.net/zgs_shmily,一起成長。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.