Linux MongoDB3.2.9安裝

一、創(chuàng)建安裝路徑

mkdir /usr/local/mongodb

二、下載安裝包并解壓

cd??/usr/local/mongodb

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.2.9.tgz

tar -zxvf mongodb-linux-x86_64-ubuntu1404-3.2.9.tgz

三、創(chuàng)建數(shù)據(jù)庫(kù)文件夾與日志文件

mkdir /usr/local/mongodb/data

touch /usr/local/mongodb/logs

四、啟動(dòng)mongodb

cd mongodb-linux-x86_64-ubuntu1404-3.2.9/bin

./mongod


//需要權(quán)限的登錄方式, 用戶連接需要用戶名和密碼

/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend ?--auth ?--port=27017 --fork

//不需要密碼

/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend ?--port=27017 --fork

五、進(jìn)入數(shù)據(jù)庫(kù)的CLI管理界面

cd mongodb-linux-x86_64-ubuntu1404-3.2.9/bin

./mongo


若干問(wèn)題及解決方案:

1.如圖所示問(wèn)題,是配置路徑不正確導(dǎo)致,檢查第四步的路徑。

2.若數(shù)據(jù)庫(kù)出現(xiàn)如不能連上,則是一個(gè)data目錄下的mongod.lock文件的問(wèn)題,可以用mongod --repair?修復(fù)。

附錄: 參數(shù)解釋(以下部分為直接轉(zhuǎn)載,特此聲明)

--dbpath 數(shù)據(jù)庫(kù)路徑(數(shù)據(jù)文件)

--logpath 日志文件路徑

--master 指定為主機(jī)器

--slave 指定為從機(jī)器

--source 指定主機(jī)器的IP地址

--pologSize 指定日志文件大小不超過(guò)64M.因?yàn)閞esync是非常操作量大且耗時(shí),最好通過(guò)設(shè)置一個(gè)足夠大的oplogSize來(lái)避免resync(默認(rèn)的 oplog大小是空閑磁盤大小的5%)。

--logappend 日志文件末尾添加

--port 啟用端口號(hào)

--fork 在后臺(tái)運(yùn)行

--only 指定只復(fù)制哪一個(gè)數(shù)據(jù)庫(kù)

--slavedelay 指從復(fù)制檢測(cè)的時(shí)間間隔

--auth 是否需要驗(yàn)證權(quán)限登錄(用戶名和密碼)

-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 ? ?指定數(shù)據(jù)存放目錄

--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 ? 以創(chuàng)建子進(jìn)程的方式運(yùn)行

--cpu ? ? ? ? ? ? ? ? ? ? periodically show cpu and iowait utilization 周期性的顯示cpu和io的使用情況

--noauth ? ? ? ? ? ? ? ? ?run without security 無(wú)認(rèn)證模式運(yùn)行

--auth ? ? ? ? ? ? ? ? ? ?run with security 認(rèn)證模式運(yùn)行

--objcheck ? ? ? ? ? ? ? ?inspect client data for validity on receipt 檢查客戶端輸入數(shù)據(jù)的有效性檢查

--quota ? ? ? ? ? ? ? ? ? enable db quota management ? 開始數(shù)據(jù)庫(kù)配額的管理

--quotaFiles arg ? ? ? ? ?number of files allower per db, requires --quota 規(guī)定每個(gè)數(shù)據(jù)庫(kù)允許的文件數(shù)

--appsrvpath arg ? ? ? ? ?root directory for the babble app server?

--nocursors ? ? ? ? ? ? ? diagnostic/debugging option 調(diào)試診斷選項(xiàng)

--nohints ? ? ? ? ? ? ? ? ignore query hints 忽略查詢命中率

--nohttpinterface ? ? ? ? disable http interface 關(guān)閉http接口,默認(rèn)是28017

--noscripting ? ? ? ? ? ? disable scripting engine 關(guān)閉腳本引擎

--noprealloc ? ? ? ? ? ? ?disable data file preallocation 關(guān)閉數(shù)據(jù)庫(kù)文件大小預(yù)分配

--smallfiles ? ? ? ? ? ? ?use a smaller default file size 使用較小的默認(rèn)文件大小

--nssize arg (=16) ? ? ? ?.ns file size (in MB) for new databases 新數(shù)據(jù)庫(kù)ns文件的默認(rèn)大小

--diaglog arg ? ? ? ? ? ? 0=off 1=W 2=R 3=both 7=W+some reads 提供的方式,是只讀,只寫,還是讀寫都行,還是主要寫+部分的讀模式

--sysinfo ? ? ? ? ? ? ? ? print some diagnostic system information 打印系統(tǒng)診斷信息

--upgrade ? ? ? ? ? ? ? ? upgrade db if needed 如果需要就更新數(shù)據(jù)庫(kù)

--repair ? ? ? ? ? ? ? ? ?run repair on all dbs 修復(fù)所有的數(shù)據(jù)庫(kù)

--notablescan ? ? ? ? ? ? do not allow table scans 不運(yùn)行表掃描

--syncdelay arg (=60) ? ? seconds between disk syncs (0 for never) 系統(tǒng)同步刷新磁盤的時(shí)間,默認(rèn)是60s

Replication options:

--master ? ? ? ? ? ? ?master mode 主復(fù)制模式

--slave ? ? ? ? ? ? ? slave mode 從復(fù)制模式

--source arg ? ? ? ? ?when slave: specify master as 當(dāng)為從時(shí),指定主的地址和端口

--only arg ? ? ? ? ? ?when slave: specify a single database to replicate 當(dāng)為從時(shí),指定需要從主復(fù)制的單一庫(kù)

--pairwith arg ? ? ? ?address of server to pair with

--arbiter arg ? ? ? ? address of arbiter server 仲裁服務(wù)器,在主主中和pair中用到

--autoresync ? ? ? ? ?automatically resync if slave data is stale 自動(dòng)同步從的數(shù)據(jù)

--oplogSize arg ? ? ? size limit (in MB) for op log 指定操作日志的大小

--opIdMem arg ? ? ? ? size limit (in bytes) for in memory storage of op ids指定存儲(chǔ)操作日志的內(nèi)存大小

Sharding options:

--configsvr ? ? ? ? ? declare this is a config db of a cluster 指定shard中的配置服務(wù)器

--shardsvr ? ? ? ? ? ?declare this is a shard db of a cluster 指定shard服務(wù)器

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容