1.
copy MongoDB to the specified server
To the MongoDB official website http://www.mongodb.org/downloads download MongoDB, unzip and test the directory on the server that needs to be installed, and then configure. For example:
[Email protected] ~]# scp-r [email protected]:/data/web/dxm/mongodb/mongodb-linux-x86_64-2.4.5 data/web/
The MongoDB directory will be copied to the ~/data/web directory of the 10.11.17.165 server.
2.
set up data, log directory
Go to the MongoDB root directory, create a new data directory to hold it, create a new log directory to hold the log, and then create a new one in the directory, for example, named Mongodb.log.
[Email protected] mongodb]# mkdir data
[Email protected] mongodb]# mkdir logs
[Email protected] mongodb]# CD logs
[email protected] logs]# Touch Mongodb.log
3.Creating a configuration file
in the MongoDB root directory Create a new profile with any file name, such as mongodb.conf, then add the configuration information in the configuration file:
port=27017 "represents the port number, if not specified, the default is 27017 "
dbpath=/root/data/web/mongodb/data/ "Database Path"
Logpath=/root/data/web/mongodb/logs/mongodb.log " Log Path "
logappend=true "Log files automatically accumulate, not overwrite"
4.Start the MongoDB service (based on the configuration file)
Execute command
[Email protected]5 mongodb]#/bin/mongod-f mongodb.conf
The following message appears:
All output going to:/root/data/web/mongodb/logs/mongodb.log
5.use the client to connect to the database
Re-open a terminal and switch to the MongoDB directory
[Email protected] ~]# CD Data/web/mongodb
then input
[email protected] mongodb]# Bin/mongo localhost:2701 7
MongoDB Shell version:2.4.5
Connecting To:localhost:27017/test
Server has startup warnings:
Fri Nov 8 13:05:59.823 [Initandlisten]
Fri Nov 8 13:05:59.823 [Initandlisten] * * Warning:you is running on a NUMA machine.
Fri Nov 8 13:05:59.823 [Initandlisten] * * We suggest launching mongod like this to avoid performance problems:
Fri Nov 8 13:05:59.823 [Initandlisten] * * Numactl--interleave=all Mongod [Other options]
Fri Nov 8 13:05:59.823 [Initandlisten]
>
The connection was successful.
6. Configure self-boot (optional)set boot auto start MongoDB
[Email protected] ~]# echo "/root/data/web/mongodb/bin/mongod-f/root/data/web/mongodb/mongodb.conf-fork" >>/ Etc/rc.local
Setting environment variables
VI ~/.bash_profile
Path= $PATH: $HOME/bin: $JAVA _home/bin:/root/data/web/mongodb/bin
MONGODB Installation and Configuration