Datax(1) - 읽기/쓰기 MySQL-To-MySQL-(Win10 설치)

13625 단어 DataX빅데이터
소개
DataX는 알리바바 그룹 내에서 널리 사용되는 오프라인 데이터 동기화 도구/플랫폼으로 MySQL, Oracle, SqlServer, Postgre, HDFS, Hive, ADS, HBase, TableStore(OTS), MaxCompute(ODPS), DRDS 등 각종 이구 데이터 소스 간의 효율적인 데이터 동기화 기능을 실현한다.
환경 준비
1:Java 1.8.0_231 2.Python 3.6.5 3.MySQL:5.5.53 3.Datax:http://datax-opensource.oss-cn-hangzhou.aliyuncs.com/datax.tar.gz(약 800M) 다운로드 주소:https://github.com/alibaba/DataX페이지 Download DataX 다운로드 주소
셋째: 구성
1. 데이터 준비:
MySQL 라이브러리 만들기:sourcedb 테이블 만들기:tuser_info
CREATE TABLE `t_user_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `content` text,
  `createdate` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

도수:
INSERT INTO `sourcedb`.`t_user_info` (`id`, `name`, `content`, `createdate`) VALUES ('1', 'linux  mysql   ', 'linux  mysql   ', '2020-04-19 21:18:58');
INSERT INTO `sourcedb`.`t_user_info` (`id`, `name`, `content`, `createdate`) VALUES ('2', 'jQuery input      ', 'jQuery input      ', '2020-04-20 21:19:14');
INSERT INTO `sourcedb`.`t_user_info` (`id`, `name`, `content`, `createdate`) VALUES ('3', 'Web  Session    ', 'Web  Session    ', '2020-04-21 21:19:19');

라이브러리 만들기:targetdb 테이블 만들기:tuser_info
CREATE TABLE `t_user_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `content` text,
  `createdate` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

2. DataX 구성
파이썬을 지원하려면 DataX 기본py 파일 다운로드를 수정해야 합니다.https://github.com/WeiYe-Jing/datax-web/tree/master/doc/datax-web/datax-python3데이터x/bin/datax를 바꿉니다.py,datax/bindxprof.py,datax/binperftrace.py
3. 실행 파일 준비: 데이터x/task/mysql3_mysql.json
{
     
    "job": {
     
        "setting": {
     
            "speed": {
     
                "channel": 1
            }
        },
        "content": [
            {
     
                "reader": {
     
                    "name": "mysqlreader",
                    "parameter": {
     
                        "username": "root",
                        "password": "111111",
                        "column": [ "id", "name","content" ,"createdate"],
                        "splitPk": "id",
                        "connection": [
                            {
     
                                "table": [
                                    "t_user_info"
                                ],
                                "jdbcUrl": [
                                    "jdbc:mysql://127.0.0.1:3306/sourcedb"
                                ]
                            }
                        ]
                    }
                },
                "writer": {
     
                    "name": "mysqlwriter",
                    "parameter": {
     
                        "writeMode": "insert",
                        "username": "root",
                        "password": "111111",
                        "column": [ "id", "name","content","createdate"],
                        "session": [
                            "set session sql_mode='ANSI'"
                        ],
                        "preSql": [
                            "delete from t_user_info"
                        ],
                        "connection": [
                            {
     
                                "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/targetdb",
                                "table": [
                                    "config"
                                ]
                            }
                        ]
                    }
                }
            }
        ]
    }
}

실행
cd datax
python .\bin\datax.py .\task\mysql-2-mysql.json
bytes |  All Task WaitWriterTime 0.000s |  All Task WaitReaderTime 0.000s | Percentage 100.00%

다섯: 검증
use targetdb;
select * from t_user_info;

sourcedb 중 tuser_info 데이터가 targetdb의 t 로 복사됨user_info 표
완성

좋은 웹페이지 즐겨찾기