NoSQL: Non-relational, distributed, acid-not-available
Simple Data Model
Separation of metadata and application data
Weak consistency
Advantage:
Avoid unnecessary complexity
High throughput
High level of scalability and low-end hardware clustering
Do not use object-relational mappings
Disadvantage:
ACID Properties Not supported
Simple function
No unified data Query model
Acid:atomicity Atomicity, consistency consistency, isolation isolation, durability persistence
NoSQL Categories:
Column database (column-managed)
Key-Value Storage
Document database (each line as an entity, separate file)
Survival database (Survival object with complex relationships), used in social sites to store complex relationships between people
A NoSQL data storage model
Column database (column-managed)
Data model: Data is stored by column, with the same column of data
Advantages: Fast lookup, strong scalability, easy to implement distributed
Cons: Limited functionality vs. sql
Application scenario: Distributed File system or distributed storage
Examples: BigTable, Cassandra, HBase, hypertable (mass data storage)
running on a distributed file system
Key-value Storage (Data model: Key-value storage)
Pros: Find Fast
Cons: Data is unstructured and is usually used only as a string or binary data
Application Scenario: Content Caching
Example: Redis, Dynamo
Document database (each line as an entity, separate file)
Data model: Similar to a key-value model, but value points to structured data, with a container attached to multiple key-value pairs
Pros: Data format requirements are not stringent, no need to define the structure beforehand
Adding a field does not require a change in its data structure
Disadvantage: Query performance is not high lack of unified query syntax
Application Scenario: Web App
Example: MongoDB, CouchDB
Survival database (Survival object with complex relationships), used in social sites to store complex relationships between people
Data Model: Graph structure Model
Advantages: The use of graph structure-related algorithms to provide performance, and full of special scenarios application requirements
Cons: Difficult to achieve distributed, functional and directional
Application scenarios: social networks, referral systems, relational maps
Example: neo4j
Mongodb:scalable (extensible) high-performance (high performance) Open source schema free document NoSQL
Schema free: No data structures need to be created beforehand
Read and write in memory
Support Extensibility: replication, Automatic sharding
Applies To: Web site, cache, high scalability, HI Volume,low value
MongoDB installation: It is recommended to install with RPM package
RPM Package Address: Https://repo.mongodb.org/yum/redhat, choose your own version to download
Yum-y Localinstall *.rpm
Mkdir-p/mongodb/data: Create a data directory, modify the data directory path in the configuration file
usermod-d/mongodb/data Mongod
Chown-r Mongod:mongod/mongodb/data: Modifying the genus Group of the data directory
Finally, a simple modification of the configuration file information (data directory, log directory, etc.)
Finally, you can start Mongod.
Service Mongod Start
To view the log records, the following warning is found:
Cat/var/log/mongodb/mongod.log View Log, error is as follows:
* * Warning:soft rlimits too low. Rlimits set to 1024x768 processes, 64000 files.
Number of processes should is at least 32000:0.5 times number of files.
Reference: http://blog.csdn.net/kk185800961/article/details/45613267
Current limitations of MongoDB: Processes, 64000 files
MongoDB Recommended Requirements: Processes = 0.5*files=32000 (at least)
So you need to change the processes from 1024 to 32000 or greater.
To modify the configuration file/etc/security/limits.conf, add the configuration information:
############## #for mongodb##############
Mongod Soft Nofile 64000
Mongod Hard Nofile 64000
Mongod Soft Nproc 32000
Mongod Hard Nproc 32000
Then restart the Mongod, review the log record again, found no warning, so the installation of MongoDB succeeded
MongoDB's Simple Grud operation:
>help (View Help)
Db.help () Help on DB methods
Db.mycoll.help () Help on collection methods
Sh.help () sharding Helpers
Rs.help () Replica set helpers
Help Admin Administrative Help
Help connect connecting to a DB help
Help keys key shortcuts
Help Misc Misc Things to Know
Help Mr MapReduce
Show DBS Show Database names
Show collections show collections in current database
Show users show users in current database
Show profile Show most recent system.profile entries with time >= 1ms
Show logs show the accessible logger names
Show log [name] prints out the last segment of log in memory, ' global ' is default
Use <db_name> Set current database
Db.foo.find () List objects in collection Foo
Db.foo.find ({a:1}) List objects in Foo where a = = 1
It result of the last line evaluated; Use to further iterate
dbquery.shellbatchsize = X Set default number of items to display on shell
Exit quit the MONGO shell
View All galleries: Show DBS
View all collections (in MySQL is a table, in MongoDB with collections): Show collections
Switch Library: Use HUANGDB (no need to define it before, just take it to the library.)
Inserting data into the collection Huangcoll: Db.huangcoll.insert ({Name: "Huang"})
View the collection's data: Db.huangcoll.find (): This is all the data that is viewing the collection Huangcoll
Find data by criteria: Db.huangcoll.find ({Name: "Huang"}): Find documents with Name Huang
CREATE INDEX: Db.huangcoll.ensureIndex ({name:1}): Create index for field Name
View index: Db.huangcoll.getIndexes (): View all indexes under the current collection
For more MONGO command operations, refer to the documentation:
https://docs.mongodb.com/manual/crud/
NoSQL MongoDB Simple installation and command use