[mysqld]
log-bin=mysql-bin #添加这一行就ok
binlog-format=ROW #选择row模式
server_id=1 #配置mysql replaction需要定义,不能和canal的slaveId重复

b. canal的原理是模拟自己为mysql slave,所以这里一定需要做为mysql slave的相关权限.

CREATE USER canal IDENTIFIED BY 'canal';
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
-- GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%' ;
FLUSH PRIVILEGES;
  1. Download and add the repository, then update.

     
    wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
    sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
    yum update
  2. Install MySQL as usual and start the service. During installation, you will be asked if you want to accept the results from the .rpm file’s GPG verification. If no error or mismatch occurs, enter y.

     
    sudo yum install mysql-server
    sudo systemctl start mysqld
sudo nano /etc/mysql/my.cnf

We have to make sure that we have a few things set up in this configuration. The first is the server-id. This number, as mentioned before needs to be unique. Since it is set on the default (still 1), be sure to change it’s something different.

server-id               = 2

Following that, make sure that your have the following three criteria appropriately filled out:

relay-log               = /var/log/mysql/mysql-relay-bin.log
log_bin                 = /var/log/mysql/mysql-bin.log
binlog_do_db            = newdatabase

You will need to add in the relay-log line: it is not there by default. Once you have made all of the necessary changes, save and exit out of the slave configuration file.

Restart MySQL once again:

sudo service mysql restart

The next step is to enable the replication from within the MySQL shell.

Open up the the MySQL shell once again and type in the following details, replacing the values to match your information:

CHANGE MASTER TO MASTER_HOST='12.34.56.789',MASTER_USER='slave_user', MASTER_PASSWORD='password', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=  107;

This command accomplishes several things at the same time:

  1. It designates the current server as the slave of our master server.
  2. It provides the server the correct login credentials
  3. Last of all, it lets the slave server know where to start replicating from; the master log file and log position come from the numbers we wrote down previously.

With that—you have configured a master and slave server.

Activate the slave server:

START SLAVE;

You be able to see the details of the slave replication by typing in this command. The \G rearranges the text to make it more readable.

SHOW SLAVE STATUS\G

If there is an issue in connecting, you can try starting slave with a command to skip over it:

SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; SLAVE START; 

MySQL 错误处理 Got fatal error 1236 from master when reading data from binary log

在master那边,执行:

flush logs;
show master status;

记下File, Position。

在slave端,执行:

CHANGE MASTER TO MASTER_LOG_FILE='testdbbinlog.000xxxx',MASTER_LOG_POS=xxxxx;
slave start;
show slave status \G

canal mysql slave的更多相关文章

  1. canal+mysql+kafka实时数据同步安装、配置

    canal+mysql+kafka安装配置 概述 简介 canal译意为水道/管道/沟渠,主要用途是基于 MySQL 数据库增量日志解析,提供增量数据订阅和消费. 基于日志增量订阅和消费的业务包括 数 ...

  2. 处理一则MySQL Slave环境出现ERROR 1201 (HY000): Could not initialize master info structure的案例

    mysql> start slave; ERROR (HY000): Slave failed to initialize relay log info structure from the r ...

  3. Mysql slave 同步错误解决

    涉及知识点 mysql 主从同步 ,参考: MySQL数据库设置主从同步 mysqlbin log查看, 参考:MySQL的binlog日志 解决slave报错, 参考: Backup stopped ...

  4. 乌龙之MySQL slave IO status:connecting

    搭建了一个主从,状态一直如下: 检查错误日志报错如下: review搭建过程,语法并没有问题. 检查用户及网络,也没有问题: so?what is the cause ? 等等....貌似上面搭建用的 ...

  5. xtrabackup备份方式搭建一个mysql slave

    以前mysql搭建新备库都是在现在业务较小的备库上停止同步或停止数据库,然后拷贝数据库到新备库,配置好新备库后,再开启同步或数据库.然而,这次没有空闲备库用来搭新备库.需要从一个业务繁忙的数据库中搭建 ...

  6. 使用Percona Xtrabackup创建MySQL slave库

    一.使用Percona Xtrabackup创建MySQL slave库 MySQL Server 版本: Server version: 5.7.10-log MySQL Community Ser ...

  7. innobackupex 备份数据搭建 MySQL Slave

    简介: 数据量比较大时,使用 innobackupex 备份数据新增 MySQL Slave 节点. 安装 innobackupex 工具,我这里写过一次:http://www.cnblogs.com ...

  8. (转)使用参数SQL_SLAVE_SKIP_COUNTER处理mysql slave同步错误讨论

    使用参数SQL_SLAVE_SKIP_COUNTER处理mysql slave同步错误讨论 本文链接地址:http://blog.chinaunix.net/uid-31396856-id-57532 ...

  9. 普通用户Mysql 5.6.13 主从,主主及nagios的mysql slave监控

    Master:192.168.209.19 Slave:192.168.209.20 mysql版本:mysql5.6.13 1. 以root身份创建普通用户,如mysql,并创建mysql安装目录: ...

随机推荐

  1. C# .Net 中字典Dictionary<TKey,TValue>泛型类 学习浅谈

    一.综述: Dictionary<TKey,TValue>是在 .NET Framework 2.0 版中是新增的.表示键值对的集合,Dictionary<TKey,TValue&g ...

  2. pta总结1

    7-1 打印沙漏 (20 分) 本题要求你写个程序把给定的符号打印成沙漏的形状.例如给定17个"*",要求按下列格式打印 所谓"沙漏形状",是指每行输出奇数个符 ...

  3. kettle使用文件导入到Postgresql出现如下几种问题的总结

    1.kettle使用文件导入到Postgresql出现如下几种问题的总结: kettle使用文件导入到Postgresql出现如下几种问题的总结: .第一种错误,报错如ERROR: extra dat ...

  4. xmind-HTTP协议

  5. echarts移动端中例子总结。

    接下来我总结一下我常用到的几个移动端echarts小例子: 第一步:我先引入自己想要的库 第二步: 给echarts给了一个窗口(有大小的窗口) 第三步: 开始引入你想要的图形的options 我做的 ...

  6. Ubuntu16.04下Hadoop的本地安装与配置

    一.系统环境 os : Ubuntu 16.04 LTS 64bit jdk : 1.8.0_161 hadoop : 2.6.4 部署时使用的用户名为hadoop,下文中需要使用用户名的地方请更改为 ...

  7. 蓝桥杯 全球变暖(dfs)

    标题:全球变暖 [题目描述]你有一张某海域NxN像素的照片,"."表示海洋."#"表示陆地,如下所示: 其中"上下左右"四个方向上连在一起的 ...

  8. Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0 报错

    此报错经常出现,项目中使用的maven版本为3.2.5版本但是去写自动化脚本又需要去3.5.2版本.经常搞混,需要记录一下: 解决如下: 再次install如下: 验证成功!

  9. XV Open Cup named after E.V. Pankratiev. GP of Three Capitals

    A. Add and Reverse 要么全部都选择$+1$,要么加出高$16$位后翻转位序然后再补充低$16$位. #include<stdio.h> #include<iostr ...

  10. VB进行RGB分色

    Option Explicit Private Type RGBA R As Byte G As Byte B As Byte A As Byte End Type Private Declare S ...