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 &