Goldengate complete mysql-to-MySQL data synchronization

Source: Internet
Author: User
Tags mysql version

Document reference Address: http://blog.csdn.net/u010587433/article/details/49305019

Demand:

Using goldengate to complete MySQL-to-MySQL data synchronization, the source library's O2M-MC library synchronizes to the GMDC library of the target library, the table name gmqdsjsp, in other words, the synchronization of data between tables between different databases

Experiment Preparation:

System: CentOS 7.2

MySQL version: 5.7-12

MYSQL-1:192.168.68.13 mysql-2:192.168.68.14

1. Initialization

1) Target Library CREATE database

mysql> CREATE DATABASE GMDC;

2) Import data

Export the Source Library table gmqdsjsp data and import it into the target library

[SQL]View PlainCopy
    1. mysqldump-uroot-p123456 --single-transaction--flush-logs--master-data=2-b o2m-mc--tables GMQDSJSP >/tmp/GMQ Dsjsp20151021.sql
    2. mysql-uroot-p123456 GMDC </tmp/gmqdsjsp20151021.sql

2. Source Library

1) Modify the parameters

Under/etc/my.cnf [mysqld], add the following parameters

[SQL]View PlainCopy
    1. Binlog_format=row
    2. Log-bin = Mysql-bin #开启二进制日志

Restart

[SQL]View PlainCopy
    1. Service Mysqld REStat

2) Create user and authorize

[SQL]View PlainCopy
    1. Mysql> GRANT all privileges in ' O2M-MC '. * to ' ogg ' @localhost identified by ' Ogg;
    2. Mysql> GRANT All privileges the ' o2m-mc '. * to ' ogg ' @'% ' identified by ' Ogg;

3) Unzip the installation to create the appropriate directory

[SQL]View PlainCopy
  1. Unzip ggs_121210_linux_x64_mysql_64bit.zip-d/home/goldengate
  2. Cd/home/goldengate
  3. Tar xvf Ggs_linux_x64_mysql_64bit.tar
  4. ./ggsci
  5. Ggsci (hadooptest05) 1> Create Subdirs
  6. Creating subdirectories under current directory/home/goldengate
  7. Parameter Files/home/goldengate/dirprm:already exists
  8. Report files/home/goldengate/dirrpt:created
  9. Checkpoint files/home/goldengate/dirchk:created
  10. Process Status files/home/goldengate/dirpcs:created
  11. SQL Script files/home/goldengate/dirsql:created
  12. Database Definitions files/home/goldengate/dirdef:created
  13. Extract Data files/home/goldengate/dirdat:created
  14. Temporary files/home/goldengate/dirtmp:created
  15. Credential Store files/home/goldengate/dircrd:created
  16. Masterkey Wallet Files/home/goldengate/dirwlt:created
  17. Dump files/home/goldengate/dirdmp:created

4) configuration Management process

