mysql5.5主从同步配置(semi_sync)
好久不折腾mysql主从了,发现5.5交之前的版本,配置上有些变化,趁着夜深人静,重温一下,顺便简单记录一下配置过程。 主从同步 master端配置 修改 my.cnf 文件 12345678910 vim /etc/my.cnf[mysqld]server-id = 1log-bin = mysql-binbinlog_format = mixede
好久不折腾mysql主从了,发现5.5交之前的版本,配置上有些变化,趁着夜深人静,重温一下,顺便简单记录一下配置过程。
主从同步
master端配置
- 修改
my.cnf
文件
1 2 3 4 5 6 7 8 9 10 Copy after login Copy after login Copy after login | vim /etc/my.cnf [mysqld] server-id = 1 log-bin = mysql-bin binlog_format = mixed expire-logs-days = 7 binlog-do-db = luxtarget binlog-ignore-db = mysql replicate-do-db = luxtarget replicate-ignore-db = mysql Copy after login Copy after login |
新建授权复制用户
1 2
Copy after logingrant replication slave on *.* to 'slave'@'xxx.xxx.xxx.xxx' identified by 'slave'; flush privileges;
Copy after login重启mysql
1
Copy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginservice mysqld restart
Copy after loginCopy after loginCopy after loginCopy after login锁定数据库,将数据打包并拷贝至slave
1
Copy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginflush tables with read lock;
Copy after login查看master上二进制日志情况,记录
File
与Position
1
Copy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginshow master status;
Copy after login当数据打包拷贝完毕,解除锁定;
1
Copy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginublock tables;
Copy after login当数据较大时,将数据打包备份比使用mysqldump导入时效率更高
slave端配置
修改
my.cnf
文件1 2 3 4 5 6 7 8 9 10
Copy after loginCopy after loginCopy after loginvim /etc/my.cnf [mysqld] server-id = 2 log-bin = mysql-bin binlog_format = mixed expire-logs-days = 7 binlog-do-db = luxtarget binlog-ignore-db = mysql replicate-do-db = luxtarget replicate-ignore-db = mysql
Copy after login重启mysql
1
Copy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginservice mysqld restart
Copy after loginCopy after loginCopy after loginCopy after login将从master拷贝来的数据导入slave
连接master开始同步
1 2 3 4 5
Copy after loginchange master to master_host='xxx.xxx.xxx.xxx',master_user='slave',master_password='slave',master_log_file='master-bin.xxxxxx,master_log_pos=xxx; start slave; show slave status\G;
Copy after login当Slave_IO_Running与Slave_SQL_Running的状态都为Running时即可。
半同步配置
master端配置
安装mysql半同步插件
1 2 3
Copy after loginINSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so'; SET GLOBAL rpl_semi_sync_master_enabled = 1; SET GLOBAL rpl_semi_sync_master_timeout = 1000;
Copy after login修改
my.cnf
文件1 2 3 4
Copy after loginCopy after loginvim /etc/my.cnf [mysqld] rpl_semi_sync_master_enabled=1 #启用半同步 rpl_semi_sync_master_timeout=1000 #超时时间为1s
Copy after login重启mysql
1
Copy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginservice mysqld restart
Copy after loginCopy after loginCopy after loginCopy after login
slave端配置
安装mysql半同步插件
1 2 3 4
Copy after loginCopy after loginINSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so'; SET GLOBAL rpl_semi_sync_slave_enabled = 1; STOP SLAVE IO_THREAD; START SLAVE IO_THREAD;
Copy after login修改
my.cnf
文件1
Copy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginrpl_semi_sync_slave_enabled=1 #启用半同步复制
Copy after login重启mysql
1
Copy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginCopy after loginservice mysqld restart
Copy after loginCopy after loginCopy after loginCopy after login
检查配置
master
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Copy after loginSHOW GLOBAL STATUS LIKE 'rpl_semi%'; +--------------------------------------------+-------+ | Variable_name | Value | +--------------------------------------------+-------+ | Rpl_semi_sync_master_clients | 1 | | Rpl_semi_sync_master_net_avg_wait_time | 0 | | Rpl_semi_sync_master_net_wait_time | 0 | | Rpl_semi_sync_master_net_waits | 0 | | Rpl_semi_sync_master_no_times | 0 | | Rpl_semi_sync_master_no_tx | 0 | | Rpl_semi_sync_master_status | ON | | Rpl_semi_sync_master_timefunc_failures | 0 | | Rpl_semi_sync_master_tx_avg_wait_time | 0 | | Rpl_semi_sync_master_tx_wait_time | 0 | | Rpl_semi_sync_master_tx_waits | 0 | | Rpl_semi_sync_master_wait_pos_backtraverse | 0 | | Rpl_semi_sync_master_wait_sessions | 0 | | Rpl_semi_sync_master_yes_tx | 0 | +--------------------------------------------+-------+ 14 rows in set (0.00 sec)
Copy after loginslave
1 2 3 4 5 6 7
Copy after loginmysql> SHOW GLOBAL STATUS LIKE 'rpl_semi%'; +----------------------------+-------+ | Variable_name | Value | +----------------------------+-------+ | Rpl_semi_sync_slave_status | ON | +----------------------------+-------+ 1 row in set (0.01 sec)
Copy after login
好久不折腾mysql主从了,发现5.5交之前的版本,配置上有些变化,趁着夜深人静,重温一下,顺便简单记录一下配置过程。
主从同步
master端配置
- 修改
my.cnf
文件
1 2 3 4 5 6 7 8 9 10 Copy after login Copy after login Copy after login | vim /etc/my.cnf [mysqld] server-id = 1 log-bin = mysql-bin binlog_format = mixed expire-logs-days = 7 binlog-do-db = luxtarget binlog-ignore-db = mysql replicate-do-db = luxtarget replicate-ignore-db = mysql Copy after login Copy after login |
本文出自:http://mayiwei.com/, 原文地址:http://mayiwei.com/2014/02/22/mysql55-master-slave/, 感谢原作者分享。

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

