• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase
您的位置:首页 > 数据库 >Mysql > 详解MySQL PXC构建新节点只需IST传输的方法

详解MySQL PXC构建新节点只需IST传输的方法

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2018-12-05

匿名通过本文主要向大家介绍了MySQL ,PXC,IST传输等相关知识,希望本文的分享对您有所帮助
下面小编就为大家带来一篇MySQL PXC构建一个新节点只需IST传输的方法(推荐)。小编觉的挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

需求场景:原有的pxc环境数据量已经比较大,新买的服务器要加入此集群中,如何让其用IST的方式传输,而不是SST.

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@zejin241 I6000]# cat grastate.dat 
# GALERA saved state
version: 2.1
uuid:  6c86dc17-246f-11e6-9955-ae4d7e89eed2
seqno:  4
cert_index:

所以我们的思路即通过备份一个集群中节点的数据,恢复到新节点上,并伪造一个grastate.dat,来记录备份数据的seqno,这样当新节点启动时就会自动用IST的方法来进行,而不是SST(注意gcache.size应该有足够的容量来保证在备份及恢复这段时间内新产生的数据都被缓存到)

galera.cache: This file is used as a main writeset store. It's implemented as a permanent ring-buffer file
that is preallocated on disk when the node is initialized. File size can be controlled with the variable
gcache.size. If this value is bigger, more writesets are cached and chances are better that the rejoining node will get IST instead of SST.
Filename can be changed with the gcache.name variable.

如下为这次的操作步骤:

node240:192.168.1.240 --已经存在的集群节点
node241:192.168.1.241 --将要加入的集群节点

step1:启动新的集群中的第一个节点

/usr/local/pxc_56/bin/mysqld_safe --defaults-file=/home/mysql/pxc6000.cnf --ledir=/usr/local/pxc_56/bin/ --wsrep-new-cluster &

配置文件如下:

[root@zejin240 I6000]
# cat /home/mysql/pxc6000.cnf
[client]
port      = 6000socket     = /home/mysql/I6000/mysql.sockdefault-character-set=utf8
[mysqld]basedir = /usr/local/pxc_56datadir = /home/mysql/I6000pid-file    = /home/mysql/I6000/mysql.
pidcharacter-set-server=utf8init_connect = 'SET NAMES utf8'log-bin=/home/mysql/I6000/log_binserver-id = 9816000innodb_buffer_pool_size = 
100Minnodb_data_file_path = ibdata1:10M:autoextendinnodb_data_home_dir = /home/mysql/I6000innodb_file_per_table=1skip-name-resolveport      = 
6000socket     = /home/mysql/I6000/mysql.sockuser=mysqllog_error=/home/mysql/I6000/mysql_error.log
#pxcuser=mysqllog_error=error.logbinlog_format=ROW#6000 for mysqld port, 6020 for sst port, 6031 for ist port, 6030 for cluster communication 
portwsrep_cluster_address='gcomm://192.168.1.240:6030,192.168.1.241:6030,192.168.1.242:6030'
wsrep_provider=/usr/local/pxc_56/lib/libgalera_smm.sowsrep_sst_receive_address=192.168.1.240:6020wsrep_node_incoming_address=192.168.1.240:6000
wsrep_node_address=192.168.1.240:6000wsrep_provider_options = "gmcast.listen_addr=tcp://192.168.1.240:6030;ist.recv_addr=192.168.1.240:6031;
"wsrep_slave_threads=2wsrep_cluster_name=pxc_zejinwsrep_sst_method=xtrabackup-v2wsrep_node_name=node6000_240innodb_autoinc_lock_mode=2wsrep_sst_auth="sstuser:123"
log-slave-updates[mysql]no-auto-rehashdefault-character-set=utf8
mysql> use zejin;
mysql> select * from t1;
+----+-------+
| id | name |
+----+-------+
| 1 | chen |
| 2 | li  |
| 3 | zhang |
+----+-------+
3 rows in set (0.01 sec)mysql> update mysql.user set password=password('123');mysql> flush privileges;
mysql> show master status;
+----------------+----------+--------------+------------------+-------------------+
| File      | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+----------------+----------+--------------+------------------+-------------------+
| log_bin.000003 |   2772 |       |         |          |
+----------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

step2:用innobackupex备份node240数据:

