关于MySQL主从复制中UUID的警告信息
最近在查看MariaDB主从复制服务器 Master 的错误日志时看到很多条警告信息,都是提示 UUID()函数不安全,可能 Slave 产生的值和 M
最近在查看MariaDB主从复制服务器 Master 的错误日志时看到很多条警告信息,都是提示 UUID()函数不安全,可能 Slave 产生的值和 Master不一致, 警告信息大致如下:
140522 15:11:10 [Warning]
Unsafe statement written to the binary log
using statement format since BINLOG_FORMAT = STATEMENT.
Statement is unsafe because it uses a system function
that may return a different value on the slave.
Statement:
insert into t_user(userId,userName) values(uuid(),'FunYoung')
大致翻译为中文如下所示:
140522 15:11:10 [警告]
因为使用的格式是 BINLOG_FORMAT = STATEMENT,
所以写入到二进制日志中的语句可能是不安全的.
语句不安全是因为使用了一个系统函数,
在 slave从服务器上执行可能会生成不一致的数值.
语句如下:
insert into t_user(userId,userName) values(uuid(),'FunYoung')
看样子是说,因为slave的 UUID() 函数产生的值可能和Master的不一致,所以使用 BINLOG_FORMAT = STATEMENT这种日志格式是不安全的。
MySQL主从复制配置
在网上找了一些资料,显示 5.0 版本是绝对有问题的,怎么办呢? 要么修改实现,比如在应用层生成 UUID,要么就采用基于行,而不是基于语句的二进制日志格式。
据说 5.0 以后是不一定的,,翻看了一些官方文档,好像 5.6 版本修正了这个问题。 参考链接: 22 Changes in MySQL 5.6.0
还有个是09年的文档,说是当时有这个问题 : https://drupal.org/node/502622
还有一个更详细的文章: Beware of MySQL 5.6 server UUID when cloning slaves
我们使用的是MariaDB5.5,应该是兼容 MySQL5.5吧,经排查这个问题系统已经自己解决了。
MariaDB [(none)]> select version();
+--------------------+
| version() |
+--------------------+
| 5.5.34-MariaDB-log |
+--------------------+
1 row in set (0.00 sec)
如果你遇到这个问题,假如还可以升级数据库系统,那就升级到最新版那就没事了。
如果不能升级DMBS,那么就需要在应用层,或者采用 基于行的复制方式 了。
更多详情见请继续阅读下一页的精彩内容:

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

Data backup and failure recovery: Discussion on the importance of MySQL master-slave replication in cluster mode Introduction: In recent years, with the continuous growth of data scale and complexity, database backup and failure recovery have become particularly important. In distributed systems, MySQL master-slave replication is widely used in cluster mode to provide high availability and fault tolerance. This article will explore the importance of MySQL master-slave replication in cluster mode and give some code examples. 1. Basic principles and advantages of MySQL master-slave replication MySQL master-slave replication is a general

Optimizing database performance: The best way to use MySQL master-slave replication in cluster technology Abstract: With the rapid development of the Internet, database performance issues have become the focus of various enterprises and organizations. MySQL master-slave replication technology plays an important role in solving database performance bottlenecks. This article will introduce the concepts and principles of MySQL master-slave replication, as well as the best use methods in cluster technology, to help readers optimize database performance. 1. Introduction As the amount of data continues to increase, database performance problems have become increasingly prominent. How to optimize numbers

Cope with high concurrency with ease: Analysis of the performance advantages of MySQL master-slave replication as a cluster technology. With the rapid development of the Internet, user visits to websites and applications have shown an explosive growth trend. In this high-concurrency situation, how to ensure system stability and performance has become an important task for every developer and system administrator. In databases, MySQL master-slave replication technology is widely used and has become one of the effective solutions to deal with high concurrency. This article will explore the performance advantages of MySQL master-slave replication as a cluster technology. first

Decrypting MySQL master-slave replication: Revealing its key implementation mechanism in cluster mode Introduction: In modern database systems, high availability and flexibility of data are very important. As an open source relational database management system, MySQL has a wide range of applications in meeting user needs. MySQL's master-slave replication is a very critical part of the MySQL database architecture and is used to achieve data backup and high availability. This article will focus on revealing the key implementation mechanism of MySQL master-slave replication, especially in cluster mode.

Is MySQL master-slave replication a cluster technology or a load balancing technology? Summary of analysis and differences: MySQL master-slave replication is a database replication technology used to synchronize database data on multiple servers. This article will analyze and distinguish the differences between MySQL master-slave replication, cluster technology and load balancing technology in terms of technical principles, application scenarios and functional characteristics. Introduction: In modern Internet applications, high availability and scalability of databases are crucial. MySQL master-slave replication is one of the common solutions, however,

Detailed explanation of the functions and advantages of MySQL master-slave replication in cluster technology Introduction MySQL is a powerful relational database management system that is widely used in various large-scale websites and applications. As the amount of data increases and access requests increase, the pressure on a single MySQL server gradually increases. In order to improve the performance and reliability of the database, people begin to adopt cluster technology, among which MySQL master-slave replication is one of the commonly used technologies. means. MySQL master-slave replication principle MySQL master-slave replication refers to the

Tapping into the cluster technology potential of MySQL master-slave replication: Comparative evaluation of open source solutions and commercial solutions. With the continuous development of Internet business and the increasing amount of data, the demand for database cluster solutions has become increasingly strong. MySQL master-slave replication technology just meets this demand. It can process the read and write operations of the database separately on multiple nodes, improving the read performance and availability of the database. This article will explore the potential of cluster technology in MySQL master-slave replication, and conduct a comparative evaluation of open source solutions and commercial solutions.

With the rapid development of the Internet, the amount of data in application systems is increasing, and the requirements for database performance and reliability are also getting higher and higher. As one of the most commonly used open source relational databases, MySQL has high performance and stability and is widely used in various enterprise-level applications. As a commonly used data replication solution, MySQL master-slave replication can improve data reliability and read and write performance, and is widely used in large-scale data applications. The cluster feature of MySQL master-slave replication refers to synchronizing the data of the master database through the replication mechanism.
