Datax使用

下载地址

下载地址:https://github.com/alibaba/DataX

实际使用
python datax.py --jvm="-Xms5G -Xmx5G" ../job/test.json -p "-Ddt=20190722 -Ddn=webA"
hive到mysql的配置文件
{
	"job": {
		"setting": {
			"speed": {
				"channel": 3
			}
		},
		"content": [{
			"reader": {
				"name": "hdfsreader",
				"parameter": {
					"path": "/user/hive/warehouse/ads.db/ads_user_question_detail/dt=${dt}/dn=${dn}/*",
					"hadoopConfig":{
                        "dfs.nameservices": "nameservice1",
                      	"dfs.ha.namenodes.nameservice1": "namenode30,namenode37",
                      	"dfs.namenode.rpc-address.nameservice1.namenode30": "hadoop001:8020",
                      	"dfs.namenode.rpc-address.nameservice1.namenode37": "hadoop002:8020",
                     	"dfs.client.failover.proxy.provider.nameservice1": "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider"	                                  
    				},
					"defaultFS": "hdfs://nameservice1",
						"column": [{
							"index": 0,
							"type": "string"
						},
						{
							"index": 1,
							"type": "string"
						},
						{
							"index": 2,
							"type": "string"
						},
						{
							"index": 3,
							"type": "string"
						},
						{
							"value": "${dt}",
							"type": "string"
						},
						{
							"value": "${dn}",
							"type": "string"
						}
					],
					"fileType": "text",
					"encoding": "UTF-8",
					"fieldDelimiter": "\t"
				}
			},
			"writer": {
				"name": "mysqlwriter",
				"parameter": {
					"writeMode": "insert",
					"username": "root",
					"password": "123456",
					"column": [
					    "questionid",
						"errcount",
						"rightcount",
						"rate",
						"dt",
						"dn"
					],
					"preSql": [
						"delete from user_question_detail where dt=${dt}"
					],
					"connection": [{
						"jdbcUrl": "jdbc:mysql://hadoop003:3306/qz_paper?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false",
						"table": [
							"user_question_detail"
						]
					}]
				}
			}
		}]
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值