Heim  >  Artikel  >  Datenbank  >  Gentoo Linux安装MongoDB

Gentoo Linux安装MongoDB

WBOY
WBOYOriginal
2016-06-07 17:36:01950Durchsuche

终于要用Nosql产品了。我们采用的是最近比较火的MongoDB,当然不是随大流,而是因为产品中要用到地理空间索引,很适合。这面是我

终于要用Nosql产品了。我们采用的是最近比较火的MongoDB,当然不是随大流,,而是因为产品中要用到地理空间索引,很适合。

这面是我在Gentoo Linux笑傲的配置过程:

1,下载自己需要的版本,我这用的是mongodb-linux-x86_64-2.4.9.tgz
 # wget
# 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: +Line+Parameters
# - File Based Configuration: +Based+Configuration


dbpath=/opt/mongodb/data
logpath=/opt/mongodb/data/mongodb.log
logappend=true


# bind_ip = 127.0.0.1
# port = 27017


fork = true
auth = true

# noauth = true

5.测试一下:
到这里,我们其实已经可以使用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/mongodb


depend() {
        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,配置完成。

MongoDB 的详细介绍:请点这里
MongoDB 的下载地址:请点这里

相关阅读:

MongoDB备份与恢复

CentOS编译安装MongoDB

CentOS 编译安装 MongoDB与mongoDB的php扩展

CentOS 6 使用 yum 安装MongoDB及服务器端配置

Ubuntu 13.04下安装MongoDB2.4.3

如何在MongoDB中建立新数据库和集合

MongoDB入门必读(概念与实战并重)

《MongoDB 权威指南》(MongoDB: The Definitive Guide)英文文字版[PDF]

linux

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn