This article will compile MongoDB in a Linux environment.
You can choose to use the compiled version directly, or you can try compiling it yourself. Https://www.mongodb.org/downloads#production official Building Document link in: https://github.com/mongodb/mongo/blob/master/docs/ Building.md hands-on start:
1, Linux, this article selected Ubuntu 14.04 LTS 64bit,:
Http://www.ubuntu.com/download/desktop
2. Package dependency: Compiler gcc g++ clang installation method:
# sudo apt-get install gcc (4.8.2 or later)
# sudo apt-get install g++ (4.8.2 or later)
# sudo apt-get install clang (3.4 or later)
3. Package dependency: Python (more than 2.7 versions) installation method:
# sudo apt-get install python
4, the package depends on: scons (2.3 or more versions) installation method:
# sudo apt-get install scons
5. Package Dependency
# sudo apt-get install aptitude
# Aptitude Install SCons build-essential
# Aptitude Install Libboost-filesystem-dev Libboost-program-options-dev libboost-system-dev Libboost-thread-dev
6. Source code: Download from github: Https://github.com/mongodb/mongo directly select a branch, right download Zip, unzip to directory:
# mkdir MONGODB-MASTER-SRC
# Unzip Mongodb-master.zip mongodb-master-src/
# CD mongodb-master-src/
7, create a new Version.json file in the mongodb-master-src/directory: In most of the documents can be searched, everyone is downloaded directly after the compilation, but will report a scons error, because of the lack of this file.
# gedit Version.json
Then enter the following to save:
{
"Version": "0.0.1-fake-"
}
8, compile the source code:
# sudo scons all-j 4
Here-j 4 refers to the number of CPU cores you are using. You can also directly:
# sudo scons
all
or just
# sudo scons mongod
# sudo scons MONGO
# sudo scons mongos
9, after compiling the verification, execute the following statement, you will see the version prompt information.
#./mongod--version
10, post-compilation configuration, new related directories and configuration files
# mkdir Mongodb_sample
# CD mongodb_sample/
# mkdir Bin
# mkdir Data
# mkdir Log
# mkdir conf
# CD conf
# gedit mongod.conf
In the open port, enter:
Port = 12345
DBPath = Data
LogPath = Log/mongod.log
Fork = True
Where: port represents the port number on which the database is accessed, and fork represents a background process.
11. Copy the compiled files to the bin directory
# CP.. /mongod mongodb_sample/bin/
12. Start Mongod:
# CD mongodb_sample/bin/
#./mongod-f conf/mongod.conf
13. Check the log and data directory to see the new files in the folder.
14, stop Mongod, here because there is no connection to the Mongod server, so the direct use of kill way to shut down, when closed, do not use kill-9, you can use kill-15:
Find the Process ID first:
# Ps-a | grep mongod
And then
# Kill 32759
For the parameters following the kill command, see: Https://en.wikipedia.org/wiki/Unix_signal#SIGTERM
How do I compile MongoDB?