日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

xtrabackup mysql 5.6_percona-xtrabackup工具实现mysql5.6.34的主从同步复制

發(fā)布時(shí)間:2023/12/20 数据库 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 xtrabackup mysql 5.6_percona-xtrabackup工具实现mysql5.6.34的主从同步复制 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

percona-xtrabackup工具實(shí)現(xiàn)mysql5.6.34的主從同步復(fù)制

下載并安裝percona-xtrabackup工具

# wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.7/binary/redhat/6/x86_64/percona-xtrabackup-24-2.4.7-1.el6.x86_64.rpm

#yum localinstall -y percona-xtrabackup-24-2.4.7-1.el6.x86_64.rpm

1.備份,將mysql數(shù)據(jù)庫(kù)整個(gè)備份到/opt/目錄下

# innobackupex --defaults-file="/etc/my.cnf" --user=root -proot --socket=/tmp/mysql.sock /opt

2.預(yù)處理,進(jìn)行事物檢查(也可以拷貝到從庫(kù)后再進(jìn)行檢查)

# innobackupex --defaults-file="/etc/my.cnf" --user=root -proot --socket=/tmp/mysql.sock --apply-log --use-memory=1G /opt/2017-05-18_00-13-42/

3.scp到從庫(kù)

[root@centossz008 ~]# scp -r /opt/2017-05-18_01-34-42/ 192.168.3.13:/opt

4.關(guān)閉從庫(kù),清理從庫(kù)數(shù)據(jù),恢復(fù)數(shù)據(jù)到從庫(kù)

/etc/init.d/mysqld stop

刪除從庫(kù)的數(shù)據(jù)和日志信息

[root@node5 ~]# rm -rf /data/mydata/*[root@node5 ~]# rm -rf /data/binlogs/*

[root@node5 ~]# rm -rf /data/relaylogs/*

在從庫(kù)上執(zhí)行(將數(shù)據(jù)恢復(fù)到數(shù)據(jù)庫(kù)中)

[root@node5 ~]# innobackupex --defaults-file="/etc/my.cnf" --user=root --socket=/tmp/mysql.sock --move-back /opt/2017-05-18_01-34-42/

5.修改權(quán)限,啟動(dòng)從庫(kù)

[root@node5 mydata]# chown -R mysql.mysql /data

[root@node5 mydata]#/etc/init.d/mysqld start

查看主庫(kù)中master位置

[root@node5 mydata]# cat /opt/2017-05-18_01-34-42/xtrabackup_binlog_info

master-bin.000002 191 4c6237f8-a7da-11e6-9966-000c29f333f8:1-2

6.主庫(kù)中創(chuàng)建建salve同步用戶(hù)

mysql> grant replication slave,reload,super on *.* to repluser@192.168.3.13 identified by 'replpass';

mysql> FLUSH PRIVILEGES;

7.從庫(kù)執(zhí)行同步

mysql> change master to master_host='192.168.3.12',master_user='repluser',master_password='replpass',master_log_file='master-bin.000002',master_log_pos=191;

mysql>start slave;

mysql>show slave status\G*************************** 1. row ***************************Slave_IO_State: Waitingformaster to send event

Master_Host:192.168.3.12Master_User: repluser

Master_Port:3306Connect_Retry:60Master_Log_File: master-bin.000002Read_Master_Log_Pos:586Relay_Log_File: relay-bin.000002Relay_Log_Pos:710Relay_Master_Log_File: master-bin.000002Slave_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:0Last_Error:

Skip_Counter:0Exec_Master_Log_Pos:586Relay_Log_Space:908Until_Condition: None

Until_Log_File:

Until_Log_Pos:0Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master:0Master_SSL_Verify_Server_Cert: No

Last_IO_Errno:0Last_IO_Error:

Last_SQL_Errno:0Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id:100Master_UUID: 4c6237f8-a7da-11e6-9966-000c29f333f8

Master_Info_File:/data/mydata/master.infoSQL_Delay:0SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waitingfor the slave I/O thread to update it

Master_Retry_Count:86400Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set: 4c6237f8-a7da-11e6-9966-000c29f333f8:3-4Executed_Gtid_Set: 4c6237f8-a7da-11e6-9966-000c29f333f8:3-4Auto_Position:0

1 row in set (0.00 sec)

延遲復(fù)制:

啟用方法:

mysql>stop slave;

mysql> change master to master_delay=600;

mysql> start slave;

應(yīng)用場(chǎng)景:

1.誤刪除恢復(fù)

2.延遲測(cè)試(當(dāng)有延遲時(shí)業(yè)務(wù)是否會(huì)受影響)

3.歷史查詢(xún)

***************************

mysql master 配置

[root@centossz008 ~]# cat /etc/my.cnf

[client]

port= 3306socket= /tmp/mysql.sock

default-character-set =utf8mb4

[mysqld]

port= 3306innodb_file_per_table= 1binlog-format=ROW

log-slave-updates=truegtid-mode=on

