Database optimization, database high availability (HA) and MYCAT agent

Time:2021-8-10

Database optimization

1、 Database synchronization

1. Database cold backup
Store the database files manually and regularly
Disadvantages: (1) low efficiency

(2) Possible loss of data

Reason: database cold backup is the last effective means for the company to recover data

2. Database hot backup

Backup principle:
(1) When the database is modified, the modified information will be imported into the binary log file (the binary file is closed by default)
(2) When there is data in the binary log file, the database will read the binary file information from the library through the IO thread
(3) The IO thread writes the read data to the relay log
(4) The SQL thread writes the files in the relay log to the slave database, and finally realizes the master-slave synchronization of the database
The core is the binary configuration file
Database optimization, database high availability (HA) and MYCAT agent

Modify database master database configuration

1. Construction strategy:
129 as the master library and 130 as the slave library

2. Modify binary log file
1) Edit binary location
Database optimization, database high availability (HA) and MYCAT agent
2) Modify binary file contents
Database optimization, database high availability (HA) and MYCAT agent
3) Restart the database and check whether the binary log file is valid
Database optimization, database high availability (HA) and MYCAT agent
4) Modify database configuration
Database optimization, database high availability (HA) and MYCAT agent
Restart the database and check the binary log
Database optimization, database high availability (HA) and MYCAT agent
5) Realize database master-slave synchronization
a. Determine main library status
Database optimization, database high availability (HA) and MYCAT agent
6) Configure master-slave mount
Database optimization, database high availability (HA) and MYCAT agent
7) Database master-slave test
Database optimization, database high availability (HA) and MYCAT agent

Achieve database read / write separation / load balancing

Database optimization, database high availability (HA) and MYCAT agent

MYCAT agent

Database optimization, database high availability (HA) and MYCAT agent

Key characteristics

Database optimization, database high availability (HA) and MYCAT agent

Recommended Today

The selector returned by ngrx store createselector performs one-step debugging of fetching logic

Test source code: import { Component } from ‘@angular/core’; import { createSelector } from ‘@ngrx/store’; export interface State { counter1: number; counter2: number; } export const selectCounter1 = (state: State) => state.counter1; export const selectCounter2 = (state: State) => state.counter2; export const selectTotal = createSelector( selectCounter1, selectCounter2, (counter1, counter2) => counter1 + counter2 ); // […]