由M--〉S1变为M-->S1&M-->S2

场景:由M--〉S1变为M-->S1&M-->S2

传统复制:

环境:

M:10.1.12.122 ,3306

S1:10.1.12.123,3306

拟添加的S2:10.1.12.122,3307

1) 从S1:10.1.12.123,3306 导出数据:

[[email protected] ~]$ mysqldump -uroot -p  --single-transaction --dump-slave=2 -A >123slave.sql

Enter password:

Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don‘t want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events.

注意:使用 --dump-slave参数,而不是master-data=2参数

2)构建chang master 语句

more 123slave.sql

#CHANGE MASTER TO MASTER_LOG_FILE=‘mysql-bin.000011‘, MASTER_LOG_POS=1793;

在M上执行show master status

+------------------+----------+--------------+------------------+-------------------------------------------+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set                         |

+------------------+----------+--------------+------------------+-------------------------------------------+

| mysql-bin.000011 |     1793 |              |                  | d26e7493-ce3a-11e6-90ff-005056a42880:1-27 |

+------------------+----------+--------------+------------------+-------------------------------------------+

1 row in set (0.00 sec)

使用的主库的binlog位置

CHANGE MASTER TO

MASTER_HOST=‘10.1.12.122‘,

MASTER_PORT=3306,

MASTER_USER=‘rep1‘,

MASTER_PASSWORD=‘pass1234‘,

MASTER_LOG_FILE=‘mysql-bin.000011‘,

MASTER_LOG_POS=1793;

3)导入数据,执行change mater语句

[[email protected] ~]$ mysql -h127.0.0.1 -uroot -ppass1234 -P3307<123slave.sql

mysql> CHANGE MASTER TO

-> MASTER_HOST=‘10.1.12.122‘,

-> MASTER_PORT=3306,

-> MASTER_USER=‘rep1‘,

-> MASTER_PASSWORD=‘pass1234‘,

-> MASTER_LOG_FILE=‘mysql-bin.000011‘,

-> MASTER_LOG_POS=1793;

ERROR 1776 (HY000): Parameters MASTER_LOG_FILE, MASTER_LOG_POS, RELAY_LOG_FILE and RELAY_LOG_POS cannot be set when MASTER_AUTO_POSITION is active.

解决:mysqladmin -uroot -ppass1234 -h127.0.0.1 -P3307 shutdown

重启数据库后,执行成功;

使用GTID方式:

1)清理环境

在10.1.12.122,3307, drop database,reset slave&master

2)重新导出和导入数据:

CHANGE MASTER TO

MASTER_HOST=‘10.1.12.122‘,

MASTER_PORT=3306,

MASTER_USER=‘rep1‘,

MASTER_PASSWORD=‘pass1234‘,

MASTER_AUTO_POSITION=1;

由M--〉S1变为M-->S1&M-->S2

时间: 2024-11-05 12:24:13

由M--〉S1变为M-->S1&M-->S2的相关文章

short s1 = 1; s1 = s1 + 1;和 s1 += 1;

对于short s1 = 1; s1 = s1 + 1; 由于s1+1运算时会自动提升表达式的类型,所以结果是int型,再赋值给short类型s1时,编译器将报告需要强制转换类型的错误. 对于short s1 = 1; s1 += 1;由于 += 是java语言规定的运算符,java编译器会对它进行特殊处理,因此可以正确编译.

C 在一个字串s1中查找一子串s2,若存在则返回s1中s2的个数和位置

在一个字串s1中查找一子串s2,若存在则返回s1中s2出现次数和位置 #include<stdio.h> #include<string.h> void main() { char s1[100],s2[10]; int i,j,k,len1,len2,b[10]; gets(s1); gets(s2); len1=strlen(s1); len2=strlen(s2); for(i=0,k=0;i<len1;i++) { for(j=0;j<len2;j++) if(

squeeze(s1,s2),将字符串s1中任何与字符串s2中匹配的字符都删除

void squeeze(char a[],char b[]) { //要实现把s2的任意字符如果出现的话就在s1中删除 //1.首先判断s1[j]==s2[i]&&s1[j]=='\0' int j,i; for( j=0;b[j]!='\0';j++)//遍历一遍b[] { for(i=0;a[i]!='\0';i++)//遍历一遍a { if(a[i]==b[j]) for(int m=i;(a[m]=a[1+m])!='\0';m++);//消除元素 } } } //其实里面那些{

445. Add Two Numbers II ——while s1 or s2 or carry 题目再简单也要些测试用例

You are given two linked lists representing two non-negative numbers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not con

经典算法面试题目-判断s2是否是s1的旋转字符串(1.8)

题目 Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring ( i.e., "waterbottle" is a rotation of &qu

将字符串s1中的任何与字符串s2中字符匹配的字符都删除

编写一个程序,将字符串s1中的任何与字符串s2中字符匹配的字符都删除. 函数原型:void my_squeeze(char s1[], char s2[]) #include <stdio.h> void my_squeeze(char s1[], char s2[]) { int i = 0; int j = 0; while (s2[j]) { while(s1[i]) { if (s2[j]==s1[i]) { while (s1[i+1]) { s1[i] = s1[i + 1]; i

short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错?

对于short s1 = 1; s1 = s1 + 1; 由于s1+1运算时会自动提升表达式的类型,所以结果是int型,再赋值给short类型s1时,编译器将报告需要强制转换类型的错误.对于short s1 = 1; s1 += 1;由于 += 是java语言规定的运算符,java编译器会对它进行特殊处理,因此可以正确编译.

97. Interleaving String *HARD* -- 判断s3是否为s1和s2交叉得到的字符串

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = "aabcc",s2 = "dbbca", When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", return false. class Solution { p

转!!Java 基础面试题的剖析: short s1=1;s1 = s1 +1 报错? s1+=1 呢

short s1=1;s1 = s1 +1会报错吗? package common; public class ShortTypeTest { /* * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub short s1 = 1; s1 = (short) (s1 + 1);//简单类型 short s2=1; s2 +=1;//复合类型,复合赋值操作符+=, Sy

hdu 2203 亲和串(给两个字符串s1,s2,问s2可不可能出现在以s1为循环节的串中)

1.strcat函数,strcat(char *s , char *p);注意这里的s和p所指内存区域不可以重叠且s必须有足够的空间来容纳p的字符串 2.strcpy函数,strcpy(char *s,char *p),将p拷贝到s 3.代码: #include<cstdio> #include<cstring> using namespace std; char s1[1000000],s2[100005],t[1000000]; int len1,len2; //int LCP