Gentoolinux安裝mongoDB

來源:互聯網
上載者:User

終於要用Nosql產品了。我們採用的是最近比較火的mongodb,當然不是隨大流,而是因為產品中要用到地理空間索引,很適合。
這面是我的配置過程:

1,下載自己需要的版本,我這用的是mongodb-linux-x86_64-2.4.9.tgz 

# wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tgz# tar -xvzf mongodb-linux-x86_64-2.4.9.tgz
2,建立mongodb目錄,和資料庫目錄。  
# mv mongodb-linux-x86_64-2.4.9.tgz /opt/mongodb # mkdir -p /opt/mongodb/data
3,增加mongodb使用者
# useradd mongod -s /bin/false # chown -R mongod:mongod /data/mongodb 4,編寫設定檔在/opt/mongodb下建立目錄ext:
#mkdir -p ext
寫入:
#!/bin/bash# file name: mongodb.conf# Configuration Options for MongoDB## For More Information, Consider:# - Configuration Parameters: http://www.mongodb.org/display/DOCS/Command+Line+Parameters# - File Based Configuration: http://www.mongodb.org/display/DOCS/File+Based+Configurationdbpath=/opt/mongodb/datalogpath=/opt/mongodb/data/mongodb.loglogappend=true# bind_ip = 127.0.0.1# port = 27017fork = trueauth = true# noauth = true5.測試一下:到這裡,我們其實已經可以使用mongodb了,只是沒有啟動進程。測一下:
#cd /opt/mongodb/bin
這裡可以看到mongo(這是mongodb shell), mongod(這是mongodb的進程)

6.啟動進程:
在/etc/init.d目錄下:
#vi mongodb

寫入:
#!/sbin/runscript# Copyright 1999-2012 Gentoo Foundation# Distributed under the terms of the GNU General Public License v2# $Header: $MONGO_HOME=/opt/mongodbdepend() {        use net}start() {        ebegin "Starting mongodb..."        ${MONGO_HOME}/bin/mongod \                --config ${MONGO_HOME}/ext/mongodb.conf        eend $?}stop() {        ebegin "Stoping mongodb..."        ${MONGO_HOME}/bin/mongod \                --shutdown \                --config ${MONGO_HOME}/ext/mongodb.conf        eend $?}restart() {        start        stop}-------------OK,配置完成。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.