Linux下Mongodb安裝和啟動配置

來源:互聯網
上載者:User

標籤:

1.下載安裝包

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

下載完成後解壓縮壓縮包

tar zxf mongodb-linux-i686-1.8.2.tgz
2. 安裝準備將mongodb移動到/usr/local/server/mongdb檔案夾
mv mongodb-linux-i686-1.8.2 /usr/local/mongodb

建立資料庫檔案夾與記錄檔

mkdir /usr/local/mongodb/datatouch /usr/local/mongodb/logs
3. 設定開機自啟動將mongodb啟動項目追加入rc.local保證mongodb在伺服器開機時啟動
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
4. 啟動mongodbcd到mongodb目錄下的bin檔案夾啟動mongodb//下面這個是需要許可權的登入方式, 使用者串連需要使用者名稱和密碼
/usr/local/server/mongodb/bin/mongod --dbpath=/usr/local/server/mongodb/data --logpath=/usr/local/server/mongodb/logs --logappend  --auth  --port=27017 --fork

//這個是不要求輸入密碼的

/usr/local/server/mongodb/bin/mongod --dbpath=/usr/local/server/mongodb/data --logpath=/usr/local/server/mongodb/logs --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/mongoMongoDB shell version: 1.8.2connecting to: test> use test;switched to db test
 若資料庫出現如不能連上,則是一個data目錄下的mongod.lock檔案的問題,可以用如下的修複的命令,
mongod --repair

 

Linux下Mongodb安裝和啟動配置

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.