Database (1)

Source: Internet
Author: User

First, what is the dual-machine hot standby?

In order to ensure the stability of the database products, many databases have dual-machine hot standby function, according to the work of switching mode can be divided into: master-Standby mode (Active-standby mode) and dual-host mode (active-active mode), Master-standby means that one server is in the active state of a certain business (that is, the active state) and the other server is in a standby state (that is, the standby state) of that business. The dual-host approach means that two different services are in the primary standby state (that is, the Active-standby and Standby-active states) on two servers respectively.

.2) Implementation Plan

The main three ways to make up the two-machine hot-standby system are: Based on shared storage (disk array), fully redundant mode and replication mode.

(a) A shared storage (disk array)-based approach

Shared storage is primarily provided through a disk array to provide the assurance of data integrity and continuity after switching. The user data is generally placed on the disk array, and when the host is down, the standby continues to obtain the original data from the disk array.

(b) Fully redundant mode

        full redundancy is dual-machine dual storage, based on a single storage of traditional dual-machine hot standby, there is a single point of failure to store the situation, in order to achieve storage redundancy, storage high availability has been more and more accepted by the user. We can see from the understanding that the two-machine hot standby is to solve the server's planned downtime and unplanned downtime solutions, but we can not achieve the planned downtime of storage and unplanned downtime of the server downtime, and storage as a dual-machine hot standby in the only storage of data equipment, Once it fails, it often results in a total crash of the dual-machine hot standby system.                                               & nbsp                          ,         &NB Sp                          ,         &NB Sp                            

(c) Mode of reproduction

In this way, the data synchronization method is used to ensure the data consistency of the primary and standby server.

Resources:

Http://baike.baidu.com/link?url=X9wkYULPkAYBpCGC790BmOTQAwl-3F2oBTdHB1dZSOEjEfn7qup1N-CyI3t8_9YazNTyVcmZple4crIkkJHNMK



Second, what is the database read and write separation

Simply put, the database read and write operations to separate the corresponding database server (generally a master library, multiple Slave library), which can effectively reduce the database pressure, but also to reduce the IO pressure. The primary database provides write operations, which provide read operations from the database. When the primary database is written, the data is synchronized to the database from which the database integrity can be effectively guaranteed.

In short, database read-write separation is divided into 3 parts:

The primary database handles transactional increment, change, and delete operations (INSERT, UPDATE, delete)

Handle Select query operations from the database (multiple slave servers can be load balanced)

database replication is used to synchronize changes caused by transactional operations to the slave database in the cluster.

.2) Classic Applications

Read/write separation is currently applied to many large web sites, such as Ebay,ebay with Oracle, master-slave replication seems to be Quest Share Plex (This is not sure, interested can find their own data to see), we look at ebay's read-write separation diagram,

As we can see from the graph, the control of read/write separation is actually at the application level, and its configuration is at the database level.

. 3) Pros and cons

(1) Poor real-time data: Data is not synchronized to the read-only server, when the data is written to the primary server, the next synchronization to be able to query.

(2) When the data volume is large, the synchronization efficiency is poor: when the single-table data volume is too large, the performance will become poor due to the index, disk IO and other problems.

(3) Connect multiple (at least two) databases at the same time: connect to at least two data databases, the actual read and write operations are done in the program code, and easily cause confusion

(4) Read high reliability and scalability: read-only server, because there is no write operation, will greatly reduce the performance problems such as disk IO, greatly improve efficiency; read-only servers can be load balanced, and the primary database is published to multiple read-only servers to achieve the scalability of read operations.

Note the point:

In the writing operation, considering the uniqueness of the data, the allocation of write data can not use random algorithms, generally using hash mapping. For example, many sites registered when the user name can not be registered, if the use of a random algorithm, user a registered user name Zhangsan, write operations assigned to host A, User B also registered user Zhangsan, write operations assigned to Host B, then it is difficult to control the uniqueness of the data , it is recommended to use hash map, such as a hash rule to uniformly assign a write operation of request Z to host A to avoid such a situation.

Resources:

Http://tech.it168.com/a2012/0110/1300/000001300144_2.shtml



Third, load Balancing

The load Balancing cluster is composed of a set of independent computer systems, which are connected by a regular network or a private network, the routers converge together, each node cooperates, the common load, and the equilibrium pressure, for the client, the whole cluster can be regarded as a stand-alone server with super high performance.

.1) Principle of implementation

To realize the load balancing technology of the database, we must first have a control side that can control the connection database. Here, it truncates the direct connection between the database and the program, which is accessed by all programs, and then by the middle tier to access the database. This allows us to control access to a particular database, and then we can take an effective equalization strategy based on the current load of the database to adjust each connection to which database.

.2) Advantages and disadvantages:
(1) Strong extensibility: When the system to higher database processing speed, as long as simply increase the database server can be extended.
(2) Maintainability: When a node fails, the system will automatically detect the failure and transfer the application of the fault node to ensure the continuous work of the database.
(3) Security: Because the data will be synchronized on multiple servers, you can achieve the redundancy of the data set, through multiple copies of data to ensure security. In addition, it successfully put the database into the intranet to better protect the security of the database.
(4) Ease of use: completely transparent to the application, the cluster exposes an IP
(5) The load cannot be allocated according to the processing capacity of the Web server.
(6) The Load Balancer (control side) failure can cause the entire database system to be paralyzed.

Reference files:

Http://www.cnblogs.com/happyday56/archive/2012/01/11/2319136.html



Iv. Sub-Library, sub-table

In order to deal with the performance bottleneck caused by the increasing of database table and table data, the segmentation database has become a good solution, whose main idea is to divide a database into several different parts into multiple databases, and according to the different business systems, the segmentation can be divided into two types: vertical segmentation and horizontal slicing.

Commonly used sub-library sub-table method:

1.) Horizontal Segmentation

Horizontal slicing is mainly to divide the different data in a table into different libraries, the segmentation rules are more complicated and the maintenance is more complicated than vertical slicing. Commonly used horizontal segmentation scene, if a table has large numbers of fields or more content field, and the probability of these fields are lower, the general recommendation of the table operation, a table is split into two corresponding tables, need to obtain these large numbers or more content fields when querying the sub-table, through this split, can greatly improve efficiency.

.2) Vertical slicing

Vertical segmentation is often the different business modules of the table into a different database, more suitable for business logic clear, low coupling between business and small impact on the system, relatively simple rules, implementation is easy.

In practical applications, the vertical segmentation is often combined with horizontal segmentation, which is often preceded by vertical segmentation, and then horizontally segmented, such as (referring to other blog diagrams).


Resources:

http://blog.csdn.net/bluishglc/article/details/7696085



Database (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.