mongodb3.2二进制单机版安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mongodb3.2二进制单机版安装相关的知识,希望对你有一定的参考价值。

            mongodb3.2二进制安装

1.环境介绍

2.配置环境变量,修改与之相关的系统参数

3.创建mongodb运行用户和目录等

4.上传安装包,解压安装

5.创建配置文件

6.启动并进行简单测试

7.总结 


1.环境介绍:

OS:Centos6.5_64

MongoDB版本:mongodb-linux-x86_64-rhel62-v3.2-latest.tgz

Memory:2G


2.配置环境变量,修改与之相关的系统参数

在该文件中末尾添加这些参数,否则后面会有相应地告警信息

[[email protected] ~]# vim /etc/security/limits.conf

*  -  fsize        unlimited    # (file size)

*  -  cpu          unlimited    # (cpu time)

*  -  as           unlimited    # (virtual memory size)

*  -  nofile       64000        # (open files)

*  -  nproc        64000        # (processes/threads)


mongodb soft nofile 64000

mongodb hard nofile 64000

mongodb soft nproc 32000

mongodb hard nproc 32000


在proc中关闭NUMA

[[email protected] ~]# echo 0 > /proc/sys/vm/zone_reclaim_mode 

[[email protected] ~]# sysctl -w vm.zone_reclaim_mode=0

vm.zone_reclaim_mode = 0

[[email protected] ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled

[[email protected] ~]# echo never > /sys/kernel/mm/transparent_hugepage/defrag


[[email protected] local]# vim /etc/rc.local 

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then

   echo never > /sys/kernel/mm/transparent_hugepage/enabled

fi

if test -f /sys/kernel/mm/transparent_hugepage/defrag; then

   echo never > /sys/kernel/mm/transparent_hugepage/defrag

fi


上述操作的目的是解决类似如下的告警信息:

2015-03-19T00:43:27.760+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always‘.

2015-03-19T00:43:27.760+0800 I CONTROL  [initandlisten] **        We suggest setting it to ‘never‘


3.创建mongodb运行用户和目录等

因为高版本的mongodb需要独立的用户来运行mongod进程,像mysqld需要mysql用户一样,

所以这里我推荐创建一个用户。如果不创建的话,也能运行,不过日志中会有相应的告警提示信息。

[[email protected] ~]# useradd mongodb  # 注意:mongodb这个用户名可以取别的

[[email protected] ~]# passwd mongodb

Changing password for user mongodb.

New password: 

BAD PASSWORD: it is based on a dictionary word

BAD PASSWORD: is too simple

Retype new password: 

passwd: all authentication tokens updated successfully.

[[email protected] ~]# 


创建需要的目录,并修改权限,切换到mongodb用户模式

[[email protected] ~]# su - mongodb

[[email protected] ~]$ mkdir -p {data,log,conf}

[[email protected] ~]$ ll

total 12

drwxrwxr-x 2 mongodb mongodb 4096 Jan 25 14:03 conf

drwxrwxr-x 2 mongodb mongodb 4096 Jan 25 14:03 data

drwxrwxr-x 2 mongodb mongodb 4096 Jan 25 14:03 log

[[email protected] ~]$ 


4.上传安装包,解压安装

[[email protected] ~]$ wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-rhel62-v3.2-latest.tgz

[[email protected] ~]$ ll

total 64900

drwxrwxr-x 2 mongodb mongodb     4096 Jan 25 14:03 conf

drwxrwxr-x 2 mongodb mongodb     4096 Jan 25 14:03 data

drwxrwxr-x 2 mongodb mongodb     4096 Jan 25 14:03 log

-rw-rw-r-- 1 mongodb mongodb 66443467 Jan 23 02:47 mongodb-linux-x86_64-rhel62-v3.2-latest.tgz

[[email protected] ~]$ tar -zxf mongodb-linux-x86_64-rhel62-v3.2-latest.tgz 

[[email protected] ~]$ mv mongodb-linux-x86_64-rhel62-3.2.1-83-g187028f/ mongodb3.2.1

[[email protected] ~]$ rm -f mongodb-linux-x86_64-rhel62-v3.2-latest.tgz  # 可以不用删除


5.创建配置文件

[[email protected] ~]$ vim /home/mongodb/.bash_profile 

export PATH=/home/mongodb/mongodb3.2.1/bin:$PATH

[[email protected] ~]$ source /home/mongodb/.bash_profile 

[[email protected] ~]$ vim conf/mongodb.conf

# bind_ip=192.168.0.100 # ip绑定

port=37000  # 端口号

dbpath=/home/mongodb/data/

logpath=/home/mongodb/log/mongodb.log # 输出日志文件名称

pidfilepath=/home/mongodb/mongobd.pid # pid文件名称

journal=true

maxConns=50000 # 最大连接数

logappend=true  # 日志输出方式

fork=true # 以守护进程的方式运行,创建服务器进程

# httpinterface=false # web界面

noauth=true 

cpu=true

[[email protected] ~]$ 


6.启动并进行简单测试

启动有两种方式启动,直接命令行启动,还有一种就是使用配置文件启动,

强烈建议使用配置文件启动。


[[email protected] ~]$ /home/mongodb/mongodb3.2.1/bin/mongod -f /home/mongodb/conf/mongodb.conf 

about to fork child process, waiting until server is ready for connections.

forked process: 32485

child process started successfully, parent exiting

[[email protected] ~]$ ps -ef|grep mongodb

root     32305 32261  0 13:56 pts/0    00:00:00 su - mongodb

mongodb  32485     1  1 14:43 ?        00:00:00 /home/mongodb/mongodb3.2.1/bin/mongod -f /home/mongodb/conf/mongodb.conf

mongodb  32502 32306  0 14:44 pts/0    00:00:00 grep mongodb

[[email protected] ~]$ netstat -anltp|grep 37000

(Not all processes could be identified, non-owned process info

 will not be shown, you would have to be root to see it all.)

tcp        0      0 0.0.0.0:37000               0.0.0.0:*                   LISTEN      32485/mongod        

[[email protected] ~]$ 

[[email protected] ~]$ cat /home/mongodb/log/mongodb.log 

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten] MongoDB starting : pid=32485 port=37000 dbpath=/home/mongodb/data/ 64-bit host=aly-lww3

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten] db version v3.2.1-83-g187028f

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten] git version: 187028f283545496b0254216d17822211fe5202c

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten] allocator: tcmalloc

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten] modules: none

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten] build environment:

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten]     distmod: rhel62

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten]     distarch: x86_64

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten]     target_arch: x86_64

