Building a MongoDB server
1. Download MongoDB installation files, this example according to the Mongod version of 2.6.5 as the standard mongodb-linux-x86_64-2.6.5, after the 2.6 version of the permissions of MongoDB enhanced. This is my Baidu cloud mongodb2.6.5 linux64 bit of resources file, can be downloaded according to this address HTTP://PAN.BAIDU.COM/S/1SJXHMSL 1. Unzip mongodb-linux-x86_64-2.6.5. TGZ resource File
TAR-ZXF mongodb-linux-x86_64-2.6. 5. tgz
2. Understand the MongoDB file description into the bin directory of MongoDB
CD mongodb-linux-x86_64-2.6. 5 CD Bin
Mongo |
client programs, connecting MongoDB |
Mongod |
Server-side program, start MongoDB |
Mongodump |
Backup program |
Mongoexport |
Data Export Program |
Mongofiles |
Gridfs tools, built-in Distributed file system |
Mongoimport |
Data Import Program |
Mongorestore |
Data Recovery Program |
MONGOs |
Data sharding program to support scale-out of data |
Mongostat |
Monitor program |
3. We set up several separate folders to start the MongoDB database service so that independence is easy to maintain.
3.1 Storing resource files related to MongoDB
mkdir MongoDB
3.2 Entering the MongoDB directory
CD MongoDB
3.3 Creating a repository for MongoDB database files
mkdir data
3.4 Storing MongoDB database log files
mkdir logs
3.5 Storing client programs that connect to the MongoDB server
MkDir bin
3.6 Storing the resource profile to start MongoDB
mkdir conf
4. Copy the MONGO to the bin directory, which is the client that connects the MongoDB database
cp/usr/mongodb-linux-x86_64-2.6. 5/bin/mongo/usr/mongodb/bin/
5. Copy Mongod to conf folder Mongod is enabled for the MongoDB database service execution file use it to enable the MongoDB database service
Cp/usr/mongodb-linux-x86_64-2.6.5/bin/mongod/usr/mongodb/conf
6. All right, let's do the last step and build it, create a configuration file that starts the MongoDB service, including the port, the directory to the database file, the log file of the database, etc...
VI mongodb.conf
CP below to mongodb.conf file
#===start=== #数据库存放路径dbpath =/usr/mongodb/data#log log file path LogPath =/usr/mongodb/logs/mongodb.log# Port number port=12345# Let the service run in the background fork=truenohttpinterface=true#===end===
7. Start the MongoDB database service
[[email protected] conf]#./mongod-f mongodb.conf about to fork child process, waiting until server was ready for CONNECTI Ons.forked Process:9676child Process started successfully, parent exiting
Ok,successfully, it has succeeded, and has returned to PID 9676, we can look at MongoDB service
[Email protected] ~]# ps-ef|grep mongodbroot7250 7120 0Sep09 pts/1 xx:xx:xxTail-F Mongodb.logroot9676 1 0 Ten: -?xx:xx:xx./mongod-F Mongodb.confroot9861 9836 0 One: thepts/3 xx:xx:xxgrep MongoDB
We saw a PID 9676 just like that. So that means MongoDB's service is up.
8. We use the client MONGO to connect MongoDB, see the following figure has a > logo, then I have logged into the MongoDB database.
./mongo IP: Port/Database
We're on this machine, so we're using 127.0.0.1, and the port we just defined in the mongodb.conf file is 12345,test is the database name.
9. You may encounter an alert for the first connection, but you can still log in, and we will not be able to sign out before the alert will appear.
Use the Db.shutdownserver () method, but this need to use the admin permission to stop, so you have to switch user name, in accordance with the tablet execution OK.
Then execute again./mongo 127.0.0.1:12345/test the alert will not appear when the entry is entered.
MongoDB Database Service Building