当前位置:   article > 正文

DataX之MySQL数据写入Hive_datax写入hive

datax写入hive

1、编写脚本mysql-to-hive.json

{
    "job": {
        "setting": {
            "speed": {
                 "channel": 3
            },
            "errorLimit": {
                "record": 0,
                "percentage": 0.02
            }
        },
        "content": [
            {
                "reader": {
                    "name": "mysqlreader",
                    "parameter": {
                        "username": "用户名",
                        "password": "密码",
                        "column": [
				"deptno",
				"dname",
				"loc"
                        ],
                        "connection": [
                            {
                                "table": [
                                    "dept"
                                ],
                                "jdbcUrl": [
					"jdbc:mysql://IP:3306/test"
                                ]
                            }
                        ]
                    }
                },
               "writer": {
                    "name": "hdfswriter",
                    "parameter": {
			"defaultFS": "hdfs://hdfs-ha",
		    "hadoopConfig":{
			"dfs.nameservices": "hdfs-ha",
			"dfs.ha.namenodes.hdfs-ha": "nn1,nn2",
			"dfs.namenode.rpc-address.hdfs-ha.nn1": "node01:8020",
			"dfs.namenode.rpc-address.hdfs-ha.nn2": "node02:8020",
			"dfs.client.failover.proxy.provider.hdfs-ha": "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider"
			},
                        "fileType": "text",
                        "path": "/user/hive/warehouse/ods.db/datax_dept",
                        "fileName": "202104",
                        "column": [
                            {
                                "name": "deptno",
                                "type": "int"
                            },
                            {
                                "name": "dname",
                                "type": "varchar"
                            },
                            {
                                "name": "loc",
                                "type": "varchar"
                            }
                        ],
                        "writeMode": "append",
                        "fieldDelimiter": "\t"
                    }
                }
            }
        ]
    }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72

2、执行脚本

/datax/bin/datax.py ./mysql-to-hive.json
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/141172
推荐阅读
相关标签
  

闽ICP备14008679号