


This article mainly introduces to you the relevant information about the implementation of some tables of dual-master synchronization in MySQL 5.7. The article introduces it in detail through the example code. It has certain reference learning value for everyone to learn or use mysql. Friends who need it Let’s learn with the editor below.
Preface
Recently encountered a demand. Due to the company's own business, some tables between the two databases need real-time bidirectional data synchronization. And the downtime of any one of the databases will not affect the other database. Record your own technical research here for later use in reconstruction. Not much to say below, let’s take a look at the detailed introduction.
Install MySQL5.7
It is recommended to go directly to the official website and download the yum source to install, after all, it is safe and easy to install.
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm yum -y install mysql57-community-release-el7-11.noarch.rpm yum -y install mysql-server # 安装MySQL5.7 systemctl start mysqld # 启动MySQL
Configuring dual master
my.cnf configuration
This is just a simple dual master The configuration has not been optimized in database-related aspects. If optimization is needed, you can chat privately.
The configuration of MySQL1 is as follows
[mysqld] vim /etc/my.cnf datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid skip_name_resolve=ON #设置简单密码 validate_password_policy=0 validate_password_length=1 ###主配置 log_bin=bin_log server-id=1 binlog-do-db=ziyun # 允许从复制的哪一个库 slave_parallel_type='logical_clock' #设置复制类型为 LOGICAL_CLOCK slave_parallel_workers=4 #设置并行数量为 4 ###从配置 relay-log=relay-bin relay-log-index=relay-bin.index replicate-do-db=ziyun # 允许复制主服务的库 replicate-do-table=ziyun.test1 # 允许复制主服务的库的哪一张表 replicate-do-table=ziyun.test2
The configuration of MySQL2 is basically the same as above, just modify one server-id=2
, keep the others unchanged
MySQL command configuration
The following are all configured in the SQL command line interface
Main configuration:
mysql> CREATE USER 'slave'@'192.168.1.100' IDENTIFIED BY '123.com'; mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave'@'192.168.1.100'; # 授权复制的用户和密码 mysql> show master status; +-----------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +-----------------+----------+--------------+------------------+-------------------+ | bin_log.000002 | 8384 | ziyun | | | +-----------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)
From configuration:
mysql> CHANGE MASTER TO -> MASTER_HOST='192.168.1.101', -> MASTER_USER='slave', -> MASTER_LOG_FILE='bin_log.000002', -> MASTER_LOG_POS=8384; Query OK, 0 rows affected, 2 warnings (0.01 sec) mysql> start slave; Query OK, 0 rows affected (0.01 sec) mysql> show slave status\G Slave_IO_Running: Yes Slave_SQL_Running: Yes # 确定以上都为yes,并且无任何报错即可
The same configuration can be done on MySQL2
Dual master Synchronous test
#Here I have previously built a ziyun database on both sides, and built the test1 test2 test3 table. The test results are as follows:
Summarize
The above is the detailed content of Introduction to the process of how to implement dual-master synchronization of partial tables in MySQL5.7. For more information, please follow other related articles on the PHP Chinese website!

一般来说,我们只需要同时使用耳机或者音响的其中一个设备,但是有些朋友反映在win11系统中,遇到了耳机和音响一起响的问题,其实我们可以在realtek面板中将它关闭,就可以了,下面一起来看一下吧。win11耳机和音响一起响怎么办1、首先在桌面上找到并打开“控制面板”2、进入控制面板,在其中找到并打开“硬件和声音”3、然后再找到一个喇叭图标的“Realtek高清晰音频管理器”4、选择“扬声器”再点击“后面板”进入扬声器设置。5、打开之后我们可以看到设备类型,如果要关闭耳机就取消勾选“耳机”,如果要

MySQL是一个非常流行的开源关系型数据库管理系统,广泛应用于各种Web应用、企业系统等。在现代业务的应用场景下,大多数的MySQL数据库需要部署在多台服务器上,以提供更高的可用性和性能,这就需要进行MySQL数据的迁移和同步。本文将介绍如何实现多台服务器之间的MySQL数据迁移和同步。一.MySQL数据迁移MySQL数据迁移指的是将MySQL服务器中的数

win10剪贴板有个非常好用的功能就是跨设备云储存功能,非常的好用可以帮助用户PC设备和手机设备同步复制黏贴。设置的方法非常简单,只要在系统里的剪切板设置就好。win10剪贴板同步到手机1、首先点击左下角的开始,进入设置。2、然后去点击“系统”。3、选择左侧的“剪贴板”。4、最后在右边的“跨设备同步”中点击登录,然后选择手机就好了。

Emmo是一款出色的日常生活记录软件,它提供了智能的记录功能和各种实用工具,帮助你详细记录生活中的点点滴滴。如果你想全面记录每天发生的事情,Emmo绝对是你的不二之选。通过这款软件,你可以在手机上轻松完成每天的日记,而且功能非常全面,满足你的各种需求。那么很多用户们还不清楚emmo日记中究竟该如何同步自己的日记,让大家在不同的设备中都能续写日记,想要了解的玩家们就快来跟着本文继续阅读吧。emmo心情日记怎么同步?1、点击左下角的菜单键2、登录你的账号3、退回到主界面,点击右上角的云朵按钮4、点击

您系统上的 OneDrive 应用程序将所有文件和文件夹存储在云端。但有时用户不希望某些文件或文件夹被存储并占用限制为 5 GB 的 OneDrive 空间而无需订阅。为此,OneDrive 应用程序中有一个设置,允许用户选择要在云上同步的文件或文件夹。如果您也在寻找这个,那么这篇文章将帮助您在 Windows 11 系统的 OneDrive 中选择要同步的文件夹或文件。如何在 Windows 11 的 OneDrive 中选择要同步的某些文件夹注意:确保 OneDrive 应用程序已连接并同步

并发编程中的锁与同步在并发编程中,多个进程或线程同时运行,这可能会导致资源争用和不一致性问题。为了解决这些问题,需要使用锁和同步机制来协调对共享资源的访问。锁的概念锁是一种机制,它允许一次只有一个线程或进程访问共享资源。当一个线程或进程获得锁时,其他线程或进程将被阻止访问该资源,直到锁被释放。锁的类型python中有几种类型的锁:互斥锁(Mutex):确保一次只有一个线程或进程可以访问资源。条件变量:允许线程或进程等待某个条件,然后获取锁。读写锁:允许多个线程同时读取资源,但只允许一个线程写入资

百度云同步盘怎么同步?百度云同步盘中可以选择文件来同步,但是多数的用户不知道如何同步百度云文件,接下来就是小编为用户带来的百度云同步盘同步方法图文教程,感兴趣的用户快来一起看看吧!百度云同步盘怎么同步1、首先进入电脑桌面,右键点击【百度云同步盘】图标,选择【设置】;2、之后展开服务小窗口,切换到【高级设置】页面点击【选择文件夹】;3、最后切换到下图的页面,勾选需要同步的文件点击【确定】即可。

很多小伙伴想把win10电脑日历和自己的苹果手机日历同步,这个该如何解决呢?我们可以通过iCloud账号,分别登陆AppleID,获取密码,再登陆日历的账户解决这个问题,下面一起来看详细的教程吧。win10日历同步iphone的方法1、先打开AppleID的登陆界面,通过双重验证,输入手机的验证码,然后登陆向左2、在安全中选择“生成密码”3、输入密码标签,然后官网就会给你一个密码。将这个密码复制下来(不是你原来登陆iCloud的密码,是一个新的密码)4、打开日历——添加账户——选择iCloud—


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)
