错误:
exception “GC Overhead limit exceeded
原因:
Why Sqoop Import throws this exception?
The answer is – During the process, RDBMS database (NOT SQOOP) fetches all the rows at one shot and tries to load everything into memory. This causes memory spill out and throws error. To overcome this you need to tell RDBMS database to return the data in batches. The following parameters “?dontTrackOpenResources=true&defaultFetchSize=10000&useCursorFetch=true” following the jdbc connection string tells database to fetch 10000 rows per batch.
因为数据量较大,sqoop在导入hive的时候会将数据直接读到内存中,然后会导致内存溢出。
解决方案:
1、指定mappers的数量(默认为4个,数量最好不要超过节点的个数)
sqoop job --exec gp1813_user -- --num-mappers 8;
2、调整jvm的内存,直接加在sqoop的job中。
-Dmapreduce.map.memory.mb=6000 \
-Dmapreduce.map.java.opts=-Xmx1600m \
-Dmapreduce.task.io.sort.mb=4800 \
3、设置mysql的读取数据的方式,不要一次性将所有数据都fetch到内存
?dontTrackOpenResources=true&defaultFetchSize=10000&useCursorFetch=true
sqoop job \
--create gp_us_order1 -- import \
--connect jdbc:mysql://hadoop01:3306/bap_ods?dontTrackOpenResources=true\&defaultFetchSize=10000\&useCursorFetch=true \
--username root \
--password-file /sqoop/pwd/gp1918SqoopPWD \
--table us_order \
--target-dir /hive/tmpdb/ods_us_order \
--fields-terminated-by '\001' \
--check-column order_id \
--incremental append \
--last-value 0
建议采用第三种方式,官方说明的问题。
解决Sqoop导入大数据时的'GC Overhead limit exceeded'错误
当使用Sqoop导入大量数据到Hive时,由于一次性加载所有行到内存,可能导致'GC Overhead limit exceeded'错误。解决方法包括指定mappers数量、调整JVM内存或设置数据库返回数据的批处理方式,如在JDBC连接字符串中添加参数以分批读取数据。
2170

被折叠的 条评论
为什么被折叠?



