系統(tǒng)之家 - 系統(tǒng)光盤下載網(wǎng)站!

當(dāng)前位置:系統(tǒng)之家 > 系統(tǒng)教程 > Linux安裝配置mongodb

Linux安裝配置mongodb的方法

時(shí)間:2015-06-08 16:59:01 作者:qipeng 來源:系統(tǒng)之家 1. 掃描二維碼隨時(shí)看資訊 2. 請(qǐng)使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20150608/50319.html 手機(jī)查看 評(píng)論

  mongodb是非關(guān)系型數(shù)據(jù)庫,使用的人不少,在Linux下的安裝也不簡(jiǎn)單,不少用戶在Linux系統(tǒng)安裝和配置mongodb上吃了一些苦頭,下面小編就給大家介紹下mongodb的安裝配置方法。

Linux安裝配置mongodb的方法

  1.下載安裝包

  wget https://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.2.tgz

  下載完成后解壓縮壓縮包

  tar zxf mongodb-linux-i686-1.8.2.tgz

  2. 安裝準(zhǔn)備

  將mongodb移動(dòng)到/usr/local/server/mongdb文件夾

  mv mongodb-linux-i686-1.4.4 /usr/local/mongodb

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

  mkdir /usr/local/mongodb/data

  touch /usr/local/mongodb/logs

  3. 設(shè)置開機(jī)自啟動(dòng)

  將mongodb啟動(dòng)項(xiàng)目追加入rc.local保證mongodb在服務(wù)器開機(jī)時(shí)啟動(dòng)

  echo “/usr/local/server/mongodb/bin/mongod –dbpath=/usr/local/server/mongodb/data –

  logpath=/usr/local/server/mongodb/logs –logappend –auth –port=27017″ 》》 /etc/rc.local

  echo “/usr/local/mongodb/bin/mongod –dbpath=/usr/local/mongodb/data –

  logpath=/usr/local/mongodb/logs –logappend –auth –port=27017″ 》》 /etc/rc.local

  4. 啟動(dòng)mongodb

  cd到mongodb目錄下的bin文件夾啟動(dòng)mongodb

  //下面這個(gè)是需要權(quán)限的登錄方式, 用戶連接需要用戶名和密碼

  /usr/local/server/mongodb/bin/mongod –dbpath=/usr/local/server/mongodb/data –

  logpath=/usr/local/server/mongodb/logs –logappend –auth –port=27017 –fork

  //這個(gè)是不需要密碼的

  /usr/local/server/mongodb/bin/mongod –dbpath=/usr/local/server/mongodb/data –

  logpath=/usr/local/server/mongodb/logs –logappend –port=27017 –fork

  5. 參數(shù)解釋: –dbpath 數(shù)據(jù)庫路徑(數(shù)據(jù)文件)

  –logpath 日志文件路徑

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

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

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

  –pologSize 指定日志文件大小不超過64M.因?yàn)閞esync是非常操作量大且耗時(shí),最好通過設(shè)置一個(gè)足夠大的

  oplogSize來避免resync(默認(rèn)的 oplog大小是空閑磁盤大小的5%)。

  –logappend 日志文件末尾添加

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

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

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

  –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 無認(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ù)庫配額的管理

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

  件數(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ù)庫文件大小預(yù)分配

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

  –nssize arg (=16) .ns file size (in MB) for new databases 新數(shù)據(jù)庫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ù)庫

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

  –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 《server:port》 當(dāng)為從時(shí),指定主的地址和端口

  –only arg when slave: specify a single database to replicate 當(dāng)為從時(shí),指定需要從主復(fù)

  制的單一庫

  –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ù)器

  6. 進(jìn)入數(shù)據(jù)庫的CLI管理界面

  cd到mongodb目錄下的bin文件夾,執(zhí)行命令。/mongo

  運(yùn)行如下:

 。踨oot@namenode mongodb]# 。/bin/mongo

  MongoDB shell version: 1.8.2

  connecting to: test

  》 use test;

  switched to db test

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

  mongod –repair

  上面就是Linux安裝配置mongodb的方法介紹了,軟件包可自己需找網(wǎng)站下載,mongodb安裝前需做一些準(zhǔn)備。

標(biāo)簽 mongodb

發(fā)表評(píng)論

0

沒有更多評(píng)論了

評(píng)論就這些咯,讓大家也知道你的獨(dú)特見解

立即評(píng)論

以上留言僅代表用戶個(gè)人觀點(diǎn),不代表系統(tǒng)之家立場(chǎng)

其他版本軟件

熱門教程

人氣教程排行

Linux系統(tǒng)推薦

掃碼關(guān)注
掃碼關(guān)注

掃碼關(guān)注 官方交流群 軟件收錄