Datax(1) - 읽기/쓰기 MySQL-To-MySQL-(Win10 설치)
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 표
완성
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
대인기의 Github 기계 학습 아이템을 소개 5선 - ScrapeStorm이 기사에서는 다섯 가지 인기있는 GitHub 기계 학습 항목을 소개합니다. 이러한 항목에는 자연 언어 처리(NLP), 컴퓨터 비전, 빅 데이터 등 다양한 기계 학습 분야가 포함되어 있습니다. NLP는 텍스트의 처리...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.