NoSQL basic concepts and MongoDB
MongoDB basic application
MongoDB index and replication set
The concept of database sharding and the implementation of Mongodb sharding
1. NoSQL basic concepts
NoSQL (Not Only SQL) is a technical genre, non-relational database; suitable for use in the field of big data, various nosql has its own query statement, which is also one of the shortcomings of nosql.
Big data (BigDate) also called massive data is a vague concept, like Google, Baidu collect a large amount of data, analyze the present, predict the future; these data through some specific characteristics and algorithms to obtain certain prediction results, these data Big Data.
Four forms of big data:
1. Parallel database: relational database horizontal cutting, partition query
2. NoSQL database management system: non-relational model, distributed, does not support ACID database design paradigm becomes NoSQL
Advantages: simple data model, metadata and data separation, weak consistency, high throughput, high level of scalability, and low-end hardware clustering
Disadvantages: The data model is not verified, does not support ACID features, has simple functions, and there is no unified query language
3. NewSQL database management system: representative products Cluterix, GenieDB, ScaleBase, NimbusDB, Drizzleyun
4. Cloud data management system:
Analysis and processing of big data:
MapReduce
Final consistency breakdown:
Causal consistency, read-write consistency, session consistency, monotonic read consistency, timeline consistency
ACID: strong consistency, isolation, pessimistic and conservative method, difficult to change;
BASE: weak consistency, availability first, optimistic approach, adapt to change, simpler and faster
Data consistency implementation technology: NRW, 2PC, Paxos, Vector Clock
Data storage model: www.nosql-databases.org
Columnar storage model, document data model, key-value data model, schema data model
Column model:
Application scenario: Provide distributed data storage supporting random read and write on top of a distributed file system
Typical products: Hadoop / HBase, Hypertable (developed by Facebook), Cassandra (Facebook)
Data model: Store with "columns" as the center and store the same column of data together
Advantages: fast query, high scalability, easy to implement distributed expansion
Document model:
Application scenarios: web applications with non-strong transaction requirements
Typical products: MongoDB, ElasticSearch, CouchDB, CouchBase Server
Data model: key-value model, stored as a document
Advantages: No need to define the data model in advance
Key-value model:
Application scenario: Content caching, used for high-load scenarios of massive parallel data access
Typical products: DynamoDB (developed by Amazon), Riak, Redis, MemcacheDB (developed by Sina)
Data model: key-value based on hash table
Advantages: quick query
Schema model:
Application scenarios: social network, recommendation system, relationship graph
Typical products: Neo4j, Infinite Graph, TiTan
Data model: schema structure
Advantages: suitable for schema computing scenarios
2. MongoDB (Official download site www.mongodb.org/downloads/)
MongoDB is a type of Nosql. It has a document data storage model and a jons data model. Its function is second to MySQL, and its performance is stronger than MySQL.
CentOS RPM package: http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/RPMS/
Install mongodb: three packages
(Mongo-org-server.rpm, mongol-org-shell.prm client, mongol-org-tools.rpm tool)
#rpm -ql mongodb View the mongodb configuration file as /etc/mongod.conf
#mkdir -pv / mongodb / data Custom database storage path (default / var / lib / mongo)
#chown -R mongod: mongod / mongodb / (The system creates a mongod user by default to run mongod, modify the directory permissions)
#vi /etc/mongod.conf Modify the database path defined in the configuration file
#The configuration file opens the http interface: httpinterface = true (add rest = true)
#service mongod start
#ls / mongodb / data (check the database initialization data, very large)
#du -sh / mongodb / data / display 3.1G
#ss -tnl #View the monitored ports 27017 and 28017
#mongo --host 172.16.100.7 #connect to the database
> show dbs #No need to create a database, after creating collections (containers, equivalent to tables), automatically delay the creation of the database!
> db.stats () #View database information
> db.serverstats () #View server status
Lesson 51 NoSQL basic concepts and MongoDB applications, database distribution concepts