Linux下MongoDB安装和配置

本文详细介绍了在CentOS环境下配置并启动MongoDB的过程,包括下载安装包、环境准备、配置文件修改、服务启动及验证操作。
一、环境
$ cat /etc/redhat-release 
CentOS Linux release 7.0.1406 (Core) 
$ uname -a
Linux zhaopin-2-201 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$
二、准备
1.下载包
$ sudo wget -c -P /opt/ https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.0.6.tgz    
--2015-09-23 10:18:24--  https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.0.6.tgz
Resolving fastdl.mongodb.org (fastdl.mongodb.org)... 54.230.108.68, 54.230.108.110, 54.230.108.116, ... 
Connecting to fastdl.mongodb.org (fastdl.mongodb.org)|54.230.108.68|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50210575 (48M) [application/x-gzip]
Saving to: ‘/opt/mongodb-linux-x86_64-rhel70-3.0.6.tgz’
100%[======================================================================================================================================================================================================================>] 50,210,575  1.20MB/s   in 50s     
2015-09-23 10:19:19 (978 KB/s) - ‘/opt/mongodb-linux-x86_64-rhel70-3.0.6.tgz’ saved [50210575/50210575]
2.环境
$ cd /opt/
$ sudo tar -zxf mongodb-linux-x86_64-rhel70-3.0.6.tgz
$ ll
total 49052
drwxr-xr-x. 3 root root     4096 Sep 23 10:20 mongodb-linux-x86_64-rhel70-3.0.6
-rw-r--r--. 1 root root 50210575 Aug 24 11:38 mongodb-linux-x86_64-rhel70-3.0.6.tgz
drwxr-xr-x. 8 root root     4096 Sep 21 15:41 omnipitr
drwxr-xr-x. 6 root root     4096 Sep 21 15:53 pg94
lrwxrwxrwx. 1 root root        9 Sep 21 15:53 pgsql -> /opt/pg94
drwxr-xr-x. 2 root root     4096 Jun 10  2014 rh
$ sudo ln -sf /opt/mongodb-linux-x86_64-rhel70-3.0.6 /opt/mongodb
$ ll
total 49052
lrwxrwxrwx. 1 root root       38 Sep 23 10:21 mongodb -> /opt/mongodb-linux-x86_64-rhel70-3.0.6
drwxr-xr-x. 3 root root     4096 Sep 23 10:20 mongodb-linux-x86_64-rhel70-3.0.6
-rw-r--r--. 1 root root 50210575 Aug 24 11:38 mongodb-linux-x86_64-rhel70-3.0.6.tgz
drwxr-xr-x. 8 root root     4096 Sep 21 15:41 omnipitr
drwxr-xr-x. 6 root root     4096 Sep 21 15:53 pg94
lrwxrwxrwx. 1 root root        9 Sep 21 15:53 pgsql -> /opt/pg94
drwxr-xr-x. 2 root root     4096 Jun 10  2014 rh
$
$ sudo vim /etc/profile.d/mongodb.sh
#!/bin/env bash
export PATH="/opt/mongodb/bin:$PATH"
$ source /etc/profile.d/mongodb.sh
$ mongo --version
MongoDB shell version: 3.0.6
三、配置
$ sudo mkdir -p /data/mongodb/{data/db0,backup/db0,log/db0,conf/db0}
$ sudo vim /data/mongodb/conf/db0/mongodb.conf
# base
port = 27017
maxConns = 800
filePermissions = 0700
fork = true
noauth = true
directoryperdb = true
dbpath = /data/mongodb/data/db0
pidfilepath = /data/mongodb/data/db0/mongodb.pid
journal = true

# security
nohttpinterface = true
rest = false

# log
logpath = /data/mongodb/log/db0/mongodb.log
logRotate = rename
logappend = true
slowms = 50
profile = 0
verbose = false
objcheck = false
四、启动
$ sudo systemctl stop firewalld.service
$ sudo systemctl disable firewalld.service
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
rm '/etc/systemd/system/basic.target.wants/firewalld.service'
$ sudo /opt/mongodb/bin/mongod --config /data/mongodb/conf/db0/mongodb.conf
$ mongo
MongoDB shell version: 3.0.6
connecting to: test
> db.version();
3.0.6
>
bye


转载于:https://my.oschina.net/aven92/blog/510179

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值