前言 导师让我看一些NoSQL资料,于是目标锁定了MongoDB,至于为什么,很简单,发现了一些不错的资料。看了一些资料,有一些想法或者读后感吧,记下来,以备回忆。 简介 MongoDB是面向集合、模式自由的文档型数据库。 面向集合(collection),文档(document)而
前言
导师让我看一些NoSQL资料,于是目标锁定了MongoDB,至于为什么,很简单,发现了一些不错的资料。看了一些资料,有一些想法或者读后感吧,记下来,以备回忆。
简介MongoDB是面向集合、模式自由的文档型数据库。
面向集合(collection),文档(document)而不是面向表(table),行(row)。文档型数据库是指数据库里面的数据库格式是BSON,与Json有些类似。MongoDB只是NoSQL的一种,那么为什么要用非关系型数据库呢?
逻辑结构和存储结构逻辑结构:
关系型数据库:一个数据库实例包含多个database,一个database包含多个table,一个table包括多个rows。
MongoDB:一个MongoDB实例包含多个database,一个database包括多个collection,一个collection包括多个document。
存储结构:
关系型数据库:创建一个普通数据库生成两个文件:.mdf,.ldf。
MongoDB: 创建一个普通数据库生成两个文件.ns,.0文件。
此文详细介绍MongoDB数据文件内部结构以及
应用MongoDB自带交互式Javascript Shell,用来对MongoDB进行操作和管理,而且许多MongoDB爱好者也写了许多GUI MongoDB管理软件。MongoDB Shell相较于MongoDB GUIs更底层一些,封闭的更少些,因此更灵活,也更能了解原理,学起来也不是很难。
博客园的一线码农写了一个MongoDB系列很不错,里面介绍了MongoDB 的CURD操作,聚合函数,索引等相关知识。
架构
先知道what,再知道how,最后还得知道why。
介绍的很好。
1. Replica Sets 副本集
即MongoDB在多个服务器上备份数据。有一个primary DB,用户只能向primary DB写入数据,网站空间,但是可以从多个服务器读取数据库,从而可以实现读写分离。而Primary DB和 Secondary DB之间保持着心跳同步检测,保持数据库的一致性。当Primary DB宕机,有仲裁服务器会从Secondary 中选出一个来充当 Primary DB。
2. Auto-Sharding 自动分片
如果一个数据太大,磁盘吃紧,美国空间,需要对数据进行分片。
3.Auto-Sharding + Replica Sets
如此,不但可以解决海量存储和动态扩容问题,而且还可以实现高可靠,高并发。
每个Shard都是集群,
Shard1在三个服务器上都存在,可以提高可靠性,容错能力,备份恢复能力。
config在三个服务器上,也是同理,为了可靠的保存分片的元数据。
mongos在3个服务器上,可实现负载平衡,提高客户端接入性能。
步骤:客户端发起请求,有3个路由进程之一接收并解析命令,然后根据config服务器记录的分片元数据来确定需要接收客户端命令的分片。
服务器的具体配置可以参考 一线码农系列
MongoDB驱动在实际编程中,你当然可以使用process调用cmd命令来操作和管理MongoDB,但是太麻烦了,还是下载驱动方便方便,MongoDB驱动多着,当然会有C#,有官方,也有非官方的。 ?
优劣势优劣势自然是和关系型数据库对比了
参考MongoDB调查总结
MongoDB 身上的优势和劣势
自我总结学起来挺轻松的,也许接触的还不深,没有经过大型项目实战,但是学着一直有种和充实的感觉,那就是我知道为什么会这样,也许是开源的原因吧。NoSQL和关系型数据库各有优势,并立共存,香港虚拟主机,适用于不同的项目中。比如,Mongo不支持事务,对于银行转账之类的自然不适用;但是在web2.0时代,NoSQL的角色愈来愈重要了,NoSQL的优势也是为web2.0而生的。
参考资料1. NoSQLFan MongoDB资料汇总专题 略显杂乱
2. MongoDB 官网 MongoDB手册 权威,英文

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6
Visual web development tools