2016-01-25T14:43:50.877+0800 I CONTROL  [initandlisten] options: { config: "/home/mongodb/conf/mongodb.conf", cpu: true, net: { maxIncomingConnections: 50000, port: 37000 }, processManagement: { fork: true, pidFilePath: "/home/mongodb/mongobd.pid" }, security: { authorization: "disabled" }, storage: { dbPath: "/home/mongodb/data/", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/home/mongodb/log/mongodb.log" } }

2016-01-25T14:43:50.877+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),

2016-01-25T14:43:51.017+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory ‘/home/mongodb/data/diagnostic.data‘

2016-01-25T14:43:51.018+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker

2016-01-25T14:43:51.045+0800 I NETWORK  [initandlisten] waiting for connections on port 37000

[[email protected] ~]$ 


创建一个快捷启动mongodb的方式

[[email protected] ~]$ vim start_mongodb.sh 

#!/bin/bash

/home/mongodb/mongodb3.2.1/bin/mongod -f /home/mongodb/conf/mongodb.conf 

[[email protected] ~]$ ./start_mongodb.sh 

about to fork child process, waiting until server is ready for connections.

forked process: 32619

child process started successfully, parent exiting

[[email protected] ~]$ 

[[email protected] ~]$ cat /home/mongodb/log/mongodb.log 

2016-01-25T15:07:04.483+0800 I CONTROL  [main] ***** SERVER RESTARTED *****

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten] MongoDB starting : pid=32619 port=37000 dbpath=/home/mongodb/data/ 64-bit host=aly-lww3

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten] db version v3.2.1-83-g187028f

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten] git version: 187028f283545496b0254216d17822211fe5202c

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten] allocator: tcmalloc

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten] modules: none

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten] build environment:

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten]     distmod: rhel62

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten]     distarch: x86_64

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten]     target_arch: x86_64

