MARIADB Copy and Pt-table-checksum usage detailed

Source: Internet
Author: User

To copy related files:
Master.info: The information needed to save a link from the server to the primary server, one value per line
Relay-log.info: Text file, save copy location, including files and locations for binary and relay logs

For the security of replication:

Sync_master_info = 1
Sync_relay_log = 1
Sync_relay_log_info = 1
On-line based statement replication:
Based on statement:
Small amount of data, easy to view, practical and strong
Some statements cannot be duplicated precisely: the application of a trigger, stored procedure, etc. can not be accurately duplicated;

Based on line:
Ability to accurately complete replication with triggers, storage, and other code scenarios to achieve almost all replication capabilities and less CPU occupancy
However, it is not possible to determine what SQL statement was executed

Evaluate the consistency of data in master-slave service tables: pt-table-checksum
Typically, the command runs on the primary server, checks for consistency from the server, and if it is inconsistent, manual synchronization
1, back up the primary server data and import data from the server
2,pt-table-sync synchronous, efficient synchronization, but in large amount of data, time consuming

Use examples:

Suppose 10.55.55.55 is the main library, 10.73.73.73 is its from the library, the port is in 3306.

First check:

Ptdebug=1./pt-table-checksum--user=user--password=pass--host=10.55.55.55--port=3306--databases=elink--tables= My_cms_10--recursion-method=processlist
Based on the checksum results, only the 10.73.73.73 from the library to the main library are repaired:

Ptdebug=1./pt-table-sync--execute--replicate percona.checksums--sync-to-master h=10.73.73.73,P=3306,u=user,p= Pass
After you fix it, verify it again. You can perform the first step of the statement.
Check the repair result: Log on to 10.73.73.73, execute the following SQL statement if empty, the repair succeeds:

SELECT * from Percona.checksums where master_cnt <> this_cnt OR master_crc <> this_crc OR ISNULL (MASTER_CRC) & Lt;> ISNULL (THIS_CRC)
In order to improve the data security at the time of replication, set on the primary server (a serious loss of system performance, generally set to 2):

Sync_binlog = 1
Innodb_flush_log_at_trx_commit = 1
Set to 1, there is a serious loss of system performance, general set to 2, if 2, the primary server crash is still likely to cause the server can not get all the binary log events

When the server is crashing, use the Pt-slave-start command to start the
The primary server crash caused the binary log to not be completed, from the need to ignore or use pt-table resynchronization
Ignored from using the following parameters: Sql_slave_skip_counter = 1
such as: Sql_slave_skip_counter 0 set to 1, ignore the loss of
MARIADB [(None)]> show GLOBAL VARIABLES like '%slave% ';
+------------------------------------+------------+
| variable_name | Value |
+------------------------------------+------------+
| Init_slave | |
| Log_slave_updates | Off |
| Rpl_semi_sync_master_wait_no_slave | On |
| Slave_compressed_protocol | Off |
| Slave_exec_mode | STRICT |
| Slave_load_tmpdir | /tmp |
| Slave_max_allowed_packet | 1073741824 |
| Slave_net_timeout | 3600 |
| slave_skip_errors | Off |
| Slave_sql_verify_checksum | On |
| slave_transaction_retries | 10 |
| slave_type_conversions | |
| Sql_slave_skip_counter | 0 |
+------------------------------------+------------+
Rows in Set (0.00 sec)

MARIADB [(None)]>

Is it backward from the server to the primary server:
MARIADB [(none)]> show Slave status\g

Seconds_behind_master:null NULL The thread does not start
seconds_behind_master:0 0 without delay.
If this value is only fluctuating, not bigger, then the problem is not big, if once the value becomes larger, then manually intervene

Installation package: percona-toolkit-2.2.4-1.noarch.rpm
Pt-summary View System Performance