Title: The working principle and configuration method of GDM in Linux systems In Linux operating systems, GDM (GNOMEDisplayManager) is a common display manager used to control graphical user interface (GUI) login and user session management. This article will introduce the working principle and configuration method of GDM, as well as provide specific code examples. 1. Working principle of GDM GDM is the display manager in the GNOME desktop environment. It is responsible for starting the X server and providing the login interface. The user enters

When you find that one or more items in your sync folder do not match the error message in Outlook, it may be because you updated or canceled meeting items. In this case, you will see an error message saying that your local version of the data conflicts with the remote copy. This situation usually happens in Outlook desktop application. One or more items in the folder you synced do not match. To resolve the conflict, open the projects and try the operation again. Fix One or more items in synced folders do not match Outlook error In Outlook desktop version, you may encounter issues when local calendar items conflict with the server copy. Fortunately, though, there are some simple ways to help

PyCharm is a powerful integrated development environment (IDE), and PyTorch is a popular open source framework in the field of deep learning. In the field of machine learning and deep learning, using PyCharm and PyTorch for development can greatly improve development efficiency and code quality. This article will introduce in detail how to install and configure PyTorch in PyCharm, and attach specific code examples to help readers better utilize the powerful functions of these two. Step 1: Install PyCharm and Python

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

How to configure a workgroup in Win11 A workgroup is a way to connect multiple computers in a local area network, which allows files, printers, and other resources to be shared between computers. In Win11 system, configuring a workgroup is very simple, just follow the steps below. Step 1: Open the "Settings" application. First, click the "Start" button of the Win11 system, and then select the "Settings" application in the pop-up menu. You can also use the shortcut "Win+I" to open "Settings". Step 2: Select "System" In the Settings app, you will see multiple options. Please click the "System" option to enter the system settings page. Step 3: Select "About" In the "System" settings page, you will see multiple sub-options. Please click

Title: How to configure and install FTPS in Linux system, specific code examples are required. In Linux system, FTPS is a secure file transfer protocol. Compared with FTP, FTPS encrypts the transmitted data through TLS/SSL protocol, which improves Security of data transmission. In this article, we will introduce how to configure and install FTPS in a Linux system and provide specific code examples. Step 1: Install vsftpd Open the terminal and enter the following command to install vsftpd: sudo

DRBD (DistributedReplicatedBlockDevice) is an open source solution for achieving data redundancy and high availability. Here is the tutorial to install and configure DRBD on CentOS7 system: Install DRBD: Open a terminal and log in to the CentOS7 system as administrator. Run the following command to install the DRBD package: sudoyuminstalldrbd Configure DRBD: Edit the DRBD configuration file (usually located in the /etc/drbd.d directory) to configure the settings for DRBD resources. For example, you can define the IP addresses, ports, and devices of the primary node and backup node. Make sure there is a network connection between the primary node and the backup node.

MyBatisGenerator is a code generation tool officially provided by MyBatis, which can help developers quickly generate JavaBeans, Mapper interfaces and XML mapping files that conform to the database table structure. In the process of using MyBatisGenerator for code generation, the setting of configuration parameters is crucial. This article will start from the perspective of configuration parameters and deeply explore the functions of MyBatisGenerator.
