Home > Database > Mysql Tutorial > body text

Mongodb入门安装与配置

WBOY
Release: 2016-06-07 16:10:01
Original
1612 people have browsed it

作者:zhanhailiang 日期:2014-11-07 1. 安装mongodb: [root@~/wade/nodejs/nodeclub]# yum search mongodb[root@~/wade/nodejs/nodeclub]# yum install mongodb.x86_64 mongodb-server.x86_64 libmongodb.x86_64 libmongodb-devel.x86_64 2. 采用配置文件

  作者:zhanhailiang 日期:2014-11-07
Copy after login

1. 安装mongodb:

[root@~/wade/nodejs/nodeclub]# yum search mongodb
[root@~/wade/nodejs/nodeclub]# yum install mongodb.x86_64 mongodb-server.x86_64 libmongodb.x86_64 libmongodb-devel.x86_64
Copy after login

2. 采用配置文件+后台运行模式启动mongodb服务:

[root@/usr/local/mongodb]# ls
conf  data  log
[root@/usr/local/mongodb/conf]# cat mongodb_27017.conf 
fork = true
bind_ip = 127.0.0.1
port = 27017
dbpath = /usr/local/mongodb/data/
logpath = /usr/local/mongodb/log/mongodb_27017.log
logappend = true
journal = true
[root@/usr/local/mongodb/conf]# mongod -f /usr/local/mongodb/conf/mongodb_27017.conf 
about to fork child process, waiting until server is ready for connections.
forked process: 21732
all output going to: /usr/local/mongodb/log/mongodb_27017.log
child process started successfully, parent exiting
[root@/usr/local/mongodb/conf]# ps -ef|grep mongodb
root     21732     1  0 23:12 ?        00:00:00 mongod -f /usr/local/mongodb/conf/mongodb_27017.conf
root     21750 21441  0 23:12 pts/1    00:00:00 grep mongodb
Copy after login

其中:

  • fork:表示是否以后台进程模式启动。
  • bind_ip:MongoDB进程绑定的监听IP,默认为 localhost(127.0.0.1)
  • port:MongoDB 服务监听的TCP端口,默认为 27017
  • dbpath:数据目录
  • logpath:日志目录
  • logappend:日志追加
  • journal: 是否开启预写日志

    3. 使用客户端mongo登录mongodb,测试mongodb服务是否正常运行:

    [root@/usr/local/mongodb/conf]# mongo 
    MongoDB shell version: 2.4.6
    connecting to: test
    > version()
    2.4.6
    Copy after login

    4. 停止mongodb服务:

    可以使用客户端登录停止mongodb服务:

    [root@/usr/local/mongodb/conf]# mongo 
    MongoDB shell version: 2.4.6
    connecting to: test
    > use admin;
    switched to db admin
    > db.shutdownServer();
    Fri Nov  7 23:46:54.710 DBClientCursor::init call() failed
    server should be down...
    Fri Nov  7 23:46:54.712 trying reconnect to 127.0.0.1:27017
    Fri Nov  7 23:46:54.712 reconnect 127.0.0.1:27017 failed couldn't connect to server 127.0.0.1:27017
    Copy after login

    也可以使用 mongod 命令关闭:

    [root@/usr/local/mongodb/conf]# mongod --shutdown -f /usr/local/mongodb/conf/mongodb_27017.conf 
    killing process with pid: 23099
    Copy after login

    推荐阅读:

    • Manage mongod Processes
    • MongoDB:启动服务
    • MongoDB:关闭服务
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!