Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to restore some tables on slave by Mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how Mysql restores certain tables on slave. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The main library has been simulating the insertion of data

[root@node1 ~] # vi tt.sh

#! / bin/bash

For ((item1witi stop slave

Query OK, 0 rows affected (0.00 sec)

two。 The main library backs up the tables that need to be restored

[root@node1] # mysqldump-uroot-pESBecs00-- master-data=2 hd test2 > test2.sql

[root@node1 ~] # more test2.sql

-- MySQL dump 10.13 Distrib 5.5.50, for Linux (i686)

--

-- Host: localhost Database: hd

-

-- Server version 5.5.50-log

/ * 40101 SET @ OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT * /

/ * 40101 SET @ OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS * /

/ * 40101 SET @ OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION * /

/ * 40101 SET NAMES utf8 * /

/ * 40103 SET @ OLD_TIME_ZONE=@@TIME_ZONE * /

/ * 40103 SET TIME_ZONE='+00:00' * /

/ * 40014 SET @ OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 * /

/ * 40014 SET @ OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 * /

/ * 40101 SET @ OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' * /

/ * 40111 SET @ OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 * /

--

-- Position to start replication or point-in-time recovery from

--

-- CHANGE MASTER TO MASTER_LOG_FILE='on.000001', MASTER_LOG_POS=38848;-- be sure to turn on master-data for backup point information.

--

-- Table structure for table `test2`

--

3. Restore from the library to the specified point

Mysql > start slave until master_log_file='on.000001',master_log_pos=38848

Query OK, 0 rows affected, 1 warning (0.00 sec)

-this step is mainly to synchronize the data generated by other tables during the period from disconnecting the slave to backing up the table

Until slq-thread is no, all errors during this period can be skipped, using the following command

Stop slave;set global sql_slave_skip_counter=1;start slave

4 Import backup files on the slave machine

[root@node2] # mysql-uroot-pESBecs00 hd select * from test1

| | 406 | chen406 |

+-+ +

406 rows in set (0.00 sec)-the quantity is the same and the data is not lost

Thank you for reading! This is the end of the article on "how to restore some tables on slave by Mysql". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report