mongodb3.2二進制安裝mysql
1.環境介紹linux
2.配置環境變量,修改與之相關的系統參數git
3.建立mongodb運行用戶和目錄等web
4.上傳安裝包,解壓安裝sql
5.建立配置文件mongodb
6.啓動並進行簡單測試shell
7.總結 數據庫
1.環境介紹:vim
OS:Centos6.5_64安全
MongoDB版本:mongodb-linux-x86_64-rhel62-v3.2-latest.tgz
Memory:2G
2.配置環境變量,修改與之相關的系統參數
在該文件中末尾添加這些參數,不然後面會有相應地告警信息
[root@aly-lww3 ~]# 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
[root@aly-lww3 ~]# echo 0 > /proc/sys/vm/zone_reclaim_mode
[root@aly-lww3 ~]# sysctl -w vm.zone_reclaim_mode=0
vm.zone_reclaim_mode = 0
[root@aly-lww3 ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@aly-lww3 ~]# echo never > /sys/kernel/mm/transparent_hugepage/defrag
[root@aly-lww3 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用戶同樣,
因此這裏我推薦建立一個用戶。若是不建立的話,也能運行,不過日誌中會有相應的告警提示信息。
[root@aly-lww3 ~]# useradd mongodb # 注意:mongodb這個用戶名能夠取別的
[root@aly-lww3 ~]# 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.
[root@aly-lww3 ~]#
建立須要的目錄,並修改權限,切換到mongodb用戶模式
[root@aly-lww3 ~]# su - mongodb
[mongodb@aly-lww3 ~]$ mkdir -p {data,log,conf}
[mongodb@aly-lww3 ~]$ 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
[mongodb@aly-lww3 ~]$
4.上傳安裝包,解壓安裝
[mongodb@aly-lww3 ~]$ wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-rhel62-v3.2-latest.tgz
[mongodb@aly-lww3 ~]$ 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
[mongodb@aly-lww3 ~]$ tar -zxf mongodb-linux-x86_64-rhel62-v3.2-latest.tgz
[mongodb@aly-lww3 ~]$ mv mongodb-linux-x86_64-rhel62-3.2.1-83-g187028f/ mongodb3.2.1
[mongodb@aly-lww3 ~]$ rm -f mongodb-linux-x86_64-rhel62-v3.2-latest.tgz # 能夠不用刪除
5.建立配置文件
[mongodb@aly-lww3 ~]$ vim /home/mongodb/.bash_profile
export PATH=/home/mongodb/mongodb3.2.1/bin:$PATH
[mongodb@aly-lww3 ~]$ source /home/mongodb/.bash_profile
[mongodb@aly-lww3 ~]$ 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
[mongodb@aly-lww3 ~]$
6.啓動並進行簡單測試
啓動有兩種方式啓動,直接命令行啓動,還有一種就是使用配置文件啓動,
強烈建議使用配置文件啓動。
[mongodb@aly-lww3 ~]$ /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
[mongodb@aly-lww3 ~]$ 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
[mongodb@aly-lww3 ~]$ 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
[mongodb@aly-lww3 ~]$
[mongodb@aly-lww3 ~]$ 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
[mongodb@aly-lww3 ~]$
建立一個快捷啓動mongodb的方式
[mongodb@aly-lww3 ~]$ vim start_mongodb.sh
#!/bin/bash
/home/mongodb/mongodb3.2.1/bin/mongod -f /home/mongodb/conf/mongodb.conf
[mongodb@aly-lww3 ~]$ ./start_mongodb.sh
about to fork child process, waiting until server is ready for connections.
forked process: 32619
child process started successfully, parent exiting
[mongodb@aly-lww3 ~]$
[mongodb@aly-lww3 ~]$ 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
[mongodb@aly-lww3 ~]$
7. 關閉mongodb數據庫
關閉mongodb數據庫,這裏有三種安全的方式
(1) kill -4 pid
[mongodb@aly-lww3 ~]$ 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
[mongodb@aly-lww3 ~]$ ps -ef|grep 'bin/mongod'|grep -v 'grep'|awk -F" " '{print $2}'
32485
[mongodb@aly-lww3 ~]$ kill -4 `ps -ef|grep 'bin/mongod'|grep -v 'grep'|awk -F" " '{print $2}'`
日誌太多,這裏省略...
再次啓動看看
[mongodb@aly-lww3 ~]$ ./start_mongodb.sh
about to fork child process, waiting until server is ready for connections.
forked process: 32654
child process started successfully, parent exiting
[mongodb@aly-lww3 ~]$
[mongodb@aly-lww3 ~]$ 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
[mongodb@aly-lww3 ~]$ kill -2 `ps -ef|grep 'bin/mongod'|grep -v 'grep'|awk -F" " '{print $2}'`
[mongodb@aly-lww3 ~]$ > /home/mongodb/log/mongodb.log
[mongodb@aly-lww3 ~]$ 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
再次啓動看看
[mongodb@aly-lww3 ~]$ 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數據庫
[mongodb@aly-lww3 ~]$ /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
[mongodb@aly-lww3 ~]$
查看關閉日誌
[mongodb@aly-lww3 ~]$ 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
[mongodb@aly-lww3 ~]$
再次啓動看看
[mongodb@aly-lww3 ~]$ ./start_mongodb.sh
about to fork child process, waiting until server is ready for connections.
forked process: 32740
child process started successfully, parent exiting
[mongodb@aly-lww3 ~]$
[mongodb@aly-lww3 ~]$ 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自身的優點外,最喜歡它的複製集和分片功能。
在這兩點上,目前關係型數據庫實現起來相對較複雜,不易維護管理。