[root@zejin240 mysql]# innobackupex --user=root --password=123 --port=6000 --host=127.0.0.1 
--defaults-file=/home/mysql/pxc6000.cnf /home/mysql/InnoDB Backup Utility v1.5.1-xtrabackup; 
Copyright 2003, 2009 Innobase Oyand Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.This software is published 
underthe GNU GENERAL PUBLIC LICENSE Version 2, June 1991.Get the latest version of Percona XtraBackup, documentation, and help 
resources:percona.com/xb/p160528 09:39:07 innobackupex: Executing a version check against the server...160528 09:39:07 
innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_file=/home/mysql/pxc6000.cnf;
mysql_read_default_group=xtrabackup;host=127.0.0.1;
port=6000' as 'root' (using password: YES).160528 09:39:07 innobackupex: Connected to MySQL server160528 09:39:07 
innobackupex: Done.160528 09:39:07 innobackupex: Connecting to MySQL server with DSN 'dbi:mysql:;
mysql_read_default_file=/home/mysql/pxc6000.cnf;
mysql_read_default_group=xtrabackup;host=127.0.0.1;port=6000' as 'root' (using password: YES).160528 09:39:07 
innobackupex: Connected to MySQL server160528 09:39:07 innobackupex: Starting the backup operationIMPORTANT: 
Please check that the backup run completes successfully.      
At the end of a successful backup run innobackupex      
prints "completed OK!".innobackupex: Using server version 5.6.26-74.0-25.12-loginnobackupex: 
Created backup directory /home/mysql/2016-05-28_09-39-07160528 09:39:07 innobackupex: Starting ibbackup with command: 
xtrabackup --defaults-file="/home/mysql/pxc6000.cnf" --defaults-group="mysqld" --backup 
--suspend-at-end --target-dir=/home/mysql/2016-05-28_09-39-07 --innodb_log_file_size="50331648"
 --tmpdir=/tmp --extra-lsndir='/tmp'innobackupex: Waiting for ibbackup (pid=30280) to suspendinnobackupex: 
 Suspend file '/home/mysql/2016-05-28_09-39-07/xtrabackup_suspended_2'xtrabackup 
 version 2.2.11 based on MySQL server 5.6.24 Linux (x86_64) (revision id: )xtrabackup: uses 
 posix_fadvise().xtrabackup: cd to /home/mysql/I6000xtrabackup: open files limit requested 0, set to 1024xtrabackup: 
 using the following InnoDB configuration:xtrabackup:  innodb_data_home_dir = /home/mysql/I6000xtrabackup:  
 innodb_data_file_path = ibdata1:10M:autoextendxtrabackup:  innodb_log_group_home_dir = ./xtrabackup:  
 innodb_log_files_in_group = 2xtrabackup:  innodb_log_file_size = 50331648>> log scanned up to (1637591)xtrabackup: 
 Generating a list of tablespaces[01] Copying /home/mysql/I6000/ibdata1 to /home/mysql/2016-05-28_09-39-07/ibdata1>> 
 log scanned up to (1637591)[01]    ...done[01] Copying ./zejin/t1.ibd to /home/mysql/2016-05-28_09-39-07/zejin/t1.ibd[01]   
  ...done[01] Copying ./mysql/innodb_table_stats.ibd to /home/mysql/2016-05-28_09-39-07/mysql/innodb_table_stats.ibd[01]   
   ...done[01] Copying ./mysql/slave_master_info.ibd to /home/mysql/2016-05-28_09-39-07/mysql/slave_master_info.ibd[01]   
   ...done[01] Copying ./mysql/slave_relay_log_info.ibd to /home/mysql/2016-05-28_09-39-07/mysql/slave_relay_log_info.ibd[01]    
   ...done[01] Copying ./mysql/slave_worker_info.ibd to /home/mysql/2016-05-28_
  


 
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • MySQL essential版本和普通版本有什么区别?
  • 如何用SQL命令查看Mysql数据库大小
  • 解析mysql中如何获得数据库的大小
  • 解析mysql修改为utf8后仍然有乱码的问题
  • 解析远程连接管理其他机器上的MYSQL数据库
  • MySQL timestamp自动更新时间分享
  • MySQL Order by 语句用法与优化详解
  • 深入解析mysql中order by与group by的顺序问题
  • 解析mysql不重复字段值求和
  • MySql实现跨表查询的方法详解

相关文章

  • 2017-05-11MySQL数学函数简明总结
  • 2017-05-11MySQL-Python安装问题小记
  • 2018-12-05union这个连接是有什么用的和INNER JOIN有什么区别
  • 2017-05-11MYSQL的binary解决mysql数据大小写敏感问题的方法
  • 2018-12-05详细介绍mysql 协议的错误包及解析
  • 2018-12-05MySQL索引用法实例分析_MySQL
  • 2017-05-11mysql连接的空闲时间超过8小时后 MySQL自动断开该连接解决方案
  • 2017-05-11Java实现获得MySQL数据库中所有表的记录总数可行方法
  • 2018-12-05PHP连接数据库,通过面向过程方法实现最基本的增删改查操作
  • 2018-12-05通用分页存储过程,源码共享,大家共同完善

文章分类

  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase

最近更新的内容

    • mysql 5.0.67最新版替代MySQL 5.0.51b版本官方下载
    • php通过Mysqli和PDO连接mysql数据详解
    • 使用存储过程实现循环插入100条记录
    • 数据库系统防黑客入侵技术综述
    • MySQL中主键与索引关系
    • 高效的mysql分页方法及原理
    • MySQL event 计划任务浅析
    • MySQL如何使用UNIQUE来实现数据不重复插入的详细介绍
    • mysql提示[Warning] Invalid (old?) table or database name问题
    • Mysql两种情况下更新字段中部分数据的方法

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有