[SQL]View PlainCopy
    1. Ggsci (hadooptest05) 2> edit params Mgr
    2. Port 7809
    3. Dynamicportlist 7840-7939
    4. AutoRestart er *, retries 5, Waitminutes 3
    5. Purgeoldextracts/home/goldengate/dirdat/*,usecheckpoints, Minkeepdays 2
    6. Ggsci (hadooptest05) 3> start Mgr
    7. Manager started.

5) Configuring the extraction process

[SQL]View PlainCopy
  1. Ggsci (hadooptest05) 4> edit param Mce1
  2. Extract Mce1
  3. sourcedb [email protected]:3306 userid ogg password ogg
  4. Exttrail/home/goldengate/dirdat/me
  5. Discardfile/home/goldengate/dirrpt/mce1.dsc,append
  6. Tranlogoptions Altlogdest/home/mariadb/data/binlogs. Index
  7. Table O2M-MC. gmqdsjsp;
  8. Ggsci (hadooptest05) 5> Add extract mce1,tranlog,begin now
  9. Ggsci (hadooptest05) 6> add exttrail/home/goldengate/dirdat/me,extract mce1
  10. Ggsci (hadooptest05) 7> start Mce1

6) Configuring the delivery process

[SQL]View PlainCopy
  1. Ggsci (hadooptest05) 8> edit param MCP1
  2. Extract MCP1
  3. PassThru
  4. sourcedb [email protected]:3306 userid ogg password ogg
  5. Rmthost 192.168.68.14,mgrport 7809,compress
  6. Rmttrail/home/goldengate/dirdat/mp
  7. Dynamicresolution
  8. Numfiles 3000
  9. Table O2M-MC. gmqdsjsp;
  10. Ggsci (hadooptest05) 9> Add extract mcp1,exttrailsource/home/goldengate/dirdat/me
  11. Ggsci (hadooptest05) 10> add rmttrail/home/goldengate/dirdat/mp,extract mcp1
  12. Ggsci (hadooptest05) 11> start MCP1

7) Create a definition file for the table

[SQL]View PlainCopy
    1. #创建参数文件
    2. Ggsci (hadooptest05) 10> edit param Defgen
    3. Defsfile./dirdef/gmqdsjsjp.def
    4. sourcedb [email protected]:3306 userid ogg, password ogg
    5. Table O2M-MC. gmqdsjsp;
    6. #生成表定义文件
    7. ./defgen Paramfile./DIRPRM/DEFGEN.PRM
    8. #传至目标库目录
    9. Scp/home/mysql/goldengate/dirdef/gmqdsjsjp.def 192.168.68.14:/home/goldengate/dirdef/

3. Target Library

1) Create user

[SQL]View PlainCopy
    1. Mysql> GRANT all privileges in ' GMDC '. * to ' ogg ' @localhost identified by ' Ogg ';
    2. Mysql> GRANT all privileges in ' GMDC '. * to ' ogg ' @'% ' identified by ' Ogg '  ;

2) also unzip the installation and create the directory

[SQL]View PlainCopy
  1. Unzip ggs_121210_linux_x64_mysql_64bit.zip-d/home/goldengate
  2. Cd/home/goldengate
  3. Tar xvf Ggs_linux_x64_mysql_64bit.tar
  4. ./ggsci
  5. GGSCI (db) 1> create Subdirs
  6. Creating subdirectories under current directory/home/goldengate
  7. Parameter Files/home/goldengate/dirprm:already exists
  8. Report files/home/goldengate/dirrpt:created
  9. Checkpoint files/home/goldengate/dirchk:created
  10. Process Status files/home/goldengate/dirpcs:created
  11. SQL Script files/home/goldengate/dirsql:created
  12. Database Definitions files/home/goldengate/dirdef:created
  13. Extract Data files/home/goldengate/dirdat:created
  14. Temporary files/home/goldengate/dirtmp:created
  15. Credential Store files/home/goldengate/dircrd:created
  16. Masterkey Wallet Files/home/goldengate/dirwlt:created
  17. Dump files/home/goldengate/dirdmp:created

3) configuration Management process

[SQL]View PlainCopy
    1. GGSCI (db) 3> edit params Mgr
    2. Port 7809
    3. Dynamicportlist 7840-7939
    4. AutoRestart er *, retries 5, Waitminutes 3
    5. Purgeoldextracts/home/goldengate/dirdat/*,usecheckpoints, Minkeepdays 2
    6. GGSCI (db) 4> start Mgr
    7. Manager started.

4) Add Checkpoint table

[SQL]View PlainCopy
    1. GGSCI (db) 5> dblogin sourcedb [email protected]:3306 userid ogg password ogg
    2. GGSCI (DB dblogin as ogg) 6> add checkpointtable gmdc. Checkpoint
    3. GGSCI (DB dblogin as ogg) 7> edit params./globals
    4. Checkpointtable GMDC. Checkpoint

5) Configure the application process

[SQL]View PlainCopy
    1. GGSCI (db) 1> edit params MCR1
    2. Replicat MCR1
    3. targetdb [email protected]:3306 userid ogg password ogg
    4. Handlecollisions
    5. Sourcedefs/home/goldengate/dirdef/gmqdsjsp.def
    6. Discardfile/home/goldengate/dirrpt/mcr1.dsc,purge
    7. Map O2M-MC. gmqdsjsp, Target GMDC. gmqdsjsp;
    8. GGSCI (db) 2> add Replicat mcr1,exttrail/home/goldengate/dirdat/mp,checkpointtable GMDC. Checkpoint
    9. GGSCI (db) 3> start MCR1

4. Test Data synchronization

Note: The size of the table in MySQL is distinguished

Info MGR//view startup information

Goldengate complete mysql-to-MySQL data synchronization

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.