Document Purpose
in the Install Mongodb application on Linux system and set basic security permissions to ensure database security
Basic Knowledge
MongoDB is based on a database for Distributed file storage . Written by the C + + language. Designed to provide scalable, high-performance data storage solutions for WEB applications.
MongoDB is a product between a relational database and a non-relational database, and is non-relational database The most versatile, most like 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.
Common Commands
Command |
Usage |
Start MONGO with a configuration file |
Mongod--config/etc/mongod.conf--port 27017--dbpath/data/db1 |
restart mongo |
|
Add MONGO to boot |
Chkconfig Mongod on |
Create a database |
Use database_name |
view database |
show dbs |
insert data |
db.database_name.insert ({ " : name |
Deleting a database |
Db.dropdatabase () |
Delete Collection |
Db.collection.drop () |
Insert Document |
Db. Collection_name.insert (document) |
Viewing a document that has been inserted |
Db.col.find () |
Update document |
Db.collection.update () |
|
Db.collection.save () |
Delete a document |
Db.collection.remove () |
MongoDB Monitoring |
Mongostat |
|
Mongotop |
Required Software
MongoDB Server version:3.4.1
System Environment
operating system:CentOS 7 (3.10.0-327.36.3.el7.x86_64)
Operation Steps1.
Configuring the Yum repository
Vim/etc/yum.repos.d/mongodb-org-3.4.repo
[mongodb-org-3.4]
Name=mongodb Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
Gpgcheck=1
Enabled=1
gpgkey=HTTPS://WWW.MONGODB.ORG/STATIC/PGP/SERVER-3.4.ASC
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/8C/D4/wKioL1h64ffBLg9JAAAZAK7xV9Y636.png "title=" Picture 1.png "alt=" Wkiol1h64ffblg9jaaazak7xv9y636.png "/>
2.
installing MongoDB Apps
sudo yum install-y mongodb-org
3. Open MONGO with no access control mode
Mongod--port 27017--DBPATH/DATA/DB1 &
Note: If you do not have a/data/db1 folder, create a new mkdir-p/data/db1
4. Set the Administrator account password
log in to MONGO
MONGO--port 27017
Create an administrator user
Use admin
Db.createuser (
{
User: "Myuseradmin",
PWD: "abc123",
Roles: [{role: ' Useradminanydatabase ', db: ' admin '}]
}
)
5. Configure the MONGO configuration file to turn on the Force access control function
Vim/etc/mongod.conf
Modify security Options
Security
Authorization:enabled
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/8C/D8/wKiom1h64ifw6JPUAAAEhbIWtkY582.png "title=" Picture 2.png "alt=" Wkiom1h64ifw6jpuaaaehbiwtky582.png "/>
6. Apply config file to open MONGO
Mongod--config/etc/mongod.conf--port 27017--dbpath/data/db1
Note: You can also use the following command to force access control on the function to turn on MONGO
Mongod--auth--port 27017--dbpath/data/db1
Note: If there is an open SELinux, you need to configure the following statement
Semanage port-a-t mongod_port_t-p TCP 27017
7.
Create a general user account
Mongo
Use test
Db.createuser (
{
User: "Mytester",
PWD: "Xyz123",
Roles: [{role: ' ReadWrite ', DB: ' Test '},
{role: "read", DB: "Reporting"}]
}
)
FAQ
Reference Documents
https://docs.mongodb.com/manual/tutorial/enable-authentication/
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
This article is from the "11591346" blog, please be sure to keep this source http://11601346.blog.51cto.com/11591346/1892046
MongoDB Deployment Installation (Linux official version)