当前位置:网站首页>Configure MySQL master-slave replication with mysqldump or mydumper
Configure MySQL master-slave replication with mysqldump or mydumper
2022-07-23 19:54:00 【wzy0623】
1. Use mysqldump
cat dump_and_replication.sh
#!/bin/bash
source ~/.bashrc
mysql -uroot -p123456 -S /data/3306/mysqldata/mysql.sock -D db1 -e "
set global sql_log_bin=0;
alter table t1 drop primary key, drop index Index_1, drop index Index_2;
"
date
mysqldump -uroot -p123456 -h192.168.1.36 -P3306 --quick --no-create-info --apply-slave-statements --single-transaction db1 t1 --master-data=1 --set-gtid-purged=OFF | mysql -uroot -p123456 -S /data/3306/mysqldata/mysql.sock -D db1
date
mysql -uroot -p123456 -S /data/3306/mysqldata/mysql.sock -D db1 -e "
stop slave;
alter table t1 add primary key (id), add index Index_1 (c1,c2), add index Index_2 (c3,c4);
start slave;"
date
mysql -uroot -p123456 -S /data/3306/mysqldata/mysql.sock -D db1 -e "set global sql_log_bin=1;"2. Use mydumper
Download and install :https://github.com/mydumper/mydumper
cat dumper_and_loader.sh
#!/bin/bash
source ~/.bashrc
mysql -uroot -p123456 -S /data/3306/mysqldata/mysql.sock -D db1 -e "set global sql_log_bin=0;"
rm -rf /data1/mydumper/*
date
mydumper -h 192.168.1.36 -P 3306 --user root --password 123456 -o /data1/mydumper/ -t 8 -B db1 -T t1
cat ~/drop_index.sql >> /data1/mydumper/t1-schema.sql
date
myloader -u root -p 123456 -o -t 16 -d /data1/mydumper/ -S /data/3306/mysqldata/mysql.sock
master_log_file=`cat /data1/mydumper/metadata | grep Log | head -1 | awk -F': ' '{print $2}'`
master_log_pos=`cat /data1/mydumper/metadata | grep Pos | head -1 | awk -F': ' '{print $2}'`
change_master="stop slave; reset slave all; change master to master_host='192.168.1.36', master_port=3306, master_user='root', master_password='123456', master_log_file='$master_log_file', master_log_pos=$master_log_pos; start slave; show slave status\G"
echo $change_master
date
mysql -uroot -p123456 -S /data/3306/mysqldata/mysql.sock -Ddb1 < ~/add_index.sql
mysql -uroot -p123456 -S /data/3306/mysqldata/mysql.sock -e "$change_master"
date
mysql -uroot -p123456 -S /data/3306/mysqldata/mysql.sock -D space -e "set global sql_log_bin=1;"cat drop_index.sql
alter table t1 drop index idx1, drop index idx2, drop index idx3;cat add_index.sql
alter table t1 add index idx1 (c1), add index idx2 (c2), add index idx3 (c3);边栏推荐
- R语言data.table包进行数据分组聚合统计变换(Aggregating transforms)、计算dataframe数据的分组最小值(min)
- Safely stop NodeOS
- [英雄星球七月集训LeetCode解题日报] 第23日 字典树
- 安全停止nodeos
- [interview: concurrent Article 22 multithreading: reentrantlock]
- Principe de l'énergie et méthode variationnelle note 19: principe de l'énergie résiduelle minimale + principe du travail possible
- Lecture 9 of project practice -- operation import and export tool
- Analyse de l'industrie | interphone logistique
- Brief analysis of compiling principle of.Net CLR R2R
- Powercli management VMware vCenter one click batch deployment OVF
猜你喜欢

PowerCLi 将虚拟机从Host01主机移动到Host02主机

为啥一问 JVM 就 懵B ?

Powercli management VMware vCenter batch deployment export import

二、MFC窗口和消息

3D point cloud course (VII) -- feature point description

编译器LLVM-MLIR-Intrinics-llvm backend-instruction

ACM MM 2022 Oral | DIG: 自监督文字识别的新框架,刷新11个公开场景文字数据集的识别性能,平均提升5%...

selenium中元素定位正确但是操作失败,6种解决办法全稿定

Energy principle and variational method note 12: minimum potential energy principle

Energy principle and variational method note 17: generalized variational principle (identification factor method)
随机推荐
攻防世界web题-fakebook
简历上写的电商,那请问Redis 如何实现库存扣减操作和防止被超卖?
吃透Chisel语言.21.Chisel时序电路(一)——Chisel寄存器(Register)详解
Hongke dry goods | teaches you how to parse floating-point data in MODBUS
Cannot read properties of null (reading ‘pickAlgorithm‘)
Energy principle and variational method note 12: minimum potential energy principle
MySQL 数据恢复 —— 使用 data 目录
R语言使用ggpubr包的ggarrange函数将多幅图像组合起来、使用ggexport函数将可视化图像保存为bmp格式(width参数指定宽度、height参数指定高度、res参数指定分辨率)
结构体大小的计算(结构体内存对齐)
Powercli management VMware vCenter batch deployment export import
Ggarrange function of R language ggpubr package combines and annotates multiple images_ Figure add annotation, annotation, annotation information to the combined image, and add annotation information
家用 NAS 服务器(3)| SSD缓存加速机械硬盘
PowerCLi 管理VMware vCenter 批量部署导出导入
PC performance monitoring tool is an indispensable helper for software testers
R language uses the gather function of tidyr package to convert a wide table to a long table (wide table to long table), the first parameter specifies the name of the new data column generated from th
(干货)结合Scikit-learn介绍几种常用的特征选择方法
R语言使用dwilcox函数生成Wilcoxon秩和统计分布密度函数数据、使用plot函数可视化Wilcoxon秩和统计分布密度函数数据
Solutions to SecureCRT garbled code problem [easy to understand]
Analyse de l'industrie | interphone logistique
R language uses the ggarrange function of ggpubr package to combine multiple images, and uses the ggexport function to save the visual images in BMP format (width parameter specifies width, height par