2016-01-25T15:07:04.520+0800 I CONTROL  [initandlisten] options: { config: "/home/mongodb/conf/mongodb.conf", cpu: true, net: { maxIncomingConnections: 50000, port: 37000 }, processManagement: { fork: true, pidFilePath: "/home/mongodb/mongobd.pid" }, security: { authorization: "disabled" }, storage: { dbPath: "/home/mongodb/data/", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/home/mongodb/log/mongodb.log" } }

2016-01-25T15:07:04.521+0800 I -        [initandlisten] Detected data files in /home/mongodb/data/ created by the ‘wiredTiger‘ storage engine, so setting the active storage engine to ‘wiredTiger‘.

2016-01-25T15:07:04.521+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),

2016-01-25T15:07:04.913+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory ‘/home/mongodb/data/diagnostic.data‘

2016-01-25T15:07:04.914+0800 I NETWORK  [initandlisten] waiting for connections on port 37000

2016-01-25T15:07:04.914+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker

[[email protected] ~]$ 


7. 关闭mongodb数据库

关闭mongodb数据库,这里有三种安全的方式

(1) kill -4 pid 

[[email protected] ~]$ ps -ef|grep ‘bin/mongod‘|grep -v ‘grep‘

mongodb  32485     1  0 14:43 ?        00:00:07 /home/mongodb/mongodb3.2.1/bin/mongod -f /home/mongodb/conf/mongodb.conf

[[email protected] ~]$ ps -ef|grep ‘bin/mongod‘|grep -v ‘grep‘|awk -F" " ‘{print $2}‘

32485

[[email protected] ~]$ kill -4 `ps -ef|grep ‘bin/mongod‘|grep -v ‘grep‘|awk -F" " ‘{print $2}‘`

日志太多,这里省略...


再次启动看看

[[email protected] ~]$ ./start_mongodb.sh 

about to fork child process, waiting until server is ready for connections.

forked process: 32654

child process started successfully, parent exiting

[[email protected] ~]$ 

[[email protected] ~]$ tail -f  /home/mongodb/log/mongodb.log 

2016-01-25T15:13:30.772+0800 I CONTROL  [main] ***** SERVER RESTARTED *****

2016-01-25T15:13:30.809+0800 I CONTROL  [initandlisten] MongoDB starting : pid=32654 port=37000 dbpath=/home/mongodb/data/ 64-bit host=aly-lww3

2016-01-25T15:13:30.809+0800 I CONTROL  [initandlisten] db version v3.2.1-83-g187028f

2016-01-25T15:13:30.810+0800 I CONTROL  [initandlisten] git version: 187028f283545496b0254216d17822211fe5202c

2016-01-25T15:13:30.810+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013

2016-01-25T15:13:30.810+0800 I CONTROL  [initandlisten] allocator: tcmalloc

2016-01-25T15:13:30.810+0800 I CONTROL  [initandlisten] modules: none

2016-01-25T15:13:30.810+0800 I CONTROL  [initandlisten] build environment:

2016-01-25T15:13:30.810+0800 I CONTROL  [initandlisten]     distmod: rhel62

2016-01-25T15:13:30.810+0800 I CONTROL  [initandlisten]     distarch: x86_64

2016-01-25T15:13:30.810+0800 I CONTROL  [initandlisten]     target_arch: x86_64

2016-01-25T15:13:30.810+0800 I CONTROL  [initandlisten] options: { config: "/home/mongodb/conf/mongodb.conf", cpu: true, net: { maxIncomingConnections: 50000, port: 37000 }, processManagement: { fork: true, pidFilePath: "/home/mongodb/mongobd.pid" }, security: { authorization: "disabled" }, storage: { dbPath: "/home/mongodb/data/", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/home/mongodb/log/mongodb.log" } }

2016-01-25T15:13:30.810+0800 I -        [initandlisten] Detected data files in /home/mongodb/data/ created by the ‘wiredTiger‘ storage engine, so setting the active storage engine to ‘wiredTiger‘.

2016-01-25T15:13:30.810+0800 W -        [initandlisten] Detected unclean shutdown - /home/mongodb/data/mongod.lock is not empty.

2016-01-25T15:13:30.810+0800 W STORAGE  [initandlisten] Recovering data from the last clean checkpoint.

2016-01-25T15:13:30.810+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),

2016-01-25T15:13:31.145+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory ‘/home/mongodb/data/diagnostic.data‘

2016-01-25T15:13:31.145+0800 I NETWORK  [initandlisten] waiting for connections on port 37000

2016-01-25T15:13:31.146+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker

2016-01-25T15:13:32.019+0800 I FTDC     [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK


从启动日志看,自动回复了。


(2) kill -2 pid

[[email protected] ~]$ kill -2 `ps -ef|grep ‘bin/mongod‘|grep -v ‘grep‘|awk -F" " ‘{print $2}‘`

[[email protected] ~]$ > /home/mongodb/log/mongodb.log 

[[email protected] ~]$ tail -f  /home/mongodb/log/mongodb.log 

2016-01-25T15:14:49.415+0800 I CONTROL  [signalProcessingThread] got signal 2 (Interrupt), will terminate after current cmd ends

2016-01-25T15:14:49.415+0800 I FTDC     [signalProcessingThread] Shutting down full-time diagnostic data capture

2016-01-25T15:14:49.416+0800 I CONTROL  [signalProcessingThread] now exiting

2016-01-25T15:14:49.416+0800 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...

2016-01-25T15:14:49.416+0800 I NETWORK  [signalProcessingThread] closing listening socket: 6

2016-01-25T15:14:49.416+0800 I NETWORK  [signalProcessingThread] closing listening socket: 7

2016-01-25T15:14:49.416+0800 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-37000.sock

2016-01-25T15:14:49.417+0800 I NETWORK  [signalProcessingThread] shutdown: going to flush diaglog...

2016-01-25T15:14:49.417+0800 I NETWORK  [signalProcessingThread] shutdown: going to close sockets...

2016-01-25T15:14:49.417+0800 I STORAGE  [signalProcessingThread] WiredTigerKVEngine shutting down

2016-01-25T15:14:49.456+0800 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...

2016-01-25T15:14:49.456+0800 I CONTROL  [signalProcessingThread] dbexit:  rc: 0


再次启动看看 

[[email protected] ~]$ cat   /home/mongodb/log/mongodb.log 

2016-01-25T15:15:22.822+0800 I CONTROL  [main] ***** SERVER RESTARTED *****

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten] MongoDB starting : pid=32681 port=37000 dbpath=/home/mongodb/data/ 64-bit host=aly-lww3

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten] db version v3.2.1-83-g187028f

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten] git version: 187028f283545496b0254216d17822211fe5202c

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten] allocator: tcmalloc

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten] modules: none

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten] build environment:

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten]     distmod: rhel62

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten]     distarch: x86_64

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten]     target_arch: x86_64

