本文为您介绍如何安装MMA2.0、准备配置文件和添加函数。
解压工具包
执行如下命令解压工具包。工具包请提工单获取。
tar vxzf odps-data-carrier.tar.gz
解压后的MMA2.0目录结构如下。

准备配置文件
- odp_config.ini
project_name= /* MaxCompute的项目名称 */ access_id=/* 阿里云账号的AccessKey ID */ access_key=/* 阿里云账号的AccessKey Secret */ end_point=/* MaxCompute服务所在地域的Endpoint */
- hive_config.ini
jdbc_connection_url=/* Hive JDBC连接串 */ user=/* Hive JDBC用户名 */ password=/* Hive JDBC密码 */ hms_thrift_addr=/* Hive Metastore Service的Thrift地址 */
- table_mapping.txt
该配置文件呈现待迁移Hive表与MaxCompute表的对应关系,文件中每一行对应一个Hive表到MaxCompute表的迁移任务。格式如下。
<hive db>.<hive table>:<maxcompute project>.<maxcompute table>
- MMA Server配置文件
执行如下命令生成MMA Server配置文件。
cd odps-data-carrier/conf/ sh ../bin/generate-config ./ --to_server_config ./ --hive_config hive_config.ini --odps_config odps_config.ini
- MMA Client配置文件
执行如下命令生成MMA Client配置文件。
cd odps-data-carrier/conf/ sh ../bin/generate-config ./ --to_client_config ./ --hive_config hive_config.ini
- MMA迁移任务配置文件
MMA2.0支持如下四种迁移作业模式,您可以根据迁移场景选择合适的迁移模式。
- 全服务迁移(All Databases To One Project)
配置文件模板如下。
{ "user": "Jon", "globalAdditionalTableConfig": { "partitionGroupSize": 100, "retryTimesLimit": 3 }, "serviceMigrationConfig": { "destProjectName": "test_project" } }
destProjectName表示目标MaxCompute项目的名称。
- 整库迁移(One Database To One Project)
配置文件模板如下。
{ "user": "Jerry", "globalAdditionalTableConfig": { "partitionGroupSize": 100, "retryTimesLimit": 3 }, "databaseMigrationConfigs": [ { "sourceDatabaseName": "test_db", "destProjectName": "test_project" } ] }
- 表级迁移(DB.table To Project.table)
您可以基于table_mapping.txt文件,使用
generate-config
命令生成配置文件。命令格式如下。cd odps-data-carrier/conf/ sh ../bin/generate-config ./ --to_migration_config ./ --table_mapping table_mapping.txt
- 分区级迁移(DB.table.partition To Project.table.partition)
配置文件模板如下。
{ "user": "Jerry", "globalAdditionalTableConfig": { "partitionGroupSize": 100, "retryTimesLimit": 3 }, "tableMigrationConfigs": [ { "sourceDataBaseName": "test_db", "sourceTableName": "test_partitioned_table", "destProjectName": "test_project", "destTableName": "test_partitioned_table", "partitionValuesList": [ ["foo", "123456"], ["bar", "234567"], ] "additionalTableConfig": { "partitionGroupSize": 100, "retryTimesLimit": 3 } } ] }
partitionValuesList表示待迁移分区的分区值列表。假设表的分区列为
c1 STRING
和c2 BIGINT
,示例模板中partitionValuesList表示的分区即为c1="foo",c2=123456
c1="bar",c2=234567
。
- 全服务迁移(All Databases To One Project)
添加函数
上传配置文件和资源包,并通过Hive客户端Beeline添加函数。
- 执行如下命令上传odps_config.ini配置文件。
cd odps-data-carrier/conf/ hdfs dfs -put -f odps_config.ini hdfs:///tmp/odps_config.ini
- 执行如下命令上传UDTF的JAR包。JAR包为工具包lib目录下的data-transfer-hive-udtf-1.0-SNAPSHOT-jar-with-dependencies.jar。
cd odps-data-carrier/lib/ hdfs dfs -put -f data-transfer-hive-udtf-1.0-SNAPSHOT-jar-with-dependencies.jar hdfs:///tmp/data-transfer-hive-udtf-1.0-SNAPSHOT-jar-with-dependencies.jar
- 启动Beeline,并添加函数。
在文档使用中是否遇到以下问题
更多建议
匿名提交