ubuntu 下mongodb安装
1.下载:
mongodb.org/download
2. 将下载的压缩文件加压到/usr/lib下
3. 建立软链接
ln -s /usr/lib/mongodb-linux-i686-2.6.7/bin/mongod /usr/bin/mongod
ln -s /usr/lib/mongodb-linux-i686-2.6.7/bin/mongo /usr/bin/mongo
这样就可以在命令行下调用mongod和mongo指令了。
当然也可以通过 apt-get install mongodb-server来安装,不过可能版本稍微旧了点。
---以下可选----
4. 启动默认的服务
mongod --dbpath /usr/lib/mongodb-linux-8686-2.6.7/db
但是这样子不是后台运行的,需要把它转为后台运行。
这该怎么办呢?
解答:在/etc/init.d下面建立一个脚本mongod,同时删除掉/usr/bin/mongod。如下:
#!/bin/sh
service mongodb-server start
同时设置为启动项:
update-rc.d mongod defaults
新建脚本文件 /etc/init.d/mongodb-server并设置好权限,内容如下:
#!/bin/sh
DAEMON=/usr/bin/mongodb-linux-i686-2.6.7/bin/mongod
DAEMON_OPTS="--dbpath /usr/lib/mongodb-linux-i686-2.6.7/db"
NAME=mongodb-server
DESC=mongodb-server
PIDFILE=/var/run/$NAME.pid
USER = tommy
case "${1}" in
case start)
echo "starting ${DESC}:"
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--chuid $(USER} --background --make-pidfile \
--exec ${DEAMON} -- ${DEAMON_OPTS}
echo "[ok]"
;;
case stop)
echo "stopping ${DESC}:"
start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
--oknodo
echo "[ok]"
;;
esac
exit 0
需要创建pidfile,并设置好权限,过程略。
以上配置后,每次开机,自动启动mongodb的默认服务,数据库为 /usr/lib/mongodb-...../db
只需要在命令行键入mongo就可以连入默认的db。
----分割--------------
以下开发相关:
(比如mongoengine的情形)
from mongoengin import *
connect('local') class Test(Document):
name = StringField(max_length=100) #...
=====附注: centos下的安装======
下载redhat包,解压到/usr/local下,重命名为mongodb;
新建脚本/etc/init.d/mongod3, 如下(本人瞎掰的):
# !bin/sh
# chkconfig: - 64 36 NAME=mongod2
PROC=/usr/local/mongodb/bin/mongod
LOG_FILE=/var/log/mongodb.log
DB_PATH=/usr/local/mongodb/db
start(){
$PROC --fork --logpath $LOG_FILE --dbpath $DB_PATH
} stop(){
ps aufx | grep $PROC | grep -v grep | awk '{print $2}' | xargs kill -9
echo 'stoped ...'
} status(){
ps afux | grep $PROC | grep -v grep || echo 'stoped'
} case "$1" in start)
start
;; stop)
stop
;; status)
status $NAME
;; restart)
stop
start
;; *)
echo "Usage: $0 {start|stop|restart|status}"
;; esac
加入自动启动
su root
chmod 755 /etc/init.d/mongod3
chkconfig --add mongod3
chkconfig mongod3 on
chkconfig --list | grep mongod3
ubuntu 下mongodb安装的更多相关文章
- Ubuntu下MongoDB的安装和使用
本博文介绍了MongoDB,并详细指引读者在Ubuntu下MongoDB的安装和使用.本教程在Ubuntu14.04下测试通过.(2017.09.07) 安装MongoDB MongoDB安装很简单, ...
- Ubuntu下软件安装方式、PATH配置、查找安装位置
Ubuntu 18.04, 安装方式 目前孤知道的Ubuntu下安装软件方式有3种(命令): 1.make 2.apt/apt-get 3.dpkg 方式1基于软件源码安装,需要经历配置(可选).编译 ...
- Torch7在Ubuntu下的安装与配置
Torch7的本系列教程的主要目的是介绍Torch的入门使用.今天首先分享一下Torch7的安装.(在Ubuntu14.04安装torch7) 为什么选择Torch Torch的目标是在建立科学算法的 ...
- ubuntu下git安装及使用
ubuntu下git安装及使用 其实,好几个月前,就已经安装好了,可是一直搁置在那儿,所以密码等一些其它细节都忘的差不多了,所以今天就重新部署了一下,并开始积极使用......... 1,git ...
- premake Ubuntu下的安装
premake是个跨平台的编译工具,先看看在Ubuntu下怎么安装. 首先下载,在/usr目录下: sudo wget -O premake-4.4-beta4-linux.tar.gz http:/ ...
- linux,windows,ubuntu下git安装与使用
ubuntu下git安装与使用:首先应该检查本地是否已经安装了git ,如果没有安装的话,在命令模式下输入 sudo apt-get install git 进行安装 输入git命令查看安装状态及常用 ...
- ubuntu下如何安装codeblocks集成开发环境
codeblocks是一个十分优秀的C/C++开发IDE,虽然后起之秀codelite目前来看大有超越之势哦. 不过在ubuntu下安装codeblocks却比较麻烦,不像其他linux发行版,比如s ...
- ubuntu下makeinfo安装,其实真正安装的是texinfo包
操作系统环境:ubuntu 在终端中执行命令:sudo apt-get install texinfo 今天在打包的时候有个包需要 makeinfo,当时就各种搜结果就没有 makeinfo 这个 ...
- Windows下Mongodb安装及配置
安装文件:MongoDB-win32-x86_64-2008plus-ssl-3.2.6-signed.msi 电脑配置:win7 64位 mongodb的安装很简单,设置好安装路径后,一直Next直 ...
随机推荐
- haproxy安装
最近一直在整理之前用过的东西,现在到haproxy了,安装如下: tar xf haproxy-1.4.27.tar.gz cd haproxy-1.4.27 make TARGET=linux26 ...
- NGUI架构和Draw Call合并原理
http://bbs.9ria.com/thread-282804-1-1.html http://www.unitymanual.com/blog-97-238.html
- Mini ORM——PetaPoco笔记(转)
记录一下petapoco官网博客的一些要点.这些博客记录了PetaPoco是如何一步步改进的. 目录: Announcing PetaPoco PetaPoco-Improvements PetaPo ...
- 用实例揭示notify()和notifyAll()的本质区别
用实例揭示notify()和notifyAll()的本质区别 收藏 notify()和notifyAll()都是Object对象用于通知处在等待该对象的线程的方法.两者的最大区别在于: notif ...
- jar tvf study.war jar命令查看war/jar包的内容
jar tvf study.war 0 Thu Oct 20 14:01:18 CST 2016 META-INF/ 137 Thu Oct 20 14:01:16 CST 2016 META-INF ...
- 开发Yii2过滤器并通过behaviors()行为调用
在Yii2的几乎每个controller中,我们都会看到一个函数behaviors(),通常,我们用这个函数来配置控制器的权限,例如:public function behaviors() { ...
- java中InvocationHandler 用于实现代理。
以下的内容部分参考了网络上的内容,在此对原作者表示感谢! Java中动态代理的实现,关键就是这两个东西:Proxy.InvocationHandler,下面从InvocationHandler接口中的 ...
- android自定义控件(3)-自定义当前按钮属性
那么还是针对我们之前写的自定义控件:开关按钮为例来说,在之前的基础上,我们来看看有哪些属性是可以自定义的:按钮的背景图片,按钮的滑块图片,和按钮的状态(是开还是关),实际上都应该是可以在xml文件中直 ...
- jquery左右链接类似frameset的插件
一般在使用jquery的扩展的 ui方面的插件, 都要注意链接两个文件 一个是ui 相关的js文件 另一个是 ui相关的 css文件! 参考这个css布局 通常多个平行的items 都是用ul li来 ...
- Unity调试相关
1.LOG处理 将所有LOG信息写入到文件,并设置部分LOG显示到屏幕上,总结成以下脚本,将其挂载在摄像机上即可. using UnityEngine; using System.Collection ...