Author: zhanhailiang Date:. Install mongodb: [root @~ Wadenodejsnodeclub] # yumsearchmongodb [root @~ Wadenodejsnodeclub] # yuminstallmongodb. x86_64mongodb-server.x86_64libmongodb.x86_64libmongodb-devel.x86_642. Use configuration file
Author: zhanhailiang Date: 1. Install 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. Use the configuration file
Author: zhanhailiang Date:
1. Install 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. Start the mongodb service in configuration file + background running mode:
[root@/usr/local/mongodb]# lsconf data log[root@/usr/local/mongodb/conf]# cat mongodb_27017.conf fork = truebind_ip = 127.0.0.1port = 27017dbpath = /usr/local/mongodb/data/logpath = /usr/local/mongodb/log/mongodb_27017.loglogappend = truejournal = 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: 21732all output going to: /usr/local/mongodb/log/mongodb_27017.logchild process started successfully, parent exiting[root@/usr/local/mongodb/conf]# ps -ef|grep mongodbroot 21732 1 0 23:12 ? 00:00:00 mongod -f /usr/local/mongodb/conf/mongodb_27017.confroot 21750 21441 0 23:12 pts/1 00:00:00 grep mongodb
Where:
- Fork: Indicates whether to start later in process mode.
- Bind_ip: the IP address bound to the MongoDB process. The default value is localhost (127.0.0.1)
- Port: the TCP port listened by the MongoDB service. The default value is 27017.
- Dbpath: Data Directory
- Logpath: log directory
- Logappend: log append
- Journal: whether to enable pre-write log
3. log on to mongodb using the mongo client to test whether the mongodb service is running properly:
[root@/usr/local/mongodb/conf]# mongo MongoDB shell version: 2.4.6connecting to: test> version()2.4.6
4. Stop the mongodb service:
You can log on to the client to stop the mongodb service:
[root@/usr/local/mongodb/conf]# mongo MongoDB shell version: 2.4.6connecting to: test> use admin;switched to db admin> db.shutdownServer();Fri Nov 7 23:46:54.710 DBClientCursor::init call() failedserver should be down...Fri Nov 7 23:46:54.712 trying reconnect to 127.0.0.1:27017Fri Nov 7 23:46:54.712 reconnect 127.0.0.1:27017 failed couldn't connect to server 127.0.0.1:27017
You can also use the mongod command to disable the function:
[root@/usr/local/mongodb/conf]# mongod --shutdown -f /usr/local/mongodb/conf/mongodb_27017.conf killing process with pid: 23099
Recommended reading:
- Manage mongod Processes
- MongoDB: start the service
- MongoDB: Shut down the service