AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题

问题[binlog](dba)

Martin Hope
Sybil
Asked: 2018-06-01 22:35:28 +0800 CST

pt-query-digest --type binlog (percona-toolkit) 使用 MariaDB/Galera 10.1 给出空输出

  • 1

我在 MacBook 上安装的 MariaDB 和 Percona Toolkit 版本:

brew info percona-toolkit
percona-toolkit: stable 3.0.10 (bottled), HEAD
Percona Toolkit for MySQL
https://www.percona.com/software/percona-toolkit/
/usr/local/Cellar/percona-toolkit/3.0.10 (244 files, 8.4MB) *
  Poured from bottle on 2018-05-31 at 09:52:48
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/percona-toolkit.rb
==> Dependencies
Required: mysql ✔, openssl ✔
==> Options
--HEAD
    Install HEAD version

数据库服务器版本:

show global variables like '%version%';
+-------------------------+---------------------------+
| Variable_name           | Value                     |
+-------------------------+---------------------------+
| innodb_version          | 5.6.36-82.1               |
| protocol_version        | 10                        |
| slave_type_conversions  |                           |
| version                 | 10.1.26-MariaDB           |
| version_comment         | Source distribution       |
| version_compile_machine | x86_64                    |
| version_compile_os      | Linux                     |
| version_malloc_library  | system                    |
| version_ssl_library     | OpenSSL 1.0.1f 6 Jan 2014 |
| wsrep_patch_version     | wsrep_25.19               |
+-------------------------+---------------------------+
10 rows in set (0.01 sec)  

有趣的是,为了安装 percona-toolkit,我必须安装 Oracle MySQL,然后改回 MariaDB

brew install mariadb
brew unlink mariadb
brew install percona-toolkit
brew unlink mysql
brew link mariadb

我们将 Galera 集群与基于行的复制一起使用:

show global variables like 'binlog_format';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW   |
+---------------+-------+
1 row in set (0.00 sec)

我做了一个简单的用例:

mysqlbinlog  mysql-bin.0013* > all.sql

pt-query-digest --type binlog all.sql
all.sql:   1% 37:37 remain
(...)
all.sql:  96% 01:23 remain
all.sql:  98% 00:30 remain

# 2417.5s user time, 51.4s system time, 89.16M rss, 4.24G vsz
# Current date: Fri Jun  1 07:42:57 2018
# Hostname: aukVivi0009
# Files: all.sql
# Overall: 0 total, 2.05k unique, 0 QPS, 0x concurrency __________________
# Time range: 2018-05-26 02:00:54 to 2018-05-31 08:05:28
# Attribute          total     min     max     avg     95%  stddev  median
# ============     ======= ======= ======= ======= ======= ======= =======
# Query size        10.68G       6 287.51k  492.88  833.10   1.92k  107.34

# Profile
# Rank        Query ID    Response time Calls       R/Call      V/M   Item
# =========== =========== =========== =========== =========== ===== ======   

为什么输出为空?与 MariaDB不pt-query-digest兼容?binlog格式的变化?任何解决方法?

mariadb binlog
  • 1 个回答
  • 673 Views
Martin Hope
nelaaro
Asked: 2017-07-26 01:23:37 +0800 CST

在 binlog 索引中找不到目标日志,从清除二进制日志 mysqld-relay-bin

  • 0

我正在尝试运行以下内容。

mysql > purge binary logs to 'mysqld-relay-bin.000075';
ERROR 1373 (HY000): Target log not found in binlog index

# cat ./mysqld-relay-bin.index 
/srv/mysql/logs/mysqld-relay-bin.000010
....
/srv/mysql/logs/mysqld-relay-bin.000075
/srv/mysql/logs/mysqld-relay-bin.000076
/srv/mysql/logs/mysqld-relay-bin.000077
/srv/mysql/logs/mysqld-relay-bin.000078
/srv/mysql/logs/mysqld-relay-bin.000079

我该怎么做才能手动清除删除这些中继日志。

MariaDB [(none)]> show slave status;
Empty set (0.00 sec)