[Root@mysql-slave local]# Pt-summary
# Percona Toolkit System Summary ######################
Date | 2016-02-15 05:50:26 UTC (local tz:pst-0800)
Hostname | Mysql-slave
Uptime | Days, 22:53, 2 users, Load average:0.00, 0.00, 0.00
System | VMware, Inc.; VMware Virtual Platform; Vnone (Other)
Service Tag | VMware-56 4d C9 A4 5b 25-a5 cb D1 3c F5
Platform | Linux
Release | CentOS Release 6.6 (Final)
Kernel | 2.6.32-573.3.1.el6.x86_64
Architecture | CPU = 64-bit, OS = 64-bit
Threading | NPTL 2.12
Compiler | GNU CC version 4.4.7 20120313 (Red Hat 4.4.7-16).
SELinux | Permissive
virtualized | Vmware
# Processor ##################################################
processors | Physical = 1, cores = 1, virtual = 1, hyperthreading = no
Speeds | 1x3092.889
Models | 1xIntel (R) Core (TM) i5-4440 CPU @ 3.10GHz
Caches | 1x6144 KB
# Memory #####################################################
Total | 981.2M
Free | 260.3M
Used | Physical = 720.9M, swap allocated = 1.9G, swap used = 0.0, virtual = 720.9M
Buffers | 154.9M
Caches | 284.2M
Dirty | 364 KB
Usedrss | 205.0M
swappiness | 60
Dirtypolicy | 20, 10
Dirtystatus | 0, 0
Locator Size Speed Form Factor Type type Detail
========= ======== ================= ============= ============= ===========
RAM Slot #0 1024 MB Unknown DIMM DRAM EDO
RAM slot #10 {EMPTY} Unknown DIMM DRAM Unknown
RAM slot #11 {EMPTY} Unknown DIMM DRAM Unknown
RAM slot #9 {EMPTY} Unknown DIMM DRAM Unknown
# mounted Filesystems ########################################
FileSystem Size Used Type Opts mountpoint
/DEV/SDA1 283M 23% Ext4 rw/boot
/dev/sda2 18G 36% ext4 RW/
Tmpfs 491M 0% tmpfs rw,rootcontext= "System_u:object_r:tmpfs_t:s0"/dev/shm
# Disk schedulers and Queue Size #############################
SDA | [CFQ] 128
Sr0 | [CFQ] 128
# Disk Partioning ############################################
Device Type Start End Size
============ ==== ========== ========== ==================
/DEV/SDA Disk 21474836480
/DEV/SDA1 Part 1 39 312560640
/dev/sda2 Part 39 2358 19074424320
/dev/sda3 part 2358 2611 2080995840
# Kernel Inode State #########################################
Dentry-state | 46604 38113 45 0 0 0
File-nr | 960 0 96182
Inode-nr | 40658 93
# LVM Volumes ################################################
Unable to collect information
# LVM Volume Groups ##########################################
Unable to collect information
# RAID Controller ############################################
Controller | No RAID Controller Detected
# Network Config #############################################
Controller | Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (Rev. 01)
FIN Timeout | 60
Port Range | 61000
# Interface Statistics #######################################
Interface rx_bytes rx_packets rx_errors tx_bytes tx_packets
========= ========= ========== ========== ========== ========== ==========
Lo 6000 80 0 6000 80 0
Eth2 30000000 400000 0 4000000 60000 0
# Network Devices ############################################
Device Speed Duplex
========= ========= =========
Eth2 1000mb/s Full
# Network Connections ########################################
Connections from remote IP addresses
192.168.0.3 2
Connections to local IP addresses
192.168.0.100 2
Connections to top ports
22 2
States of connections
Established 2
LISTEN 10
# Top Processes ##############################################
PID USER PR NI virt RES SHR S%cpu%mem time+ COMMAND
1 Root 0 19356 1540 1228 S 0.0 0.2 0:01.43 Init
2 Root 0 0 0 0 S 0.0 0.0 0:00.00 Kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
4 Root 0 0 0 0 S 0.0 0.0 0:04.03 ksoftirqd/0
5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 stopper/0
6 root RT 0 0 0 0 S 0.0 0.0 0:01.84 watchdog/0
7 Root 0 0 0 0 S 0.0 0.0 14:22.34 events/0
8 Root 0 0 0 0 S 0.0 0.0 0:00.00 events/0
9 Root 0 0 0 0 S 0.0 0.0 0:00.00 events_long/0
# Notable processes ##########################################
PID OOM COMMAND
1710-17 sshd
# Simplified and Fuzzy rounded vmstat (wait-please) ##########
Procs---Swap-------IO-------system------------CPU--------
R b si so bi bo ir cs us sy il wa st
1 0 0 0 0 3 25 10 0 0 100 0-0
0 0 0 0 0 0 400 800 11 20 69 0-0
0 0 0 0 0 0 60 70 0 1 99 0-0
0 0 0 0 0 0 25 60 0 0 100 0-0
0 0 0 0 0 0 30 60 0 1 99 0-0
# The End ####################################################
[Root@mysql-slave local]#
Third-party replication solution: Tungsten,galera

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.