Brief introduction
MongoDB is a product between a relational database and a non-relational database, and is the most versatile and most like relational database in a non-relational database. The data structure he supports is very loose and is a JSON-like Bson format, so you can store more complex data types. MONGO's biggest feature is that the query language he supports is very powerful, and its syntax is a bit like an object-oriented query language that almost implements most of the functionality of a relational database single-table query, and also supports indexing of data.
Packages Package Description
The MongoDB official source contains the following dependent packages:
MONGODB-ORG:MONGODB metadata package, install the following four packages automatically:
1. Mongodb-org-server: Contains the MongoDB daemon and related configuration and initialization scripts.
2, Mongodb-org-mongos: Contains the MONGOs daemon.
3, Mongodb-org-shell: Contains MONGO shell.
4. Mongodb-org-tools: A tool that includes MongoDB: Mongoimport, Bsondump, Mongodump, Mongoexport, Mongofiles, Mongooplog, Mongoperf, Mongorestore, Mongostat, and Mongotop.
Experimental environment
System version: centos7x3.10.0-514.el7.x86_64
MongoDB version: mongodb-linux-x86_64-rhel70-3.6.6
Turn off the firewall and disable power-on self-booting
Systemctl Stop Firewalld.service
Systemctl Disable FIREWALLD
Turn off SELinux
Sed-i ' s/selinux=enforcing/selinux=disabled/g '/etc/sysconfig/selinux
Restart reboot
Installing MongoDB
MongoDB website
MongoDB Usage Tutorials
MongoDB Source code Download
Note: Download the source package as required!
1. Go to MongoDB website to download the installation package (download path below)
Go to MongoDB website (be sure to use a compatible browser otherwise may not open, such as Firefox, Google, etc.)
Click to select Community Servers and Linux systems
Click the "Version" drop-down menu at the bottom left to select the appropriate edition
Finally download the specified version of the binary file and upload it to the server as required
2. Extracting MongoDB
1) View compressed package ls
2) Unzip the mongodb-linux-x86_64-rhel70-3.6.6.tgz to the specified directory
Tar zxf mongodb-linux-x86_64-rhel70-3.6.6.tgz-c/usr/local/
3) go to unzip directory
cd/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/
3. Create a MongoDB data store directory and log storage directory
mkdir DB Log
Note: These two directories will be used in the configuration file behind!
4. Write MongoDB configuration file
Vi/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/bin/mongodb.conf
Systemlog:
Destination:file
Path: "/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/log/mongodb.log"
Logappend:true
Storage
DbPath: "/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/db/"
Journal
Enabled:true
Processmanagement:
Fork:true
Pidfilepath: "/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/mongodb.pid"
Net
port:27017
Setparameter:
Enablelocalhostauthbypass:false
Note: This piece may have children's shoes will ask? What document are you mongodb.pid? Why not? Don't worry. This PID file can be understood as the process code when the service starts or shuts down. Why didn't you find this file? Because this file default source installation does not exist, we write the path in advance to start MongoDB later, the system will automatically follow this path to create this PID file.
5. Creating a MongoDB-initiated script
Vi/etc/init.d/mongodb
#!/bin/sh
#chkconfig: 2345 80 90
#description: MongoDB
Start () {
/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/bin/mongod-f/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/bin/ Mongodb.conf
}
Stop () {
/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/bin/mongod-f/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/bin/ Mongodb.conf--shutdown
}
Case "$" in
Start
Start
;;
Stop
Stop
;;
Restart
Stop
Start
;;
*)
echo $ "Usage: $ {Start|stop|restart}"
Exit 1
Esac
6. Start script execution permissions for MongoDB
chmod +x/etc/init.d/mongodb
7. Set up the start-up service
1) Start the MongoDB setup
Chkconfig--level + MongoDB on
2) registering MongoDB as a system service
Chkconfig--add MongoDB
3) Start MongoDB service
/etc/init.d/mongodb start
4) Stop MongoDB Service
/etc/init.d/mongodb stop
5) Restart MongoDB service
/etc/init.d/mongodb restart
8. Turn on the firewall and open the 27017 port.
1) Turn on the firewall
SYSTEMCLT Start Firewalld
2) permanently open 27017 port
Firewall-cmd--add-port=27017/tcp--permanent
3) Restart the firewall for configuration to take effect
Systemctl Restart Firewalld
4) See if it takes effect
Firewall-cmd--list-all
9. Configure Environment variables
1) Edit the environment variable and add a row at the end of the file as follows
Vi/etc/profile
Export path= $PATH:/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/bin
2) Execution Environment variables
Source/etc/profile
10. Test if MongoDB is installed successfully
1) Use the MONGO command to enter the MongoDB console
2) switch database management user
Use admin
Note: To complete the source of the MongoDB database to build!
Centos7 Source Installation MongoDB-3.6