MariaDB [(none)]> show master status;
+---------------+-----------+--------------+------------------+
| File          | Position  | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------+-----------+--------------+------------------+
| binary.000141 | 487953618 |              |                  |
+---------------+-----------+--------------+------------------+


ls -lrt /var/lib/mysql/logs/
total 4616604
-rw-rw---- 1 mysql mysql        299 Jun  7 15:04 mysqld-relay-bin.000010
-rw-rw---- 1 mysql mysql        299 Jun  7 15:19 mysqld-relay-bin.000011
-rw-rw---- 1 mysql mysql        299 Jun  7 15:21 mysqld-relay-bin.000012
....
-rw-rw---- 1 mysql mysql        299 Jul 23 01:15 mysqld-relay-bin.000075
-rw-rw---- 1 mysql mysql        299 Jul 23 01:15 mysqld-relay-bin.000076
-rw-rw---- 1 mysql mysql        268 Jul 24 09:17 mysqld-relay-bin.000077

作为我运行的备份脚本的一部分。我每天晚上都刷新日志,这会不会有影响。

复制日志堆积的主服务器。

MariaDB [(none)]> SHOW VARIABLES LIKE 'server_id';  
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id     | 1000  |
+---------------+-------+
1 row in set (0.00 sec)

MariaDB [(none)]> SHOW VARIABLES LIKE '%relay%';
+-----------------------+----------------------------------------+
| Variable_name         | Value                                  |
+-----------------------+----------------------------------------+
| max_relay_log_size    | 1073741824                             |
| relay_log             | /srv/mysql/logs/mysqld-relay-bin       |
| relay_log_basename    | /srv/mysql/logs/mysqld-relay-bin       |
| relay_log_index       | /srv/mysql/logs/mysqld-relay-bin.index |
| relay_log_info_file   | relay-log.info                         |
| relay_log_purge       | ON                                     |
| relay_log_recovery    | OFF                                    |
| relay_log_space_limit | 0                                      |
| sync_relay_log        | 10000                                  |
| sync_relay_log_info   | 10000                                  |
+-----------------------+----------------------------------------+

连接到主站的从站。

MariaDB [(none)]> SHOW VARIABLES LIKE 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id     | 1002  |
+---------------+-------+
1 row in set (0.00 sec)


MariaDB [(none)]>  SHOW SLAVE STATUS\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.21.228.81
                  Master_User: db.replicator
                  Master_Port: 3306
                Connect_Retry: 10
              Master_Log_File: binary.000141
          Read_Master_Log_Pos: 540479720
               Relay_Log_File: mysqld-relay-bin.000358
                Relay_Log_Pos: 540480005
        Relay_Master_Log_File: binary.000141
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 540479720
              Relay_Log_Space: 540480344
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1000
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: No
                  Gtid_IO_Pos: 
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: conservative
1 row in set (0.00 sec)

ERROR: No query specified
mysql binlog
  • 1 个回答
  • 3714 Views
Martin Hope
Omri
Asked: 2017-03-29 01:57:23 +0800 CST

清除 mysql 4 中的旧二进制日志

  • 0

我需要从 mysql 版本 4 中清除二进制日志。我查看了手册,发现语法类似于高级版本:

PURGE MASTER LOGS TO mysql-bin.xxx

但是,当我使用此命令时,出现以下错误:

ERROR 1064 (00000): You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'BINARY LOGS TO 'mysql-bin.xxx'' at line 1

请注意。

mysql binlog
  • 1 个回答
  • 386 Views
Martin Hope
bwizzy
Asked: 2016-09-10 01:40:39 +0800 CST

如何关闭或刷新远程服务器上的二进制日志文件

  • 3

我正在使用mysqlbinlog --stop-never --read-from-remote-server标志将我的二进制日志文件复制到辅助服务器。如果主数据库服务器受到威胁,我想在远程服务器上重放二进制日志,但我在处理“当前”二进制日志时遇到了问题。

使用mysqlbinlog将其转换为 SQL 时,我总是会收到如下错误:

错误:Log_event::read_log_event() 中的错误:'读取错误',data_len:2682,事件_type:2 错误:无法读取偏移量 4426095 处的条目:日志格式错误或读取错误

