说明:
虽然MongoDB支持在命令行里面添加所有参数,但是为了管理方便,还是应该添加一个配置文件的。然后在命令行里面指定配置文件的位置。
实现:
1.mongoDB目录下添加etc目录,新建mongodb.con文件
# mkdir -p /usr/local/mongoDB/etc # vim /usr/local/mongoDB/etc/mongodb.conf //添加以下内容
#Directory and relavent set dbpath = /data/mongoDB/db logpath = /data/mongoDB/logs/mongodb.log repairpath = /data/mongoDB/repair pidfilepath = /usr/local/mongoDB/mongodb.pid directoryperdb = true #sysinfo = true #verbose = true logappend = true #cpu = true #Network and security set noauth = true #port = 8888 maxConns = 1024 fork = true #Management #nohttpinterface = true rest = true quota = true quotaFiles = 1024 nssize = 16 #syncdelay = 5
2.执行以下命令,开启mongd守护进程,-f为指定配置文件
# /usr/local/mongoDB/bin/mongod -f /usr/local/mongoDB/etc/mongodb.conf