01 Introduction to relational databases and non-relational data

@(mysql tuning)
directory

[TOC]

1. Some concepts

        1. Database security, availability, reliability, maintainability, fault tolerance

        2. Offsite backup, synchronous, semi-synchronous, asynchronous

        3. Three centers in two places

                The three centers in two places refer to the disaster recovery plan of the database. The three centers respectively refer to the production data center, the same-city disaster recovery center and the remote disaster recovery center. Under this disaster recovery solution, the three data centers in the two cities are interconnected. If one data center fails or has a disaster, other data The center can operate normally and take over key business or all business.

        4. Cold Standby, Hot Standby

                 Hot standby: Data between data centers is backed up in real-time synchronization. For example, the RAC mode of Oracle can achieve hot standby mode, and it can perform addition, deletion, modification, and query operations on two databases at the same time (there are dirty reads and dirty writes). The hot backup method can ensure that data will not be lost if one of the data centers fails.

                 Cold backup: The data is backed up once an hour or a day. If there is a problem, the data before the corresponding time period can be restored.

                Oracle can do real hot backup, mysql can synchronize data to two different physical databases through synchronization, and put the query, addition, deletion, modification and query transactions into the main database, and the slave database mainly performs query transactions. Data synchronization is carried out through real-time synchronization. When the master database is down, the slave database will actively become the master database. At this time, after the DBA repairs the master database, the master database resumes its functions, and the original slave database continues to act as the slave database. character of.

                As a tester, during the testing process, it is necessary to test the high availability and reliability of the cluster. For example: For the disaster recovery database deployed in MySQL cluster, use the LR tool to add data concurrently (add 10,000 data), observe that during the process of adding data, when the main database is killed, switch from the database to the main database mode (Switch by heartbeat mode (referring to fast switching speed) ), check whether the data is lost during this process, and whether the success rate is 99.9%. In the word test process, this method of stopping the main library and restarting it can be operated 1-2 times.

                Question: What is virtual IP flapping?

        The state requires that important systems of general banks, database systems such as electricity and telecommunications need to have off-site backup disaster recovery mechanisms in the Central Plains, Shanghai, Beijing and other regions. There will be a data backup disaster recovery mechanism between the two cities to prevent losses caused by wars, natural disasters and other factors. The data synchronization methods of data centers between two cities can be divided into asynchronous, synchronous, semi-synchronous and asynchronous methods.

        The development path of performance test engineer: non-functional test ( if the performance meets the requirements of the index, go to a deeper level, ) ( content: high reliability ( case: during cluster deployment, when the host is down, the DBA writes the jump) Mechanism, whether it can be used. ), high availability ( case: when the cluster is deployed, the data can interact normally during the downtime startup process. ), security ( case: database full permission control, database external port confidentiality (modify mysql default port) , to prevent malicious attacks), control system open ports, etc. ), high-maintenance test ( case: restart the host when it is disconnected and restarted, whether it can ensure data recovery and whether data is lost. ) )

Second, the characteristics of the database server

2.1 Database management functions

        Including system configuration and management , data access and update management , data integrity management and data security management .

2.2 Database query and operation functions

        包括数据库检索修改

2.3 数据库管理功能

        包括数据引入引出管理数据库结构维护数据恢复功能以及性能监测

2.4 数据库管理功能

        由于在同一时间内,访问数据库的用户不止一个,所以数据库服务器必须支持并行运行机制,处理多个事件同时发生。

三、数据库分类

3.1 关系型数据库

        以二维表结构存储数据的数据库属于关系型数据库。

        关系型数据库最大的特点是事务的一致性,传统的关系型数据库读写操作都是事务的。具有ACID的特点,这个特性使得关系型数据可以用于几乎所有对一致性有要求的系统中,如典型的银行系统

                主流的关系型数据库有:ORACLE、MySQL、Postgresql、DB2、SQL Server。

                Postgresql推荐书籍: 威长松译,数据架构师的postgresql修炼、高效设计、开发与维护数据库应用[M]. 机械工程出版社, 2016.

3.1.1 电商系统使用的数据库类型

一号店JD
        使用Oracle+MySQL的混合体系,核心使用Oracle一体机(一台Oracle Exadata X5有24T内存,576核CPU,价格达几千万到上亿人民币)

苏宁易购
        是IBM一手打造的技术团队和技术体系,使用的是DB2、MySQL和Oracle的混合体系。

携程旅行
        .NET技术为主,所以是一般SQLServer为主,MySQL为辅的混合体系。

唯品会
        也是MySQL和Oracle的混合体系。

3.2 非关系型数据库

        以非二维表结构存储数据的数据库属于非关系型数据库。

        非关系型数据库是传统关系型数据库功能的阉割版本,但其性能较高。严格来说,非关系性数据库并不是不一种数据库,而是一种数据结构化存储方式的集合。但需要注意的是对于数据的持久存储,尤其是海量数据的持久存储,还是需要一种关系型数据库

        在使用非关系性数据库的过程中,典型的应用场景是,把用户信息定期从关系型数据库中迁移到非关系性数据库中,以提高数据登录的速度。

                主流的非关系型数据库有:ORACLE、MySQL、Postgresql、DB2、SQL Server,具体分类如下表所示。

数据库类型 数据库
键值存储数据库 Redis
Memcached
文档存储数据库 MongoDB
CouchDB
列存储数据库 HBASE
CASSNDRA

        一般的网站,用户请求到达Nginx后,在缓存数据库(Redis等)中捞取数据,若捞取到数据直接返回到前端,如果缓存数据库没有,通过Nginx将请求分发到Tomcat服务器,调用Tomcat服务器的应用实例,在MySQL中查询数据,将查询到的数据返回前端。一般而言,对于存储在缓存服务器中都是一些静态分析,以及用户信息等,缓存服务器可以定期将用户信息从MySQL中抽取到缓存服务器中,提高用户的登录速度

3.3 关系型数据库和非关系型数据库之间比对

3.3.1 非关系型数据库的优势

① 性能

        非关系性数据库(NoSQL)是基于键值对的,可以想象成表中主键和值的对应关系,而且不需要经过SQL层的解析,所以性能非常高。

② 可扩展性

        由于NoSQL性数据库是基于键值对的形式存储,数据之间没有耦合性,所以非常容易水平扩展。

3.3.2 关系型数据库的优势

① 复杂查询

        非关系性数据库(NoSQL)是基于键值对的,可以想象成表中主键和值的对应关系,而且不需要经过SQL层的解析,所以性能非常高。

② 事务支持

        使得对于安全性能很高的数据访问他要求得以实现。

3.3.3 案例:Mongodb和MySQL之间比对

比对点 Mongodb MySQL
数据库模型 非关系性 关系型
存储方式 虚拟化+持久化 不同的引擎有不同的存储方式
查询语句 独特的 Mongodb 查询方式 传统的SQL语句
架构特点 可以通过副本集,以分片来实现可用 常见的有单点,M-S,MHA,MMM,cluster等架构方式
数据处理方式 基于内存,将热数据存在物理内存中,从而达到高速读写 不同的引擎有用其自己的特点
成熟度 新兴数据库,成熟度较低 拥有较为成熟的体系,成熟度高
广泛度 NoSQL数据库中,Mongdb是较为完善的BD之一,使用人群在不断增加 开源数据库份额不断增加,MySQL的份额也在持续增长

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324500317&siteId=291194637