MYSQL dual-machine hot standby experience

 

1. The main purpose of MySQL dual-system hot backup is to use the database of the slave server to actively access the database of the master server for data backup. It can be set to allow only the IP of the slave server to access and backup the database of the master server to provide security;

 

2. It is best to use the same version of the database for the two servers to avoid version inconsistency;

 

3. Generally, database servers are backed up locally, but if the hard disk of the server is damaged, the data is lost, or the server is stolen, which is irreversible for the company. Dual-system hot backup allows data to be backed up to a remote server to avoid this from happening. At the same time, once the master server goes down, the database administrator can switch the application's access to the slave server, and then check the problem of the master server.

 

4. Use keepalived to realize virtual routing. Dual-system hot backup does not mean that two servers are providing services. When one server fails, the other server can take over, and the switching time is very short. The working principle of Keepalived is VRRP ( virtual Router Redundancy Protocol ) virtual routing protocol. There are two important concepts in VRRP : VRRP router and virtual router, master router and backup router. A VRRP router is a router that runs VRRP , a physical entity, and a virtual router is a logical concept created by the VRRP protocol. A group of VRRP routers work together to form a virtual router. There is an election mechanism in Vrrp , which is used to select the route that provides services, that is, the master route, and the others become backup routes. When the master route fails, a master route will be re-elected from the backup route to continue working to ensure uninterrupted service.           

 

During this process, a VIP (Virtual IP ) will appear, and the application server or MySQL client can connect to the MySQL database through the VIP . When the master server goes down, keepalived will automatically switch to the slave server to achieve automatic master-slave switchover. Deploying an application is to configure VIP to share database resources.

 

Note that when the crash is restored, keepalived must be restarted , otherwise the VIP cannot be automatically switched back.

 

Guess you like

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