我假设此问题与此 binlog 文件尚未在主数据库服务器上关闭或刷新有关。flush logs在主数据库服务器上运行后,我的文件没有这个问题。

所以,我的问题是:如果主数据库服务器受到威胁并且我无法运行flush logs,只能访问已复制到远程服务器的二进制日志文件。如何清理、关闭或刷新在数据库中断事件时打开的二进制日志?

mysql binlog
  • 1 个回答
  • 809 Views
Martin Hope
clausavram
Asked: 2016-05-18 03:05:16 +0800 CST

最新二进制日志文件上的部分 mysqlbinlog

  • 1

我正在尝试mysqlbinlog在其中的某个位置对最新的二进制日志文件进行部分处理(尝试仅提取一个查询)。

mysqlbinlog --start-position=1234 --stop-position=1234 /var/lib/mysql/mysql-bin.000021

输出包含:

警告:此二进制日志正在使用或未正确关闭。

我如何强制MySQL开始记录下一个binlog文件(即mysql-bin.000022)并释放原始文件以便我可以使用mysqlbinlog它?

这个问题还有其他解决方案吗?

mysql binlog
  • 2 个回答
  • 1054 Views
Martin Hope
Swaroop Kundeti
Asked: 2014-06-12 11:00:47 +0800 CST

MySQL:6 小时内 30GB 的二进制日志

  • 4

我有一个带有钨复制器的 mysql 主/主设置。我的服务器空间不足,在 6 小时内占用了大约 30G。我不知道如何处理这个。如果有人可以帮助我解决这个问题,那就太好了。

谢谢,斯瓦鲁普。

mysql binlog
  • 2 个回答
  • 3898 Views
Martin Hope
lamp_scaler
Asked: 2013-07-27 00:20:49 +0800 CST

为什么 MySQL bin 日志文件在清除或刷新后仍然存在?

  • 15

我使用了 PURGE BINARY LOGS 和 FLUSH LOGS,但是 mysql 目录仍然包含这些文件:

mysql-bin.000025
mysql-bin.000024
mysql-bin.000023
mysql-bin.000022
mysql-bin.000021
mysql-bin.000020
mysql-bin.000019
mysql-bin.index

有没有使用命令不起作用的原因?这些文件占用了大量空间。我想安全地摆脱它们。

mysql binlog
  • 5 个回答
  • 48406 Views
Martin Hope
user2431104
Asked: 2013-07-09 23:23:52 +0800 CST

mysql binlog文件大小停止增长

  • 2

我制作了一个master( A)-slave( B)-slave( C)模式的MySQL实例作为备份。但是今天当我看到模式是否正常时,我发现A并且B可以。即B可以从 获取 binlog A,但B不会将更新写入其 binlog。所以C不能同步B。

经过一番调查,我看到B新的 binlog 文件是 120 字节,并且 MySQL 的日志中没有任何错误。sql_log_bin是开的。所以我不知道导致问题的原因是什么。我可以补充的是,新的 binlog 的创建时间是我创建mysqldumpon的时间B。mysqldump所以我猜测事件和binlog写事件之间可能有某种关系?希望有人能帮助我,非常感谢。

B的主人状态:

mysql> show master status;
+-----------------+----------+--------------+------------------+-------------------+
| File            | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-----------------+----------+--------------+------------------+-------------------+
| mysqlbin.000016 |      120 |              |                  |                   |
+-----------------+----------+--------------+------------------+-------------------+

B的 binlog 文件大小状态:

ll /data/mysql/
-rw-rw----. 1 mysql mysql        166 7月   7 02:00 mysqlbin.000015
-rw-rw----. 1 mysql mysql        120 7月   7 02:00 mysqlbin.000016
-rw-rw----. 1 mysql mysql        288 7月   7 02:00 mysqlbin.index

B的查询mysqldump语句:

mysqldump --master-data=2 --all-databases --flush-logs --user=xxx  --socket=/tmp/mysqld.sock -A > /tmp/backup.sql
mysql binlog
  • 1 个回答
  • 559 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve