一、Hive-SQL / Spark-SQL參數(shù)配置和調(diào)優(yōu)
#設(shè)置計(jì)算引擎
set hive.execution.engine=spark;
#設(shè)置spark提交模式
set spark.master=yarn-cluster;
#設(shè)置作業(yè)提交隊(duì)列
set spark.yarn.queue=${queue_name};
#設(shè)置隊(duì)列的名字
set mapreduce.job.queuename=root.users.hdfs;
#設(shè)置作業(yè)名稱(chēng)
set spark.app.name=${job_name};
#該參數(shù)用于設(shè)置Spark作業(yè)總共要用多少個(gè)Executor進(jìn)程來(lái)執(zhí)行
set spark.executor.instances=25;
#設(shè)置執(zhí)行器計(jì)算核個(gè)數(shù)
set spark.executor.cores=4;
#設(shè)置執(zhí)行器內(nèi)存
set spark.executor.memory=8g
#設(shè)置任務(wù)并行度
set mapred.reduce.tasks=600;
#設(shè)置每個(gè)executor的jvm堆外內(nèi)存
set spark.yarn.executor.memoryOverhead=2048;
#設(shè)置內(nèi)存比例(spark2.0+)
set spark.memory.fraction=0.8;
#設(shè)置對(duì)象序列化方式
set spark.serializer=org.apache.serializer.KyroSerializer;
#設(shè)置動(dòng)態(tài)分區(qū)
set hive.exec.dynamic.partition=true; --開(kāi)啟動(dòng)態(tài)分區(qū)功能
set hive.exec.dynamic.partition.mode=nonstrict; --允許所有分區(qū)是動(dòng)態(tài)的
set hive.exec.max.dynamic.partitions.pernode=1000; --每個(gè)mapper/reducer可以創(chuàng)建的最大動(dòng)態(tài)分區(qū)數(shù)
--set hive.exec.dynamic.partitions=10000; 這個(gè)可不要
insert overwrite table test partition(country,state) select * from test2; --添加動(dòng)態(tài)分區(qū)示例
二、shell腳本spark-submit參數(shù)配置
#python版本提交spark任務(wù)
spark-submit \
--master yarn \
--deploy-mode client \
--driver-memory 24G \
--driver-cores 8 \
--num-executors 100 \
--executor-cores 8 \
--executor-memory 24G \
--conf spark.driver.maxResultSize=24G \
--conf spark.kubernetes.executor.limit.cores=12 \
--conf spark.kryoserializer.buffer.max=1024m \
--conf spark.kryoserializer.buffer=512m \
--conf spark.dynamicAllocation.enabled=true \
--conf spark.shuffle.service.enabled=true \
--conf spark.sql.shuffle.partitions=3200 \
--conf spark.default.parallelism=3200 \
--conf spark.storage.memoryfraction=0.3 \
--conf spark.shuffle.memoryFraction=0.3 \
--conf spark.sql.hive.mergeFiles=true \
--conf spark.blacklist.enabled=true \
--conf spark.speculation=true \
--conf spark.sql.sources.readWithSubdirectories.enabled=false \
--conf spark.sql.autoBroadcastJoinThreshold=102400 \
--py-files utils.py \
--name analysis \
analysis.py ${calc_date}
#scala 版本提交 spark任務(wù)
spark-submit --class com.ad.data.algorithms.model.runModel \
--master yarn \
--deploy-mode cluster \
--driver-memory 16G \
--conf spark.driver.maxResultSize=16G \
--driver-cores 8 \
--num-executors 100 \
--executor-cores 8 \
--executor-memory 16G \
--conf spark.dynamicAllocation.enabled=true \
--conf spark.shuffle.service.enabled=true \
--conf spark.sql.shuffle.partitions=3200 \
--conf spark.default.parallelism=3200 \
--conf spark.storage.memoryfraction=0.4 \
--conf spark.shuffle.memoryFraction=0.4 \
--conf spark.sql.hive.mergeFiles=true \
--conf spark.blacklist.enabled=true \
--conf spark.speculation=true \
--conf spark.hadoop.hive.exec.orc.split.strategy=ETL \
--name segment-model \
${basePath}/../algorithms-model.jar ${calculateDate} ${cateCodes}
三、sparkSession中配置參數(shù)
from pyspark.sql import SparkSession
from pyspark.sql.functions import lit, col, expr
if __name__ == '__main__':
script, calc_date = argv
spark = SparkSession.builder.appName("analysis")\
.config("spark.sql.autoBroadcastJoinThreshold", 102400)\
.config("spark.driver.maxResultSize", "24G")\
.enableHiveSupport().getOrCreate()
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-545978.html
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-545978.html
到了這里,關(guān)于Spark參數(shù)配置和調(diào)優(yōu),Spark-SQL、Config的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!