mysql-tabellen_in_einem_pxc-cluster_pruefen

MySQL-Tabellen in einem PXC-Cluster prüfen

Installation des Percona-Toolkits:

> apt install percona-toolkit

Dieser DB haben wir in diesem Beispiel installiert:

> dpkg -l | fgrep -- -server | egrep 'mysql|maria|xtra'
ii  mysql-community-server                5.7.30-1ubuntu16.04                             amd64        MySQL Server

Dieser Aufruf prüft die lokale Datenbank:

root@dbmaster:~# pt-table-checksum

Wenn man mehr als eine DB auf einem Host laufen lässt, dann mußt Du noch den Port mit angeben:

root@dbmaster:~# pt-table-checksum -P 3369
Diffs cannot be detected because no slaves were found.  Please read the --recursion-method documentation for information.

Leider kann er aber nicht automatisch die Slave-Hosts finden. Wenn wir in der Doku nachschauen, was die Option --recursion-method für Werte annehmen kann, dann steht da u.a. hosts aber das ist auch schon die Standard-Einstellung. Also brauchen wir diese Option nicht extra zu setzen.

Weil es in der Doku keine Option für die Liste der Slave-Hosts gibt, werden wir hier noch zusätzlich den Master-Host angeben:

root@dbmaster:~# pt-table-checksum -h 127.0.0.1 -P 3369
Cannot connect to P=3369,h=db3369knoten02
Cannot connect to P=3369,h=db3369knoten03
Diffs cannot be detected because no slaves were found.  Please read the --recursion-method documentation for information.

Jetzt wird auch klar, warum er die Slave-Hosts nicht finden konnte. Er nimmt aus der Ansicht von SHOW SLAVE STATUS nicht (wie erwartet) den Eintrag für Master_Host: sondern den für Channel_Name:, was für mich keinen Sinn ergibt!

Also müssen wir für die Kanalnamen in der /etc/hosts jeweils noch IPs hinterlegen:

root@dbmaster:~# echo "10.10.1.12 db3369knoten02" >> /etc/hosts
root@dbmaster:~# echo "10.10.1.13 db3369knoten03" >> /etc/hosts
root@dbmaster:~# pt-table-checksum -h 127.0.0.1 -P 3369
Cannot connect to P=3369,h=db3369knoten01
Cannot connect to P=3369,h=db3369knoten01

Klar, er versucht natürlich auch die Einträge für die Channel_Name: von den Slave-Hosts zu kontaktieren, also sich selbst:

root@dbmaster:~# echo "10.10.1.11 db3369knoten01" >> /etc/hosts
root@dbmaster:~# pt-table-checksum -h 127.0.0.1 -P 3369
Replica tcdb09 has binlog_format ROW which could cause pt-table-checksum to break replication.  Please read "Replicas using row-based replication" in the LIMITATIONS section of the tool's documentation.  If you understand the risks, specify --no-check-binlog-format to disable this check.
Replica tcdb08 has binlog_format ROW which could cause pt-table-checksum to break replication.  Please read "Replicas using row-based replication" in the LIMITATIONS section of the tool's documentation.  If you understand the risks, specify --no-check-binlog-format to disable this check.

Nun scheint es ein Problem zu sein, dass wir binlog_format=ROW verwenden. Allerdings werden wir das nicht ändern.

Also müssen wir dafür sorgen, dass das übergangen wird:

root@dbmaster:~# pt-table-checksum -h 127.0.0.1 -P 3369 --no-check-binlog-format
08-07T12:10:27 Replication filters are set on these hosts:
  tcdb09
    slave_skip_errors = 1032,1062,1507,1517
    replicate_wild_ignore_table = specialCharFilter.%
  tcdb08
    replicate_wild_ignore_table = specialCharFilter.%
    slave_skip_errors = 1032,1062,1507,1517
Please read the --check-replication-filters documentation to learn how to solve this problem. at /usr/bin/pt-table-checksum line 9644.

In der Doku steht, dass die Prüfung sofort abgebrochen wird, wenn Replikations-Filter gefunden werden.

Also sagen wir ihm, dass er trotzdem weiter machen soll:

root@dbmaster:~# pt-table-checksum -h 127.0.0.1 -P 3369 --no-check-binlog-format --no-check-replication-filters
            TS ERRORS  DIFFS     ROWS  CHUNKS SKIPPED    TIME TABLE
08-07T12:13:45      0      0        0       1       0   0.283 mysql.columns_priv
08-07T12:13:45      0      0        5       1       0   0.286 mysql.db
08-07T12:13:45      0      0        2       1       0   0.283 mysql.engine_cost
08-07T12:13:45      0      0        0       1       0   0.034 mysql.event
08-07T12:13:45      0      0        0       1       0   0.041 mysql.func
08-07T12:13:45      0      1       19       1       0   0.035 mysql.gtid_executed
08-07T12:13:45      0      0       40       1       0   0.031 mysql.help_category
08-07T12:13:46      0      0      676       1       0   0.281 mysql.help_keyword
08-07T12:13:46      0      0     1330       1       0   0.287 mysql.help_relation
08-07T12:13:46      0      0      634       1       0   0.290 mysql.help_topic
08-07T12:13:47      0      0        0       1       0   0.285 mysql.ndb_binlog_index
08-07T12:13:47      0      0        1       1       0   0.283 mysql.plugin
08-07T12:13:47      0      0       48       1       0   0.286 mysql.proc
08-07T12:13:47      0      0        0       1       0   0.286 mysql.procs_priv
08-07T12:13:48      0      0        1       1       0   0.285 mysql.proxies_priv
08-07T12:13:48      0      0        6       1       0   0.283 mysql.server_cost
08-07T12:13:48      0      0        0       1       0   0.291 mysql.servers
08-07T12:13:49      0      0        2       1       0   0.284 mysql.tables_priv
08-07T12:13:49      0      0        0       1       0   0.031 mysql.time_zone
08-07T12:13:49      0      0        0       1       0   0.283 mysql.time_zone_leap_second
08-07T12:13:49      0      0        0       1       0   0.031 mysql.time_zone_name
08-07T12:13:49      0      0        0       1       0   0.029 mysql.time_zone_transition
08-07T12:13:49      0      0        0       1       0   0.281 mysql.time_zone_transition_type
08-07T12:13:50      0      0       10       1       0   0.290 mysql.user
08-07T12:13:50      0      0        6       1       0   0.287 sys.sys_config

ACHTUNG!!! Zu beachten ist auch, dass in der pt-table-checksum - Dokumentation steht, dass in der Standard-einstellung nur max die ersten 1000 Zeilen für max. 0,5 Sekunden je Chunk überprüft werden. Es wird also nicht der komplette DB-Inhalt zwischen den Replikationspartnern verglichen! Dieses Verhalten kann aber mit Hilfe von Parametern verändert werden. Allerdings gibt es keine Option für soetwas wie "Alles".

/home/http/wiki/data/pages/mysql-tabellen_in_einem_pxc-cluster_pruefen.txt · Zuletzt geändert: von manfred