MySQL PXC添加新节点只需IST传输的方法
PXC传输数据有两种方式:
IST: Incremental State Transfer 增量同步
SST:State Snapshot Transfer 全量同步
IST 发生的条件:This is done using caching mechanism on nodes (即只发生在之前集群里的节点数据还有在缓存中)
判断方法:
在主节点上
mysql>
show global status like 'wsrep_local_cached_downto';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| wsrep_local_cached_downto | 1 |
+---------------------------+-------+
1 row in set (0.00 sec)
此值小于新添加节点的seqno:
[root@mysql2 data]# cat grastate.dat
# GALERA saved state
version: 2.1
uuid: 6a244048-3a0e-11e6-9016-831e882dea43
seqno:
16
cert_index:
即通过备份,将新节点先做成slave,并伪造一个grastate.dat,来记录新节点数据的seqno,这样当新节点启动时就会自动用IST的方法来进行,而不是SST(注意gcache.size应该有足够的容量来保证在备份及恢复这段时间内新产生的数据都被缓存到)
搭建pxc环境,请看http://blog.csdn.net/zhanglei_16/article/details/51473538
如下为这次的操作步骤:
mysql1:192.168.1.41 --已经存在的集群节点
mysql2:192.168.1.42 --将要加入的集群节点
1:启动mysql1,使用xtrabackup备份mysql1,并在mysql2上恢复
[root@mysql1 mysql]# /etc/init.d/mysql bootstrap-pxc
Bootstrapping PXC (Percona XtraDB Cluster)Starting MySQL (Percona XtraDB Cluster).......[ OK ]
[root@mysql1 ~]# /usr/local/mysql/bin/mysql -S /tmp/mysql3306.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.6.26-74.0-25.12-log Percona XtraDB Cluster binary (GPL) 5.6.26-25.12, Revision 624ef81, wsrep_25.12
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
"root@localhost:mysql3306.sock [zhang]>
select * from zhang.test;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
+------+
10 rows in set (0.02 sec)
创建复制用户和IST用户:
grant all privileges on *.* to zhang@'%' identified by 'mysql123';
grant replication slave on *.* to zhang@'localhost' identified by 'mysql123';
grant reload,create tablespace,lock tables ,replication client,super on *.* to 'zhang'@localhost;
flush privileges;
"root@localhost:mysql3306.sock [zhang]>
show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
|
mysql-bin.000002 |
120 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
用innobackupex备份mysql1的数据:
[root@mysql1 backup]#
innobackupex --user=zhang --password=mysql123 /mysql/backup
160625 21:30:21 innobackupex: Starting the backup operation
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
160625 21:30:21 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;port=3306;mysql_socket=/tmp/mysql3306.sock' as 'zhang' (using password: YES).
160625 21:30:21 version_check Connected to MySQL server
160625 21:30:21 version_check Executing a version check against the server...
160625 21:30:21 version_check Done.
160625 21:30:21 Connecting to MySQL server host: localhost, user: zhang, password: set, port: 3306, socket: /tmp/mysql3306.sock
Using server version 5.6.26-74.0-25.12-log
innobackupex version 2.3.4 based on MySQL server 5.6.24 Linux (x86_64) (revision id: e80c779)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /mysql/data
xtrabackup: open files limit requested 65535, set to 65535
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:1024M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 3
xtrabackup: innodb_log_file_size = 268435456
xtrabackup: using O_DIRECT
160625 21:30:22 >> log scanned up to (1644664)
xtrabackup: Generating a list of tablespaces
160625 21:30:22 [01] Copying ./ibdata1 to /mysql/backup/2016-06-25_21-30-21/ibdata1
160625 21:30:23 >> log scanned up to (1644664)
160625 21:30:24 >> log scanned up to (1644664)
160625 21:30:25 >> log scanned up to (1644664)
160625 21:30:26 >> log scanned up to (1644664)
160625 21:30:27 >> log scanned up to (1644664)
160625 21:30:28 >> log scanned up to (1644664)
160625 21:30:29 >> log scanned up to (1644664)
160625 21:30:30 >> log scanned up to (1644664)
160625 21:30:31 >> log scanned up to (1644664)
160625 21:30:32 >> log scanned up to (1644664)
160625 21:30:33 >> log scanned up to (1644664)
160625 21:30:34 >> log scanned up to (1644664)
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./zhang/test.ibd to /mysql/backup/2016-06-25_21-30-21/zhang/test.ibd
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./mysql/slave_relay_log_info.ibd to /mysql/backup/2016-06-25_21-30-21/mysql/slave_relay_log_info.ibd
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./mysql/innodb_index_stats.ibd to /mysql/backup/2016-06-25_21-30-21/mysql/innodb_index_stats.ibd
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./mysql/slave_worker_info.ibd to /mysql/backup/2016-06-25_21-30-21/mysql/slave_worker_info.ibd
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./mysql/innodb_table_stats.ibd to /mysql/backup/2016-06-25_21-30-21/mysql/innodb_table_stats.ibd
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./mysql/slave_master_info.ibd to /mysql/backup/2016-06-25_21-30-21/mysql/slave_master_info.ibd
160625 21:30:34 [01] ...done
160625 21:30:34 Executing LOCK TABLES FOR BACKUP...
160625 21:30:34 Starting to backup non-InnoDB tables and files
160625 21:30:34 [01] Copying ./zhang/db.opt to /mysql/backup/2016-06-25_21-30-21/zhang/db.opt
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./zhang/test.frm to /mysql/backup/2016-06-25_21-30-21/zhang/test.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/db.opt to /mysql/backup/2016-06-25_21-30-21/performance_schema/db.opt
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/events_stages_summary_by_user_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_stages_summary_by_user_by_event_name.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/file_summary_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/file_summary_by_event_name.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/events_statements_summary_by_thread_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_statements_summary_by_thread_by_event_name.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/events_waits_summary_global_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_waits_summary_global_by_event_name.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/file_instances.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/file_instances.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/events_stages_history.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_stages_history.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/events_stages_current.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_stages_current.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/events_waits_summary_by_account_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_waits_summary_by_account_by_event_name.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/setup_actors.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/setup_actors.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/setup_timers.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/setup_timers.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/accounts.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/accounts.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/events_waits_history_long.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_waits_history_long.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/file_summary_by_instance.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/file_summary_by_instance.frm
160625 21:30:34 [01] ...done
160625 21:30:34 [01] Copying ./performance_schema/events_statements_history.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_statements_history.frm
160625 21:30:34 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_statements_current.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_statements_current.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_stages_summary_by_account_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_stages_summary_by_account_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/table_io_waits_summary_by_table.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/table_io_waits_summary_by_table.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_statements_summary_by_user_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_statements_summary_by_user_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_statements_history_long.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_statements_history_long.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/users.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/users.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/table_io_waits_summary_by_index_usage.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/table_io_waits_summary_by_index_usage.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_waits_summary_by_instance.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_waits_summary_by_instance.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_statements_summary_by_digest.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_statements_summary_by_digest.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_statements_summary_by_account_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_statements_summary_by_account_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/mutex_instances.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/mutex_instances.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_stages_summary_global_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_stages_summary_global_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/threads.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/threads.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/session_connect_attrs.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/session_connect_attrs.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/host_cache.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/host_cache.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/table_lock_waits_summary_by_table.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/table_lock_waits_summary_by_table.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_stages_history_long.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_stages_history_long.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_waits_summary_by_user_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_waits_summary_by_user_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/objects_summary_global_by_type.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/objects_summary_global_by_type.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/rwlock_instances.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/rwlock_instances.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/session_account_connect_attrs.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/session_account_connect_attrs.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/performance_timers.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/performance_timers.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/socket_summary_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/socket_summary_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_waits_history.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_waits_history.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/setup_consumers.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/setup_consumers.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_statements_summary_global_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_statements_summary_global_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/socket_summary_by_instance.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/socket_summary_by_instance.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_waits_current.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_waits_current.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_stages_summary_by_thread_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_stages_summary_by_thread_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_stages_summary_by_host_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_stages_summary_by_host_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/setup_instruments.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/setup_instruments.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/socket_instances.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/socket_instances.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/setup_objects.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/setup_objects.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/hosts.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/hosts.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_waits_summary_by_host_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_waits_summary_by_host_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_waits_summary_by_thread_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_waits_summary_by_thread_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/cond_instances.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/cond_instances.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./performance_schema/events_statements_summary_by_host_by_event_name.frm to /mysql/backup/2016-06-25_21-30-21/performance_schema/events_statements_summary_by_host_by_event_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/servers.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/servers.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/innodb_table_stats.frm to /mysql/backup/2016-06-25_21-30-21/mysql/innodb_table_stats.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/plugin.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/plugin.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/ndb_binlog_index.frm to /mysql/backup/2016-06-25_21-30-21/mysql/ndb_binlog_index.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/slow_log.CSV to /mysql/backup/2016-06-25_21-30-21/mysql/slow_log.CSV
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/time_zone_leap_second.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_leap_second.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/time_zone_name.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_name.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/help_relation.frm to /mysql/backup/2016-06-25_21-30-21/mysql/help_relation.frm
160625 21:30:35 [01] ...done
160625 21:30:35 >> log scanned up to (1644695)
160625 21:30:35 [01] Copying ./mysql/tables_priv.frm to /mysql/backup/2016-06-25_21-30-21/mysql/tables_priv.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/help_topic.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/help_topic.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/event.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/event.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/user.frm to /mysql/backup/2016-06-25_21-30-21/mysql/user.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/proc.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/proc.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/plugin.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/plugin.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/user.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/user.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/db.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/db.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/time_zone_transition_type.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_transition_type.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/general_log.CSM to /mysql/backup/2016-06-25_21-30-21/mysql/general_log.CSM
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/procs_priv.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/procs_priv.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/help_keyword.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/help_keyword.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/procs_priv.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/procs_priv.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/db.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/db.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/help_topic.frm to /mysql/backup/2016-06-25_21-30-21/mysql/help_topic.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/servers.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/servers.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/time_zone_transition.frm to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_transition.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/ndb_binlog_index.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/ndb_binlog_index.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/slow_log.frm to /mysql/backup/2016-06-25_21-30-21/mysql/slow_log.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/time_zone.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/help_keyword.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/help_keyword.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/procs_priv.frm to /mysql/backup/2016-06-25_21-30-21/mysql/procs_priv.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/slow_log.CSM to /mysql/backup/2016-06-25_21-30-21/mysql/slow_log.CSM
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/columns_priv.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/columns_priv.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/slave_master_info.frm to /mysql/backup/2016-06-25_21-30-21/mysql/slave_master_info.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/help_category.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/help_category.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/db.frm to /mysql/backup/2016-06-25_21-30-21/mysql/db.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/help_category.frm to /mysql/backup/2016-06-25_21-30-21/mysql/help_category.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/time_zone_transition_type.frm to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_transition_type.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/func.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/func.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/general_log.frm to /mysql/backup/2016-06-25_21-30-21/mysql/general_log.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/proxies_priv.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/proxies_priv.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/help_keyword.frm to /mysql/backup/2016-06-25_21-30-21/mysql/help_keyword.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/columns_priv.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/columns_priv.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/time_zone.frm to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/time_zone_transition.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_transition.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/innodb_index_stats.frm to /mysql/backup/2016-06-25_21-30-21/mysql/innodb_index_stats.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/user.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/user.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/proxies_priv.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/proxies_priv.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/func.frm to /mysql/backup/2016-06-25_21-30-21/mysql/func.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/time_zone_name.frm to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_name.frm
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/help_topic.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/help_topic.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/func.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/func.MYD
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/help_category.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/help_category.MYI
160625 21:30:35 [01] ...done
160625 21:30:35 [01] Copying ./mysql/time_zone_name.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_name.MYI
160625 21:30:35 [01] ...done
160625 21:30:36 [01] Copying ./mysql/event.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/event.MYD
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/time_zone_transition.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_transition.MYI
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/time_zone_leap_second.frm to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_leap_second.frm
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/time_zone_transition_type.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_transition_type.MYD
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/servers.frm to /mysql/backup/2016-06-25_21-30-21/mysql/servers.frm
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/tables_priv.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/tables_priv.MYI
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/proxies_priv.frm to /mysql/backup/2016-06-25_21-30-21/mysql/proxies_priv.frm
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/tables_priv.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/tables_priv.MYD
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/general_log.CSV to /mysql/backup/2016-06-25_21-30-21/mysql/general_log.CSV
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/slave_worker_info.frm to /mysql/backup/2016-06-25_21-30-21/mysql/slave_worker_info.frm
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/columns_priv.frm to /mysql/backup/2016-06-25_21-30-21/mysql/columns_priv.frm
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/time_zone.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone.MYD
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/slave_relay_log_info.frm to /mysql/backup/2016-06-25_21-30-21/mysql/slave_relay_log_info.frm
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/event.frm to /mysql/backup/2016-06-25_21-30-21/mysql/event.frm
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/proc.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/proc.MYD
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/help_relation.MYI to /mysql/backup/2016-06-25_21-30-21/mysql/help_relation.MYI
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/proc.frm to /mysql/backup/2016-06-25_21-30-21/mysql/proc.frm
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/plugin.frm to /mysql/backup/2016-06-25_21-30-21/mysql/plugin.frm
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/ndb_binlog_index.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/ndb_binlog_index.MYD
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/time_zone_leap_second.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/time_zone_leap_second.MYD
160625 21:30:36 [01] ...done
160625 21:30:36 [01] Copying ./mysql/help_relation.MYD to /mysql/backup/2016-06-25_21-30-21/mysql/help_relation.MYD
160625 21:30:36 [01] ...done
160625 21:30:36 Finished backing up non-InnoDB tables and files
160625 21:30:36 Executing LOCK BINLOG FOR BACKUP...
160625 21:30:36 [00] Writing xtrabackup_binlog_info
160625 21:30:36 [00] ...done
160625 21:30:36 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '1644695'
xtrabackup: Stopping log copying thread.
.160625 21:30:36 >> log scanned up to (1644695)
160625 21:30:36 Executing UNLOCK BINLOG
160625 21:30:36 Executing UNLOCK TABLES
160625 21:30:36 All tables unlocked
160625 21:30:36 Backup created in directory '/mysql/backup/2016-06-25_21-30-21'
MySQL binlog position: filename 'mysql-bin.000002', position '120'
160625 21:30:36 [00] Writing backup-my.cnf
160625 21:30:36 [00] ...done
160625 21:30:36 [00] Writing xtrabackup_info
160625 21:30:36 [00] ...done
xtrabackup: Transaction log of lsn (1644664) to (1644695) was copied.
160625 21:30:36 completed OK!
[root@mysql1 backup]#
ll /mysql/backup/2016-06-25_21-30-21/
total 1048612
-rw-r----- 1 root root 390 Jun 25 21:30 backup-my.cnf
-rw-r----- 1 root root 1073741824 Jun 25 21:30 ibdata1
drwx------ 2 root root 4096 Jun 25 21:30 mysql
drwx------ 2 root root 4096 Jun 25 21:30 performance_schema
-rw-r----- 1 root root 21 Jun 25 21:30 xtrabackup_binlog_info
-rw-r----- 1 root root 113 Jun 25 21:30 xtrabackup_checkpoints
-rw-r----- 1 root root 481 Jun 25 21:30 xtrabackup_info
-rw-r----- 1 root root 2560 Jun 25 21:30 xtrabackup_logfile
drwx------ 2 root root 4096 Jun 25 21:30 zhang
在mysql1上再加入一些数据:
insert into zhang.test values(11),(12),(13);
"root@localhost:mysql3306.sock [(none)]>
select * from zhang.test;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
+------+
13 rows in set (0.00 sec)
将备份的数据传输到mysql2上并恢复:
[root@mysql2 2016-06-25_21-30-21]#
innobackupex --apply-log /mysql/backup/2016-06-25_21-30-21
160625 21:44:31 innobackupex: Starting the apply-log operation
IMPORTANT: Please check that the apply-log run completes successfully.
At the end of a successful apply-log run innobackupex
prints "completed OK!".
innobackupex version 2.3.4 based on MySQL server 5.6.24 Linux (x86_64) (revision id: e80c779)
xtrabackup: cd to /mysql/backup/2016-06-25_21-30-21
xtrabackup: This target seems to be not prepared yet.
xtrabackup: xtrabackup_logfile detected: size=2097152, start_lsn=(1644664)
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:1024M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 1
xtrabackup: innodb_log_file_size = 2097152
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:1024M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 1
xtrabackup: innodb_log_file_size = 2097152
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
InnoDB: Using atomics to ref count buffer pool pages
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Memory barrier is not used
InnoDB: Compressed tables use zlib 1.2.3
InnoDB: Not using CPU crc32 instructions
InnoDB: Initializing buffer pool, size = 100.0M
InnoDB: Completed initialization of buffer pool
InnoDB: Highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 1644664
InnoDB: Database was not shutdown normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages
InnoDB: from the doublewrite buffer...
InnoDB: Doing recovery: scanned up to log sequence number 1644695 (0%)
InnoDB: 128 rollback segment(s) are active.
InnoDB: Waiting for purge to start
InnoDB: 5.6.24 started; log sequence number 1644695
xtrabackup: Last MySQL binlog file position 120, file name mysql-bin.000002
xtrabackup: Recovered WSREP position: 6a244048-3a0e-11e6-9016-831e882dea43:16
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1644705
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:1024M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 3
xtrabackup: innodb_log_file_size = 268435456
InnoDB: Using atomics to ref count buffer pool pages
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Memory barrier is not used
InnoDB: Compressed tables use zlib 1.2.3
InnoDB: Not using CPU crc32 instructions
InnoDB: Initializing buffer pool, size = 100.0M
InnoDB: Completed initialization of buffer pool
InnoDB: Setting log file ./ib_logfile101 size to 256 MB
InnoDB: Progress in MB: 100 200
InnoDB: Setting log file ./ib_logfile1 size to 256 MB
InnoDB: Progress in MB: 100 200
InnoDB: Setting log file ./ib_logfile2 size to 256 MB
InnoDB: Progress in MB: 100 200
InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
InnoDB: New log files created, LSN=1644705
InnoDB: Highest supported file format is Barracuda.
InnoDB: 128 rollback segment(s) are active.
InnoDB: Waiting for purge to start
InnoDB: 5.6.24 started; log sequence number 1645068
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1645078
160625 21:44:42 completed OK!
找出Xid的位置:
方法一:查看文件xtrabackup_galera_info
[root@mysql2 2016-06-25_21-30-21]#
cat xtrabackup_galera_info
6a244048-3a0e-11e6-9016-831e882dea43:16
方法二:通过binlog位置来查找
[root@mysql2 2016-06-25_21-30-21]#
cat xtrabackup_binlog_info
mysql-bin.000002 120
即备份时的备份点位置为log_bin.000002 120
再去Mysql1查找此binlog对应的xid:
[root@mysql1 bin]# cd /mysql/logs/
[root@mysql1 logs]#
/usr/local/mysql/bin/mysqlbinlog -vv mysql-bin.000002 |grep Xid
#160625 21:34:40 server id 213306 end_log_pos 317 CRC32 0xa3386f6d Xid = 17
由于120是每个binlog开始的pos位,把Xid设为16.
在Mysql2上伪造一个grastate.dat文件(从Mysql1上复制过来,更改下seqno即可):
[root@mysql2 data]#
cat grastate.dat
# GALERA saved state
version: 2.1
uuid: 6a244048-3a0e-11e6-9016-831e882dea43
seqno:
16
cert_index:
启动mysql2:
[root@mysql2 mysql]#
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
[1] 19736
[root@mysql2 mysql]# 160625 21:55:06 mysqld_safe Logging to '/mysql/logs/error.log'.
160625 21:55:06 mysqld_safe Starting mysqld daemon with databases from /mysql/data
160625 21:55:06 mysqld_safe Skipping wsrep-recover for 6a244048-3a0e-11e6-9016-831e882dea43:16 pair
160625 21:55:06 mysqld_safe Assigning 6a244048-3a0e-11e6-9016-831e882dea43:16 to wsrep_start_position
查看mysql2的error.log:
[root@mysql2 logs]# tail -800 error.log
160625 21:55:06 mysqld_safe Starting mysqld daemon with databases from /mysql/data
160625 21:55:06 mysqld_safe Skipping wsrep-recover for 6a244048-3a0e-11e6-9016-831e882dea43:16 pair
160625 21:55:06 mysqld_safe Assigning 6a244048-3a0e-11e6-9016-831e882dea43:16 to wsrep_start_position
2016-06-25 21:55:07 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.26-74.0-25.12-log) starting as process 20771 ...
2016-06-25 21:55:07 20771 [Note] WSREP: Read nil XID from storage engines, skipping position init
2016-06-25 21:55:07 20771 [Note] WSREP: wsrep_load(): loading provider library '/usr/local/mysql/lib/libgalera_smm.so'
2016-06-25 21:55:07 20771 [Note] WSREP: wsrep_load(): Galera 3.12.2(rf3e626d) by Codership Oy
loaded successfully.
2016-06-25 21:55:07 20771 [Note] WSREP: CRC-32C: using "slicing-by-8" algorithm.
2016-06-25 21:55:07 20771 [Note] WSREP: Found saved state: 6a244048-3a0e-11e6-9016-831e882dea43:16
2016-06-25 21:55:07 20771 [Note] WSREP: Passing config to GCS: base_dir = /mysql/data/; base_host = 192.168.1.42; base_port = 4567; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.join_retrans_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.user_send_window = 2; evs.view_forget_timeout = PT24H; gcache.dir = /mysql/data/; gcache.keep_pages_count = 0; gcache.keep_pages_size = 0; gcache.mem_size = 0; gcache.name = /mysql/data//galera.cache; gcache.page_size = 128M; gcache.size = 128M; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; gcs.recv_q_hard_limit = 9223372036854775807; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; gmcast.segment = 0; gmcast.version = 0; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; p
2016-06-25 21:55:07 20771 [Note] WSREP: Service thread queue flushed.
2016-06-25 21:55:07 20771 [Note] WSREP: Assign initial position for certification: 16, protocol version: -1
2016-06-25 21:55:07 20771 [Note] WSREP: wsrep_sst_grab()
2016-06-25 21:55:07 20771 [Note] WSREP: Start replication
2016-06-25 21:55:07 20771 [Note] WSREP: Setting initial position to 6a244048-3a0e-11e6-9016-831e882dea43:16
2016-06-25 21:55:07 20771 [Note] WSREP: protonet asio version 0
2016-06-25 21:55:07 20771 [Note] WSREP: Using CRC-32C for message checksums.
2016-06-25 21:55:07 20771 [Note] WSREP: backend: asio
2016-06-25 21:55:07 20771 [Warning] WSREP: access file(/mysql/data//gvwstate.dat) failed(No such file or directory)
2016-06-25 21:55:07 20771 [Note] WSREP: restore pc from disk failed
2016-06-25 21:55:07 20771 [Note] WSREP: GMCast version 0
2016-06-25 21:55:07 20771 [Note] WSREP: (6d070973, 'tcp://0.0.0.0:4567') listening at tcp://0.0.0.0:4567
2016-06-25 21:55:07 20771 [Note] WSREP: (6d070973, 'tcp://0.0.0.0:4567') multicast: , ttl: 1
2016-06-25 21:55:07 20771 [Note] WSREP: EVS version 0
2016-06-25 21:55:07 20771 [Note] WSREP: gcomm: connecting to group 'pxc_zhang', peer '192.168.1.41:,192.168.1.42:,192.168.1.43:'
2016-06-25 21:55:07 20771 [Warning] WSREP: (6d070973, 'tcp://0.0.0.0:4567') address 'tcp://192.168.1.42:4567' points to own listening address, blacklisting
2016-06-25 21:55:07 20771 [Note] WSREP: (6d070973, 'tcp://0.0.0.0:4567') turning message relay requesting on, nonlive peers:
2016-06-25 21:55:08 20771 [Note] WSREP: declaring 1dc4c899 at tcp://192.168.1.41:4567 stable
2016-06-25 21:55:08 20771 [Note] WSREP: Node 1dc4c899 state prim
2016-06-25 21:55:08 20771 [Note] WSREP: view(view_id(PRIM,1dc4c899,2) memb {
1dc4c899,0
6d070973,0
} joined {
} left {
} partitioned {
})
2016-06-25 21:55:08 20771 [Note] WSREP: save pc into disk
2016-06-25 21:55:08 20771 [Note] WSREP: discarding pending addr without UUID: tcp://192.168.1.43:4567
2016-06-25 21:55:08 20771 [Note] WSREP: discarding pending addr proto entry 0x24b4060
2016-06-25 21:55:08 20771 [Note] WSREP: gcomm: connected
2016-06-25 21:55:08 20771 [Note] WSREP: Changing maximum packet size to 64500, resulting msg size: 32636
2016-06-25 21:55:08 20771 [Note] WSREP: Shifting CLOSED -> OPEN (TO: 0)
2016-06-25 21:55:08 20771 [Note] WSREP: Opened channel 'pxc_zhang'
2016-06-25 21:55:08 20771 [Note] WSREP: New COMPONENT: primary = yes, bootstrap = no, my_idx = 1, memb_num = 2
2016-06-25 21:55:08 20771 [Note] WSREP: STATE EXCHANGE: Waiting for state UUID.
2016-06-25 21:55:08 20771 [Note] WSREP: Waiting for SST to complete.
2016-06-25 21:55:08 20771 [Note] WSREP: STATE EXCHANGE: sent state msg: 869dbbe6-3adc-11e6-b634-e32cf2eeb329
2016-06-25 21:55:08 20771 [Note] WSREP: STATE EXCHANGE: got state msg: 869dbbe6-3adc-11e6-b634-e32cf2eeb329 from 0 (mysql1)
2016-06-25 21:55:08 20771 [Note] WSREP: STATE EXCHANGE: got state msg: 869dbbe6-3adc-11e6-b634-e32cf2eeb329 from 1 (mysql2)
2016-06-25 21:55:08 20771 [Note] WSREP: Quorum results:
version = 3,
component = PRIMARY,
conf_id = 1,
members = 1/2 (joined/total),
act_id = 17,
last_appl. = -1,
protocols = 0/7/3 (gcs/repl/appl),
group UUID = 6a244048-3a0e-11e6-9016-831e882dea43
2016-06-25 21:55:08 20771 [Note] WSREP: Flow-control interval: [23, 23]
2016-06-25 21:55:08 20771 [Note] WSREP: Shifting OPEN -> PRIMARY (TO: 17)
2016-06-25 21:55:08 20771 [Note] WSREP: State transfer required:
Group state: 6a244048-3a0e-11e6-9016-831e882dea43:17
Local state: 6a244048-3a0e-11e6-9016-831e882dea43:16
2016-06-25 21:55:08 20771 [Note] WSREP: New cluster view: global state: 6a244048-3a0e-11e6-9016-831e882dea43:17, view# 2: Primary, number of nodes: 2, my index: 1, protocol version 3
2016-06-25 21:55:08 20771 [Warning] WSREP: Gap in state sequence. Need state transfer.
2016-06-25 21:55:08 20771 [Note] WSREP: Running: 'wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.1.42' --datadir '/mysql/data/' --defaults-file '/etc/my.cnf' --defaults-group-suffix '' --parent '20771' '' '
WSREP_SST: [INFO] Streaming with xbstream (20160625 21:55:09.399)
WSREP_SST: [INFO] Using socat as streamer (20160625 21:55:09.403)
WSREP_SST: [INFO] Evaluating timeout -s9 100 socat -u TCP-LISTEN:4444,reuseaddr stdio | xbstream -x; RC=( ${PIPESTATUS[@]} ) (20160625 21:55:09.466)
2016-06-25 21:55:09 20771 [Note] WSREP: Prepared SST request: xtrabackup-v2|192.168.1.42:4444/xtrabackup_sst//1
2016-06-25 21:55:09 20771 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
2016-06-25 21:55:09 20771 [Note] WSREP: REPL Protocols: 7 (3, 2)
2016-06-25 21:55:09 20771 [Note] WSREP: Service thread queue flushed.
2016-06-25 21:55:09 20771 [Note] WSREP: Assign initial position for certification: 17, protocol version: 3
2016-06-25 21:55:09 20771 [Note] WSREP: Service thread queue flushed.
2016-06-25 21:55:09 20771 [Note] WSREP:
Prepared IST receiver, listening at: tcp://192.168.1.42:4568
2016-06-25 21:55:09 20771 [Note] WSREP: Member 1.0 (mysql2) requested state transfer from '*any*'. Selected 0.0 (mysql1)(SYNCED) as donor.
2016-06-25 21:55:09 20771 [Note] WSREP: Shifting PRIMARY -> JOINER (TO: 17)
2016-06-25 21:55:09 20771 [Note] WSREP: Requesting state transfer: success, donor: 0
2016-06-25 21:55:10 20771 [Note] WSREP: 0.0 (mysql1): State transfer to 1.0 (mysql2) complete.
2016-06-25 21:55:10 20771 [Note] WSREP: Member 0.0 (mysql1) synced with group.
WSREP_SST: [INFO] xtrabackup_ist received from donor: Running IST (20160625 21:55:10.938)
WSREP_SST: [INFO] Galera co-ords from recovery: 6a244048-3a0e-11e6-9016-831e882dea43:16 (20160625 21:55:10.944)
WSREP_SST: [INFO] Total time on joiner: 0 seconds (20160625 21:55:10.950)
WSREP_SST: [INFO] Removing the sst_in_progress file (20160625 21:55:10.954)
2016-06-25 21:55:10 20771 [Note] WSREP: SST complete, seqno: 16
2016-06-25 21:55:10 20771 [Note] Plugin 'FEDERATED' is disabled.
2016-06-25 21:55:10 7f879e70b7e0 InnoDB: Warning: Using innodb_locks_unsafe_for_binlog is DEPRECATED. This option may be removed in future releases. Please use READ COMMITTED transaction isolation level instead, see http://dev.mysql.com/doc/refman/5.6/en/set-transaction.html.
2016-06-25 21:55:10 20771 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-06-25 21:55:10 20771 [Note] InnoDB: The InnoDB memory heap is disabled
2016-06-25 21:55:10 20771 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-06-25 21:55:10 20771 [Note] InnoDB: Memory barrier is not used
2016-06-25 21:55:10 20771 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-06-25 21:55:10 20771 [Note] InnoDB: Using Linux native AIO
2016-06-25 21:55:10 20771 [Note] InnoDB: Not using CPU crc32 instructions
2016-06-25 21:55:10 20771 [Note] InnoDB: Initializing buffer pool, size = 1.0G
2016-06-25 21:55:11 20771 [Note] WSREP: (6d070973, 'tcp://0.0.0.0:4567') turning message relay requesting off
2016-06-25 21:55:11 20771 [Note] InnoDB: Completed initialization of buffer pool
2016-06-25 21:55:12 20771 [Note] InnoDB: Setting log file ./ib_logfile101 size to 256 MB
InnoDB: Progress in MB: 100 200
2016-06-25 21:55:14 20771 [Note] InnoDB: Setting log file ./ib_logfile1 size to 256 MB
InnoDB: Progress in MB: 100 200
2016-06-25 21:55:15 20771 [Note] InnoDB: Setting log file ./ib_logfile2 size to 256 MB
InnoDB: Progress in MB: 100 200
2016-06-25 21:55:17 20771 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-06-25 21:55:17 20771 [Warning] InnoDB: New log files created, LSN=1645078
2016-06-25 21:55:17 20771 [Note] InnoDB: Highest supported file format is Barracuda.
2016-06-25 21:55:17 20771 [Note] InnoDB: 128 rollback segment(s) are active.
2016-06-25 21:55:17 20771 [Note] InnoDB: Waiting for purge to start
2016-06-25 21:55:17 20771 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.26-74.0 started; log sequence number 1645580
2016-06-25 21:55:17 20771 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 73126cd7-3adc-11e6-9004-000c290c66d3.
2016-06-25 21:55:17 20771 [Note] RSA private key file not found: /mysql/data//private_key.pem. Some authentication plugins will not work.
2016-06-25 21:55:17 20771 [Note] RSA public key file not found: /mysql/data//public_key.pem. Some authentication plugins will not work.
2016-06-25 21:55:17 20771 [Note] Server hostname (bind-address): '*'; port: 3306
2016-06-25 21:55:17 20771 [Note] IPv6 is available.
2016-06-25 21:55:17 20771 [Note] - '::' resolves to '::';
2016-06-25 21:55:17 20771 [Note] Server socket created on IP: '::'.
2016-06-25 21:55:18 20771 [Note] Event Scheduler: Loaded 0 events
2016-06-25 21:55:18 20771 [Note] WSREP: Signalling provider to continue.
2016-06-25 21:55:18 20771 [Note] WSREP: Initialized wsrep sidno 2
2016-06-25 21:55:18 20771 [Note] WSREP: SST received: 6a244048-3a0e-11e6-9016-831e882dea43:16
2016-06-25 21:55:18 20771 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.6.26-74.0-25.12-log' socket: '/tmp/mysql3306.sock' port: 3306 Percona XtraDB Cluster binary (GPL) 5.6.26-25.12, Revision 624ef81, wsrep_25.12
2016-06-25 21:55:18 20771 [Note] WSREP:
Receiving IST: 1 writesets, seqnos 16-17
2016-06-25 21:55:18 20771 [Note] WSREP:
IST received: 6a244048-3a0e-11e6-9016-831e882dea43:17
2016-06-25 21:55:18 20771 [Note] WSREP: 1.0 (mysql2): State transfer from 0.0 (mysql1) complete.
2016-06-25 21:55:18 20771 [Note] WSREP: Shifting JOINER -> JOINED (TO: 17)
2016-06-25 21:55:18 20771 [Note] WSREP: Member 1.0 (mysql2) synced with group.
2016-06-25 21:55:18 20771 [Note] WSREP: Shifting JOINED -> SYNCED (TO: 17)
2016-06-25 21:55:18 20771 [Note] WSREP: Synchronized with group, ready for connections
2016-06-25 21:55:18 20771 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
成功用IST来恢复了。
可以拿这里的error.log,与正常添加节点的error.log,进行比较,这里省略。
登录mysql2,查看数据是否正常:
[root@mysql2 mysql]# /usr/local/mysql/bin/mysql -S /tmp/mysql3306.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.26-74.0-25.12-log Percona XtraDB Cluster binary (GPL) 5.6.26-25.12, Revision 624ef81, wsrep_25.12
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
"root@localhost:mysql3306.sock [(none)]>select * from zhang.test;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
+------+
13 rows in set (0.00 sec)
发现数据也已经全部同步完成。
pxc环境下避免新节点加入时需要进行SST的方法,在数据量大时SST将会占用大量的资源,
配置的gcache.size足够容纳从备份到恢复此时间段内主节点产生的数据量,建议通过业务
低峰期时通过脚本来实现此新节点加入操作。
参考文档:http://www.cnblogs.com/zejin2008/p/5537174.html