enforce-gtid-consistency=truemaster-info-repository=filerelay-log-info-repository=file

sync-master-info=1slave-parallel-workers=4binlog-checksum=CRC32

master-verify-checksum=1slave-sql-verify-checksum=1binlog-rows-query-log_events=1server-id=100report-port=3306log-bin=/data/binlogs/master-bin

max_binlog_size=200M

datadir=/data/mydata

socket=/tmp/mysql.sock

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

init-connect = 'SET NAMES utf8mb4'character-set-server =utf8mb4

skip-name-resolve

skip-external-locking

back_log= 300max_connections= 1024max_connect_errors= 6000open_files_limit= 65535table_open_cache= 128max_allowed_packet=4M

binlog_cache_size=1M

max_heap_table_size=8M

tmp_table_size=16M

read_buffer_size=2M

read_rnd_buffer_size=8M

sort_buffer_size=8M

join_buffer_size=8M

key_buffer_size=4M

thread_cache_size= 8query_cache_type= 1query_cache_size=16M

query_cache_limit=2M

ft_min_word_len= 4expire_logs_days= 10performance_schema= 0explicit_defaults_for_timestamp

default_storage_engine=InnoDB

innodb_open_files= 500innodb_buffer_pool_size=64M

innodb_write_io_threads= 4innodb_read_io_threads= 4innodb_thread_concurrency= 4innodb_purge_threads= 1innodb_flush_log_at_trx_commit= 2innodb_log_buffer_size=2M

innodb_log_file_size=32M

innodb_log_files_in_group= 3innodb_max_dirty_pages_pct= 90innodb_lock_wait_timeout= 120bulk_insert_buffer_size=8M

myisam_sort_buffer_size=8M

myisam_max_sort_file_size=512M

myisam_repair_threads= 1interactive_timeout= 28800wait_timeout= 28800[mysqldump]

quick

max_allowed_packet=16M

[myisamchk]

key_buffer_size=8M

sort_buffer_size=8M

read_buffer=4M

write_buffer= 4M

******************

mysql slave 配置

[root@node5 src]# cat /etc/my.cnf

[client]

port= 3306socket= /tmp/mysql.sock

default-character-set =utf8mb4

[mysqld]

port= 3306innodb_file_per_table= 1binlog-format=ROW

log-slave-updates=truegtid-mode=on

enforce-gtid-consistency=truemaster-info-repository=filerelay-log-info-repository=file

sync-master-info=1slave-parallel-workers=4binlog-checksum=CRC32

master-verify-checksum=1slave-sql-verify-checksum=1binlog-rows-query-log_events=1server-id=200report-port=3306log-bin=/data/binlogs/master-bin

relay-log=/data/relaylogs/relay-bin

max_binlog_size=200M

datadir=/data/mydata

socket=/tmp/mysql.sock

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

init-connect = 'SET NAMES utf8mb4'character-set-server =utf8mb4

skip-name-resolve

skip-external-locking

back_log= 300max_connections= 1024max_connect_errors= 6000open_files_limit= 65535table_open_cache= 128max_allowed_packet=4M

binlog_cache_size=1M

max_heap_table_size=8M

tmp_table_size=16M

read_buffer_size=2M

read_rnd_buffer_size=8M

sort_buffer_size=8M

join_buffer_size=8M

key_buffer_size=4M

thread_cache_size= 8query_cache_type= 1query_cache_size=16M

query_cache_limit=2M

ft_min_word_len= 4expire_logs_days= 10performance_schema= 0explicit_defaults_for_timestamp

default_storage_engine=InnoDB

innodb_open_files= 500innodb_buffer_pool_size=64M

innodb_write_io_threads= 4innodb_read_io_threads= 4innodb_thread_concurrency= 4innodb_purge_threads= 1innodb_flush_log_at_trx_commit= 2innodb_log_buffer_size=2M

innodb_log_file_size=32M

innodb_log_files_in_group= 3innodb_max_dirty_pages_pct= 90innodb_lock_wait_timeout= 120bulk_insert_buffer_size=8M

myisam_sort_buffer_size=8M

myisam_max_sort_file_size=512M

myisam_repair_threads= 1interactive_timeout= 28800wait_timeout= 28800[mysqldump]

quick

max_allowed_packet=16M

[myisamchk]

key_buffer_size=8M

sort_buffer_size=8M

read_buffer=4M

write_buffer= 4M

*********************

cenos6上啟動(dòng)mysql服務(wù)報(bào)錯(cuò):

070517 23:08:52 mysqld_safe Starting mysqld daemon with databases from /data/mydata

2107-05-17 23:08:56 0 [ERROR] This MySQL server doesn't support dates later then 2038

2107-05-17 23:08:56 0 [ERROR] Aborting

將時(shí)間修改為1年前,即可啟動(dòng),啟動(dòng)完成后改回時(shí)間即可

總結(jié)

以上是生活随笔為你收集整理的xtrabackup mysql 5.6_percona-xtrabackup工具实现mysql5.6.34的主从同步复制的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。