1、开启mysql的binlog日志,并配置binlog相关参数
binlog_format = ROW
binlog_row_image = FULL
2、将源数据和目标数据对齐
3、数据对齐后,查看mysql的binlog日志的文件和偏移量
SHOW MASTER STATUS; +------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000001 | 571203 | | | +------------------+----------+--------------+------------------+
4、配置文件(binlogfile和binlogfile_offset按上面的查出来的配置)
[src.mysql] host = "10.10.x.x" port = "3306" user = "root" password = "xxxxxx" db = "dsideal_db" encodingdir = "share" encoding = "utf8" binlogfile = "mysql-bin.000001" binlogfile_offset = "571203" [binlogloader] loader_table_list = "loader_table_list.txt" [local.pgsql] connect_string = "host=10.10.x.x dbname=huanghai_temp port=5432 user=root password=xxxxxx" [desc.pgsql] connect_string = "host=10.10.x.x dbname=huanghai_db port=5432 user=root password=xxxxxx" target_schema = "public" ignore_copy_error_count_each_table = "0"
5、启动
#启动 binlog 拉取进程 nohup ./binlog_miner 1>minner.log 2>&1 & #启动 binlog 写入进程 nohup ./binlog_loader 1>loader.log 2>&1 &