1. 程式人生 > >Linux下Mongodb安裝,命令列操作和sql語句

Linux下Mongodb安裝,命令列操作和sql語句

--logappend --port=27017 --fork


5. 引數解釋: --dbpath 資料庫路徑(資料檔案)
--logpath 日誌檔案路徑
--master 指定為主機器
--slave 指定為從機器
--source 指定主機器的IP地址
--pologSize 指定日誌檔案大小不超過64M.因為resync是非常操作量大且耗時,最好通過設定一個足夠大的oplogSize來避免resync(預設的 oplog大小是空閒磁碟大小的5%)。
--logappend 日誌檔案末尾新增
--port 啟用埠號
--fork 在後臺執行
--only 指定只複製哪一個資料庫
--slavedelay 指從複製檢測的時間間隔
--auth 是否需要驗證許可權登入(使用者名稱和密碼)


-h [ --help ] show this usage information
--version show version information
-f [ --config ] arg configuration file specifying additional options
--port arg specify port number
--bind_ip arg local ip address to bind listener - all local ips
bound by default
-v [ --verbose ] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
--dbpath arg (=/data/db/) directory for datafiles 指定資料存放目錄
--quiet quieter output 靜默模式
--logpath arg file to send all output to instead of stdout 指定日誌存放目錄
--logappend appnd to logpath instead of over-writing 指定日誌是以追加還是以覆蓋的方式寫入日誌檔案
--fork fork server process 以建立子程序的方式執行
--cpu periodically show cpu and iowait utilization 週期性的顯示cpu和io的使用情況
--noauth run without security 無認證模式執行
--auth run with security 認證模式執行
--objcheck inspect client data for validity on receipt 檢查客戶端輸入資料的有效性檢查
--quota enable db quota management 開始資料庫配額的管理
--quotaFiles arg number of files allower per db, requires --quota 規定每個資料庫允許的檔案數
--appsrvpath arg root directory for the babble app server 
--nocursors diagnostic/debugging option 除錯診斷選項
--nohints ignore query hints 忽略查詢命中率
--nohttpinterface disable http interface 關閉http介面,預設是28017
--noscripting disable scripting engine 關閉指令碼引擎
--noprealloc disable data file preallocation 關閉資料庫檔案大小預分配
--smallfiles use a smaller default file size 使用較小的預設檔案大小
--nssize arg (=16) .ns file size (in MB) for new databases 新資料庫ns檔案的預設大小
--diaglog arg 0=off 1=W 2=R 3=both 7=W+some reads 提供的方式,是隻讀,只寫,還是讀寫都行,還是主要寫+部分的讀模式
--sysinfo print some diagnostic system information 列印系統診斷資訊
--upgrade upgrade db if needed 如果需要就更新資料庫
--repair run repair on all dbs 修復所有的資料庫
--notablescan do not allow table scans 不執行表掃描
--syncdelay arg (=60) seconds between disk syncs (0 for never) 系統同步重新整理磁碟的時間,預設是60s

Replication options:
--master master mode 主複製模式
--slave slave mode 從複製模式
--source arg when slave: specify master as <server:port> 當為從時,指定主的地址和埠
--only arg when slave: specify a single database to replicate 當為從時,指定需要從主複製的單一庫
--pairwith arg address of server to pair with
--arbiter arg address of arbiter server 仲裁伺服器,在主主中和pair中用到
--autoresync automatically resync if slave data is stale 自動同步從的資料
--oplogSize arg size limit (in MB) for op log 指定操作日誌的大小
--opIdMem arg size limit (in bytes) for in memory storage of op ids指定儲存操作日誌的記憶體大小

Sharding options:
--configsvr declare this is a config db of a cluster 指定shard中的配置伺服器
--shardsvr declare this is a shard db of a cluster 指定shard伺服器

6. 進入資料庫的CLI管理介面
cd到mongodb目錄下的bin資料夾,執行命令./mongo
執行如下:
[
[email protected]
mongodb]# ./bin/mongo
MongoDB shell version: 1.8.2
connecting to: test
> use test;
switched to db test

若資料庫出現如不能連上,則是一個data目錄下的mongod.lock檔案的問題,可以用如下的修復的命令,
mongod --repair