2016-01-25T15:15:22.858+0800 I CONTROL  [initandlisten] options: { config: "/home/mongodb/conf/mongodb.conf", cpu: true, net: { maxIncomingConnections: 50000, port: 37000 }, processManagement: { fork: true, pidFilePath: "/home/mongodb/mongobd.pid" }, security: { authorization: "disabled" }, storage: { dbPath: "/home/mongodb/data/", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/home/mongodb/log/mongodb.log" } }

2016-01-25T15:15:22.858+0800 I -        [initandlisten] Detected data files in /home/mongodb/data/ created by the ‘wiredTiger‘ storage engine, so setting the active storage engine to ‘wiredTiger‘.

2016-01-25T15:15:22.858+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),

2016-01-25T15:15:23.194+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory ‘/home/mongodb/data/diagnostic.data‘

2016-01-25T15:15:23.195+0800 I NETWORK  [initandlisten] waiting for connections on port 37000

2016-01-25T15:15:23.195+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker


从关闭和启动日志中看,相对使用kill -4 而言,使用kill -2 更安全些。

(3) 使用db.shutdownServer()关闭mongodb数据库 

[[email protected] ~]$ /home/mongodb/mongodb3.2.1/bin/mongo --port 37000 

MongoDB shell version: 3.2.1-83-g187028f

connecting to: 127.0.0.1:37000/test

Welcome to the MongoDB shell.

For interactive help, type "help".

For more comprehensive documentation, see

http://docs.mongodb.org/

Questions? Try the support group

http://groups.google.com/group/mongodb-user

> show dbs

local  0.000GB

> use admin

switched to db admin

> db.shutdownServer();

server should be down...

2016-01-25T15:18:00.919+0800 I NETWORK  [thread1] trying reconnect to 127.0.0.1:37000 (127.0.0.1) failed

2016-01-25T15:18:00.921+0800 I NETWORK  [thread1] Socket recv() errno:104 Connection reset by peer 127.0.0.1:37000

2016-01-25T15:18:00.921+0800 I NETWORK  [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [127.0.0.1:37000] 

2016-01-25T15:18:00.922+0800 I NETWORK  [thread1] reconnect 127.0.0.1:37000 (127.0.0.1) failed failed 

> exit

bye

[[email protected] ~]$ 


查看关闭日志

[[email protected] ~]$ cat /home/mongodb/log/mongodb.log 

2016-01-25T15:17:29.958+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:41509 #1 (1 connection now open)

2016-01-25T15:18:00.915+0800 I COMMAND  [conn1] terminating, shutdown command received

2016-01-25T15:18:00.915+0800 I FTDC     [conn1] Shutting down full-time diagnostic data capture

2016-01-25T15:18:00.917+0800 I CONTROL  [conn1] now exiting

2016-01-25T15:18:00.917+0800 I NETWORK  [conn1] shutdown: going to close listening sockets...

2016-01-25T15:18:00.917+0800 I NETWORK  [conn1] closing listening socket: 6

2016-01-25T15:18:00.917+0800 I NETWORK  [conn1] closing listening socket: 7

2016-01-25T15:18:00.917+0800 I NETWORK  [conn1] removing socket file: /tmp/mongodb-37000.sock

2016-01-25T15:18:00.917+0800 I NETWORK  [conn1] shutdown: going to flush diaglog...

2016-01-25T15:18:00.917+0800 I NETWORK  [conn1] shutdown: going to close sockets...

2016-01-25T15:18:00.917+0800 I STORAGE  [conn1] WiredTigerKVEngine shutting down

2016-01-25T15:18:01.000+0800 I STORAGE  [conn1] shutdown: removing fs lock...

2016-01-25T15:18:01.000+0800 I CONTROL  [conn1] dbexit:  rc: 0

[[email protected] ~]$ 


再次启动看看 

[[email protected] ~]$ ./start_mongodb.sh 

about to fork child process, waiting until server is ready for connections.

forked process: 32740

child process started successfully, parent exiting

[[email protected] ~]$ 

[[email protected] ~]$ tail -f  /home/mongodb/log/mongodb.log 

2016-01-25T15:19:00.369+0800 I CONTROL  [main] ***** SERVER RESTARTED *****

2016-01-25T15:19:00.406+0800 I CONTROL  [initandlisten] MongoDB starting : pid=32740 port=37000 dbpath=/home/mongodb/data/ 64-bit host=aly-lww3

2016-01-25T15:19:00.406+0800 I CONTROL  [initandlisten] db version v3.2.1-83-g187028f

2016-01-25T15:19:00.406+0800 I CONTROL  [initandlisten] git version: 187028f283545496b0254216d17822211fe5202c

2016-01-25T15:19:00.406+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013

2016-01-25T15:19:00.406+0800 I CONTROL  [initandlisten] allocator: tcmalloc

2016-01-25T15:19:00.406+0800 I CONTROL  [initandlisten] modules: none

2016-01-25T15:19:00.406+0800 I CONTROL  [initandlisten] build environment:

2016-01-25T15:19:00.406+0800 I CONTROL  [initandlisten]     distmod: rhel62

2016-01-25T15:19:00.406+0800 I CONTROL  [initandlisten]     distarch: x86_64

2016-01-25T15:19:00.407+0800 I CONTROL  [initandlisten]     target_arch: x86_64

2016-01-25T15:19:00.407+0800 I CONTROL  [initandlisten] options: { config: "/home/mongodb/conf/mongodb.conf", cpu: true, net: { maxIncomingConnections: 50000, port: 37000 }, processManagement: { fork: true, pidFilePath: "/home/mongodb/mongobd.pid" }, security: { authorization: "disabled" }, storage: { dbPath: "/home/mongodb/data/", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/home/mongodb/log/mongodb.log" } }

2016-01-25T15:19:00.407+0800 I -        [initandlisten] Detected data files in /home/mongodb/data/ created by the ‘wiredTiger‘ storage engine, so setting the active storage engine to ‘wiredTiger‘.

2016-01-25T15:19:00.407+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),

2016-01-25T15:19:00.759+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory ‘/home/mongodb/data/diagnostic.data‘

2016-01-25T15:19:00.760+0800 I NETWORK  [initandlisten] waiting for connections on port 37000

2016-01-25T15:19:00.760+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker


可见,使用db.shutdownServer()和使用kill -2 比较放心些。所以我们最好能采用这两种的其中一个即可。


7.总结 

  本文档是基于目前相对较新的版本在测试过境中搭建的过程,而且是单机环境。目的是从头开始尝试

mongodb这种NoSQL数据库的使用。个人看重的除了mongodb自身的优势外,最喜欢它的复制集和分片功能。

在这两点上,目前关系型数据库实现起来相对较复杂,不易维护管理。


本文出自 “mongodb单机安装” 博客,请务必保留此出处http://lww2016.blog.51cto.com/3560553/1738306

以上是关于mongodb3.2二进制单机版安装的主要内容,如果未能解决你的问题,请参考以下文章

linux mongodb replica set集群安装

mongodb3.2安装

mongodb3.2安装与基本配置

CentOS7.2 上安装MongoDB3.2-3.3笔记

MongoDB3.2.7安装及用户角色配置

CentOS6.5下安装Mongodb3.2.4