{"id":356028,"date":"2024-05-20T23:21:06","date_gmt":"2024-05-20T23:21:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=356028"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-20T23:21:06","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=356028","title":{"rendered":"<span>Hadoop \u0432 \u043b\u044e\u0431\u043e\u0439 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438. \u041a\u0430\u043a \u0432\u044b\u0436\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443 \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 ML \u043a\u043e\u043c\u0430\u043d\u0434\u0435<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>\u041f\u0440\u0438\u0432\u0435\u0442, Habr!<\/strong><\/p>\n<p>\u042f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u043c \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0432 \u041c\u0435\u0433\u0430\u0424\u043e\u043d\u0435. \u0417\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0447\u0430\u0441\u0442\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 MLOps \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b. \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u044d\u0442\u0430\u043f\u043e\u0432 (\u0441\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, MQ\/DQ, \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u0438\u0437\u0430\u0446\u0438\u044f).<\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c Hadoop \u0438 \u043a\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f (\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433, \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u043f\u0430\u043c\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430)<\/p>\n<p>\u0412\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e \u043c\u043e\u0442\u0438\u0432\u0430\u043c \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/www.youtube.com\/watch?v=gLbN9IuhGSw\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 <a href=\"#6\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041a\u043e\u0434 <a href=\"https:\/\/github.com\/MaryIzo\/spark_apps\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u0438 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 BigData \u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 Hadoop. <\/p>\n<p><strong>\u0417\u0430\u0442\u0440\u043e\u043d\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0435\u043c\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"#1\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u043f\u0430\u0440\u043a\u0430.<\/a> <\/p>\n<\/li>\n<li>\n<p><a href=\"#2\">\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 spark application \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 python.<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#3\">\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 Hadoop.<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#4\">\u0421\u043a\u043b\u0435\u0438\u0432\u0430\u0442\u0435\u043b\u044c (Spark gluer) \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 hdfs.<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#5\">\u041f\u0430\u043c\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 (alter table, hdfs cleaner).<\/a><\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e Apache Hadoop (\u00ab\u0425\u0430\u0434\u0443\u043f\u00bb) \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041e\u043d \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430, \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u043e\u0442\u0435\u043d \u0442\u0435\u0440\u0430\u0431\u0430\u0439\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<\/blockquote>\n<p><strong>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Hadoop<\/strong><\/p>\n<ol>\n<li>\n<p><em>Hadoop Common.<\/em> <br \/>\u041d\u0430\u0431\u043e\u0440 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0443\u0442\u0438\u043b\u0438\u0442. <\/p>\n<\/li>\n<li>\n<p><em>HDFS (Hadoop Distributed File System).<\/em> <br \/>\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0430\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0443\u0437\u043b\u0430\u0445 (\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445).<\/p>\n<\/li>\n<li>\n<p><em>YARN (Yet Another Resource Negotiator).<\/em> <br \/>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p><em>Hadoop MapReduce.<\/em> <br \/>\u041f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 MapReduce-\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c nodes \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 Hadoop \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Hive &#8212; \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0438\u0437 HDFS \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f MapReduce. <\/p>\n<p><a class=\"anchor\" name=\"1\" id=\"1\"><\/a><\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u043f\u0430\u0440\u043a\u0430<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b: \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u0448\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445, \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u0442\u044c \u043a \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044e \u043b\u0438\u043c\u0438\u0442\u043e\u0432, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 pyspark (\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0435). \u0415\u0441\u043b\u0438 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439, \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f (\u0438\u043b\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f) \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. <\/p>\n<pre><code class=\"python\">conf = SparkConf() conf.set('spark.dynamicAllocation.maxExecutors', '20') conf.set('spark.executor.cores', '5') conf.set('spark.executor.memory', '15g') conf.set('spark.executor.memoryOverhead', '2g') conf.set('spark.driver.memoryOverhead', '1g') conf.set('spark.scheduler.mode', 'FAIR') conf.set('spark.yarn.queue', f'root.users.{short_user_name}')<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<p><u>dynamicAllocation.maxExecutors<\/u>  &#8212; \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e executor\u2019\u043e\u0432 \u043f\u0440\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432,<br \/><u>executor.cores<\/u> \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044f\u0434\u0435\u0440 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e executor\u2019\u0430,<br \/><u>executor.memory<\/u> \u2013 \u043e\u0431\u044a\u0451\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e executor\u2019\u0430,<br \/><u>spark.executor.memoryOverhead<\/u> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u043d\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u0434\u043b\u044f execitor\u2019a (\u0435\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u0430\u0448\u0438\u043d\u0443 \u0432 \u0441\u0432\u043e\u043f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u0430 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u042f\u0440\u043d\u043e\u043c. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435: 1-2 Gb),<br \/><u>spark.driver.memoryOverhead<\/u> \u2013 \u043e\u0431\u044a\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043a\u0430\u0436\u0434\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 Spark \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435,<br \/><u>spark.scheduler.mode<\/u> \u2013 \u043c\u0435\u0442\u043e\u0434 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u0439,<br \/><u>spark.yarn.queue<\/u> \u2013 \u0438\u043c\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0438 spark.<\/p>\n<\/div>\n<\/details>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0435\u0435 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432: <\/p>\n<ul>\n<li>\n<p> spark.dynamicAllocation.enabled=true (\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432),<\/p>\n<\/li>\n<li>\n<p> spark.shuffle.service.enabled=true (\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0442\u0430\u0434\u0438\u0438 shuffle),<\/p>\n<\/li>\n<li>\n<p> spark.dynamicAllocation.executorIdleTimeout=120s (\u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f executor \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b),<\/p>\n<\/li>\n<li>\n<p> spark.dynamicAllocation.cachedExecutorIdleTimeout=600s (\u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f executor \u0441 \u0437\u0430\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438),<\/p>\n<\/li>\n<li>\n<p>spark.port.maxRetries=50 (\u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0440\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c Spark \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0430\u0440\u0442\u043e\u043c).<\/p>\n<\/li>\n<\/ul>\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/58e\/09e\/e5d\/58e09ee5da4bd1ff7a5200c7aa88ab58.png\" alt=\"\" title=\"\" width=\"674\" height=\"379\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/58e\/09e\/e5d\/58e09ee5da4bd1ff7a5200c7aa88ab58.png\"\/><\/figure>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0432 Running Applications \u0437\u0430 \u0442\u0435\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432\u0430\u0448\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043e \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0431\u0438\u0440\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0443 \u043a\u043e\u043b\u043b\u0435\u0433, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b. <\/p>\n<p>\u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c\u00a0<br \/><u>spark.dynamicAllocation.maxExecutors\u00a0X\u00a0spark.executor.cores<\/u>\u00a0\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 <br \/>\u0438 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c\u00a0<u>spark.dynamicAllocation.maxExecutors\u00a0X\u00a0spark.executor.memory<\/u> \u043f\u0430\u043c\u044f\u0442\u0438\u00a0\u0432 \u0441\u0430\u043c\u043e\u043c \u043f\u043b\u043e\u0445\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.    <\/p>\n<p><a class=\"anchor\" name=\"2\" id=\"2\"><\/a><\/p>\n<h3>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/h3>\n<p>\u0418\u043c\u0435\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 Running applications, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0447\u0435\u0442 \u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 spark application.<\/p>\n<p>\u042d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c YARN \u0438 python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. <a href=\"https:\/\/newtechaudit.ru\/monitoring-resursov-spark-prilozhenij-s-pomoshhyu-python\/\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0437\u0434\u0435\u0441\u044c.<\/a><\/p>\n<pre><code class=\"python\">import subprocess import requests import re import pandas as pd from bs4 import BeautifulSoup<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b  \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439,<\/p>\n<pre><code class=\"python\">cmd = yarn application \u2013list applications = subprocess.check_output(cmd, shell = True).splitlines()<\/code><\/pre>\n<p> \u0434\u0430\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"python\">cmd = yarn application \u2013status &lt;app_id> status  = subprocess.check_output(cmd, shell = True).splitlines()<\/code><\/pre>\n<p>\u041f\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0443 \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0434\u0430\u0442\u0443 \u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>\u0414\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0442\u0438\u043f\u0430 SPARK \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c request \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a YARN Resource manager UI \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u0434\u0430\u0447\u0430\u0445.<\/p>\n<pre><code class=\"python\">site_res = requests.get(\"http:\/\/msk-hdp----------- \/proxy\/\"+app_id+\"\/environment\/\", auth=(user_name, password)).text site_jobs = requests.get(\"http:\/\/msk-hdp-----------\/proxy\/\"+app_id+\"\/\", auth=(user_name, password)).text<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1b6\/69e\/225\/1b669e2259a7d8f856d05e3f51e221a0.png\" alt=\"pandas dataframe \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430\" title=\"pandas dataframe \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 (\u0441\u043a\u0440\u044b\u0442\u044b id)\" width=\"1011\" height=\"318\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1b6\/69e\/225\/1b669e2259a7d8f856d05e3f51e221a0.png\"\/><\/p>\n<div><figcaption>pandas dataframe \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 (\u0441\u043a\u0440\u044b\u0442\u044b id)<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447. \u041f\u043e \u0434\u0430\u0442\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0434\u043d\u044f. <\/p>\n<pre><code class=\"python\">jobs_info = BeautifulSoup(site_jobs, 'lxml').find_all('table', attrs={'id': 'completedJob-table'}) <\/code><\/pre>\n<figure class=\"float\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a06\/206\/b6e\/a06206b6ef30e4ddd014f5e78dd4f48f.png\" alt=\"\" title=\"\" width=\"428\" height=\"305\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a06\/206\/b6e\/a06206b6ef30e4ddd014f5e78dd4f48f.png\"\/><\/figure>\n<p>\u041c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434, \u043d\u043e \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u0418\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043d\u0430 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043f\u0440\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 7 \u0434\u043d\u0435\u0439 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <u>yarn application \u2013kill &lt;app_id><\/u>.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a UI \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 email \u043d\u043e\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430\u043c. <\/p>\n<p>\u042d\u0442\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432 docker \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432 airflow. <\/p>\n<p><a class=\"anchor\" name=\"3\" id=\"3\"><\/a><\/p>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 Hadoop<\/h3>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0442\u0435\u043c, \u043a\u0430\u043a \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b \u043d\u0430 \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 HDFS \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0431\u043b\u043e\u043a\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 64 \u0438\u043b\u0438 128 \u041c\u0431, \u0430 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0430 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0443\u0437\u043b\u0430 \u0438\u043c\u0451\u043d \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. <\/p>\n<p>\u0424\u0430\u0439\u043b\u044b \u0438 \u0431\u043b\u043e\u043a\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0438\u043c\u0435\u043d \u0432 HDFS \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043c\u0435\u0441\u0442\u043e \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/949\/3c8\/9da\/9493c89daf02a1556f4088c8b213e6e6.png\" alt=\"hdfs\" title=\"hdfs\" width=\"1134\" height=\"546\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/949\/3c8\/9da\/9493c89daf02a1556f4088c8b213e6e6.png\"\/><\/p>\n<div><figcaption>hdfs<\/figcaption><\/div>\n<\/figure>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0435\u043c\u043a\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u043d \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0443\u0437\u043b\u0430 \u0438\u043c\u0435\u043d. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 HDFS \u043f\u043b\u043e\u0445\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0440\u0430\u0432\u0435\u043d 150 \u0431\u0430\u0439\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 HDFS \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e: \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430 NameNode, \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e. <\/p>\n<p>\u0427\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0430\u0439\u043b \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 1 \u041c\u0431 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0431\u043b\u043e\u043a\u0430 128 \u041c\u0431, \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043f\u043e 1 \u041c\u0431 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0443\u0436\u0435 \u0432 \u0434\u0432\u0443\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c 300 \u0431\u0430\u0439\u0442 \u043d\u0430 NameNode, \u0445\u043e\u0442\u044f \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u0432 150. <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u0439,<\/p>\n<\/li>\n<li>\n<p>\u0440\u043e\u0441\u0442 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, <\/p>\n<\/li>\n<li>\n<p>\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0444\u0430\u0439\u043b\u043e\u0432? \u041f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 Hive \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u044e\u0447 \u0440\u0430\u0437\u0434\u0435\u043b\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 spark.sql.shuffle.partitions \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 200, \u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 Partition By \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0432 50 \u0446\u0435\u043b\u0435\u0432\u044b\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432, \u0431\u0443\u0434\u0435\u0442 200 \u0437\u0430\u0434\u0430\u0447 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432 50 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432. <br \/>\u041a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043e\u043a\u043e\u043b\u043e 200*50=10000 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<details class=\"spoiler\">\n<summary>spark.sql.shuffle.partitions<\/summary>\n<div class=\"spoiler__content\">\n<p><u>spark.sql.shuffle.partitions<\/u> \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f (\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439) join \u0438\u043b\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0439.<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0443 \u0432\u0430\u0441, \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u043b\u043e\u043a \u0438 \u043c\u0435\u0441\u0442\u043e \u043d\u0430 NameNode: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/24c\/1bf\/1f8\/24c1bf1f86cb6d46f2860cd323cd15a4.png\" alt=\"\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432\" title=\"\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432\" width=\"688\" height=\"419\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/24c\/1bf\/1f8\/24c1bf1f86cb6d46f2860cd323cd15a4.png\"\/><\/p>\n<div><figcaption>\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0444\u0430\u0439\u043b\u043e\u0432 <u>\u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438<\/u> \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/ca1\/239\/c1d\/ca1239c1d0d5c52c9ce670663dc2665c.jpg\" alt=\"\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\" title=\"\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\" width=\"604\" height=\"256\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ca1\/239\/c1d\/ca1239c1d0d5c52c9ce670663dc2665c.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/figcaption><\/div>\n<\/figure>\n<blockquote>\n<p>\u041f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (partitioning) \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0447\u0430\u0441\u0442\u0438, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u041a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0444\u0440\u0435\u0439\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0447\u0442\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0438\u043b\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0430, Spark \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<\/blockquote>\n<p>\u042d\u0442\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 Spark \u043d\u0430\u0434 Pandas. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044f\u0445 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. <\/p>\n<p>Apache spark \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 (\u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435):<\/p>\n<ol>\n<li>\n<p>\u041f\u0430\u0440\u0442\u0438\u0446\u0438\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 repartition \u0438\u043b\u0438 coalesce.<br \/>repartition \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 coalesce \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0430\u0440\u0442\u0438\u0446\u0438\u044f \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430 partitionBy (\u044d\u0442\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044f\u043c \u0432 Hive).\u00a0\u00a0\u00a0 <\/p>\n<\/li>\n<\/ol>\n<p><u>DataFrame.repartition(numPartitions, cols)<\/u><em> \u2013 <\/em>\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 DataFrame, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u043e \u0445\u0435\u0448\u0443. \u0426\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 numPartitions \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0446\u0435\u043b\u0435\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432. \u0421\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 cols \u0437\u0430\u0434\u0430\u0435\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p><em>\u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434. \u0417\u0434\u0435\u0441\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0435\u0442 repartition \u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043f\u043e\u0442\u043e\u043c \u0443\u0436\u0435 partition by \u0434\u043b\u044f \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u0434\u0438\u0441\u043a\u0435. <\/em><\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<pre><code class=\"python\">sdf.repartition(num_files_partitions, partition_columns)      .write      .partitionBy(partition_columns)      .mode(mode)      .format(wr_format)      .saveAsTable(table_name)<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430<em> <\/em><u>repartition(num_files_partitions)<\/u> \u0438\u043b\u0438 <u>coalesce(num_files_partitions)<\/u>.<\/p>\n<blockquote>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 \u0440\u0435\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0440\u0435\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u043e \u043f\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0441 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u043f\u0430\u0434\u0435\u043d\u0438\u0435 NameNode (\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438 \u043f\u043e\u0442\u0435\u0440\u044f \u0434\u0430\u043d\u043d\u044b\u0445).<\/p>\n<\/blockquote>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u043a\u043e\u043b\u043e\u043d\u043a\u0435 \u2013 <u>\u044d\u0442\u043e distinct().count()<\/u>.<\/p>\n<p>\u00a0<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c0d\/2be\/d93\/c0d2bed93db215011e7c67a0b3a3bf9a.png\" alt=\"\u0440\u0435\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443\" title=\"\u0440\u0435\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443\" width=\"349\" height=\"472\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c0d\/2be\/d93\/c0d2bed93db215011e7c67a0b3a3bf9a.png\"\/><\/p>\n<div><figcaption>\u0440\u0435\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 hdfs \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u043e\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043f\u0430\u043f\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 bash \u043a\u043e\u043c\u0430\u043d\u0434. <br \/>\u0422\u0430\u043a\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <u>\/user\/<\/u> \u0441 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0438 \u0447\u0438\u0441\u043b\u043e\u043c \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u0430 \u0444\u0430\u0439\u043b\u043e\u0432, \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043f\u043e \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0443:<\/p>\n<pre><code class=\"python\">import sys import subprocess  cmd = \"\"\" hdfs dfs -count \/user\/ | egrep -w -v \"yarn|hive|spark\" | sort -k2 -nr | awk '{ if (2) \"\\t\\t\" int(3\/(10241024$2)) \" Mb \\t \\t\" $4}' \"\"\" shell_cmd = True if isinstance(cmd, str) else False s_output, s_err = subprocess.Popen(   cmd,    stdout=subprocess.PIPE,    stderr=subprocess.PIPE,   shell = shell_cmd,   universal_newlines=True ).communicate()  sys.stdout.write(s_output)<\/code><\/pre>\n<p>\u0412\u044b\u0432\u043e\u0434 \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 pandas dataframe \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 html \u043f\u0438\u0441\u044c\u043c\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u0443\u044e \u043d\u043e\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 airflow \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c \u043e \u0447\u0438\u0441\u043b\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/p>\n<p><a class=\"anchor\" name=\"4\" id=\"4\"><\/a><\/p>\n<h3>\u0421\u043a\u043b\u0435\u0438\u0432\u0430\u0442\u0435\u043b\u044c (Spark gluer) \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 hdfs.<\/h3>\n<figure class=\"float\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2d7\/ab6\/56a\/2d7ab656a83154045253a435bccb50bd.png\" alt=\"spark gluer\" title=\"spark gluer\" width=\"333\" height=\"547\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2d7\/ab6\/56a\/2d7ab656a83154045253a435bccb50bd.png\"\/><\/p>\n<div><figcaption>spark gluer<\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b spark \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <u>\u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0442\u0435\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432<\/u> \u043d\u0430 hdfs (spark gluer). <\/p>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 spark \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u043d\u0451\u043d\u043d\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439.<br \/>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b.<\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/MaryIzo\/spark_apps\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a hdfs \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">FileSystem = spark._jvm.org.apache.hadoop.fs.FileSystem Path = spark._jvm.org.apache.hadoop.fs.Path FileUtil = spark._jvm.org.apache.hadoop.fs.FileUtil hadoop_conf = spark.sparkContext._jsc.hadoopConfiguration() fs = FileSystem.get(hadoop_conf) string_path = \"hdfs:\/\/service\u2026\/user\/\u2026\/hive\/megapowers_apply_click_monthly\/month=2022-12\" first_path = Path(string_path)  # \u0421\u0443\u043c\u043c\u0430\u0440\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445. fs.getContentSummary(first_path).getLength()  # \u0421\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. fs.getContentSummary(first_path).getFileCount()<\/code><\/pre>\n<p>\u0414\u043b\u044f \u00ab\u0441\u043a\u043b\u0435\u0438\u0432\u0430\u043d\u0438\u044f\u00bb \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432 tmp \u043f\u0430\u043f\u043a\u0443 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e. <\/p>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 copy.<\/p>\n<pre><code class=\"python\">it = fs.listFiles(first_path, False)      while it.hasNext():         part = it.next()         to_delete = Path(part.getPath().toString())         fs.delete(to_delete)              it = fs.listFiles(tmp_path, False)      while it.hasNext():         part = it.next()         to_move = Path(part.getPath().toString())         FileUtil.copy(fs, to_move, fs, first_path, True, hadoop_conf)<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/efe\/23e\/e65\/efe23ee65b3275ba945dc11badf8ced2.png\" alt=\"spark gluer\" title=\"spark gluer\" width=\"324\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/efe\/23e\/e65\/efe23ee65b3275ba945dc11badf8ced2.png\"\/><\/p>\n<div><figcaption>spark gluer<\/figcaption><\/div>\n<\/figure>\n<p><a class=\"anchor\" name=\"5\" id=\"5\"><\/a><\/p>\n<h2>\u041f\u0430\u043c\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 (alter table, hdfs cleaner)<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0435\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u0412\u0430\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446 \u0434\u043b\u044f \u0441\u043a\u043e\u0440\u0438\u043d\u0433\u043e\u0432.\u00a0 <\/p>\n<p>\u041f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e \u043d\u0430 \u0434\u0430\u0442\u0443, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0435\u0435 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0438 \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <u>spark.sql \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/u>:<\/p>\n<pre><code class=\"python\">drop_retro_script = f\"\"\" ALTER TABLE {table_name}           DROP IF EXISTS PARTITION({date_partition_name}='{partition}')                                     \"\"\"              spark.sql(drop_retro_script)<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0443\u0436\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 airflow \u0438 bash \u0441\u043a\u0440\u0438\u043f\u0442\u0430.<\/p>\n<pre><code class=\"bash\">now=$(date +%s); days_to_keep=365; hdfs dfs -ls \/\u2026\/\u2026\/\u2026\/\u2026\/ | while read f; do file_date_l1=echo $f | awk '{print $6}'; file_name_l1=echo $f | awk '{print $8}'; difference=$(( ($now - $(date -d \"$file_date_l1\" +%s)) \/ (24 * 60 * 60) ));     if [ $difference -gt $days_to_keep ]; then       echo \"Found $file_name_l1 it is older than $days_to_keep and is dated $file_date_l1.\";       hdfs dfs -rm -r $file_name_l1;<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043f\u0430\u043f\u043a\u0435, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u043f\u0440\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0438 \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. <\/p>\n<p><strong>\u041f\u043e\u0434\u0432\u0435\u0434\u0451\u043c \u0438\u0442\u043e\u0433\u0438:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0414\u043b\u044f \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0441\u043f\u0430\u0440\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u0432 \u043d\u0430 spark application \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 python.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 hadoop \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 repartition, coalesce, partition by.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0441\u043a\u0440\u044b\u0442\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c spark \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430 hdfs. <\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 hdfs dfs \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435.<\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. <br \/>\u041d\u0438\u0436\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p><a class=\"anchor\" name=\"6\" id=\"6\"><\/a><\/p>\n<p><strong>\u0421\u043f\u0438\u0441\u043e\u043a \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a:<\/strong><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/companies\/newprolab\/articles\/327556\/\">\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 YARN \u043d\u0430 Spark<\/a>\u00a0 <br \/><a href=\"https:\/\/github.com\/MaryIzo\/spark_apps\">\u0433\u0438\u0442\u0445\u0430\u0431 \u0441 \u043a\u043e\u0434\u043e\u043c (spark gluer)<\/a><br \/><a href=\"https:\/\/bigdataschool.ru\/wiki\/hadoop\">\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Hadoop<\/a> <br \/><a href=\"https:\/\/www.waitingforcode.com\/apache-spark\/fair-jobs-scheduling-apache-spark\/read\">fair-jobs-scheduling-apache-spark<\/a> <br \/><a href=\"https:\/\/newtechaudit.ru\/monitoring-resursov-spark-prilozhenij-s-pomoshhyu-python\/\">\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 spark apllication<\/a> <br \/><a href=\"https:\/\/bigdataschool.ru\/blog\/too-many-small-files-in-hdfs.html#:~:text=%D0%9E%D0%B4%D0%BD%D0%B8%D0%BC%20%D0%B8%D0%B7%20%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D0%BE%D0%B2%20%D0%B8%D0%B7%D0%B1%D0%B5%D0%B6%D0%B0%D1%82%D1%8C%20%D0%BF%D1%80%D0%BE%D0%B1%D0%BB%D0%B5%D0%BC%D1%8B,%D0%BD%D0%B5%D0%B1%D0%BE%D0%BB%D1%8C%D1%88%D0%B8\">\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 Hadoop.<\/a> <br \/><a href=\"https:\/\/spark-school.ru\/blogs\/partitionby\/\">PartitionBy<\/a> <br \/><a href=\"https:\/\/bigdataschool.ru\/blog\/coalesce-vs-repartition-in-spark.html\">coalesce-vs-repartition-in-spark<\/a> <br \/><a href=\"https:\/\/spark-school.ru\/blogs\/repartition-vs-coalesce\/\">repartition-vs-coalesce2<\/a> <br \/><a href=\"https:\/\/hadoop.apache.org\/docs\/stable\/api\/org\/apache\/hadoop\/fs\/FileSystem.html\">SparkMethodsFileSystem<\/a> \u00a0\u00a0\u00a0\u00a0\u00a0<br \/><a href=\"https:\/\/hadoop.apache.org\/docs\/r2.6.0\/api\/org\/apache\/hadoop\/fs\/FileUtil.html\">SparkMethodsFileUtil<\/a> <br \/><a href=\"https:\/\/umbertogriffo.gitbook.io\/apache-spark-best-practices-and-tuning\/\">apache-spark-best-practices-and-tuning<\/a> <\/p>\n<p><strong>\u041f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438 \u0432\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u0442\u0435\u0441\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c \u0438 \u043a\u0430\u043a \u0438\u0445 \u0440\u0435\u0448\u0430\u0435\u0442\u0435.<\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/763864\/\"> https:\/\/habr.com\/ru\/articles\/763864\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>\u041f\u0440\u0438\u0432\u0435\u0442, Habr!<\/strong><\/p>\n<p>\u042f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u043c \u043f\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u0432 \u041c\u0435\u0433\u0430\u0424\u043e\u043d\u0435. \u0417\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0447\u0430\u0441\u0442\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 MLOps \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b. \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u044d\u0442\u0430\u043f\u043e\u0432 (\u0441\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, MQ\/DQ, \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u0438\u0437\u0430\u0446\u0438\u044f).<\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c Hadoop \u0438 \u043a\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f (\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433, \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u043f\u0430\u043c\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430)<\/p>\n<p>\u0412\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e \u043c\u043e\u0442\u0438\u0432\u0430\u043c \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/www.youtube.com\/watch?v=gLbN9IuhGSw\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 <a href=\"#6\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041a\u043e\u0434 <a href=\"https:\/\/github.com\/MaryIzo\/spark_apps\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u0438 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 BigData \u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 Hadoop. <\/p>\n<p><strong>\u0417\u0430\u0442\u0440\u043e\u043d\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0435\u043c\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"#1\">\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u043f\u0430\u0440\u043a\u0430.<\/a> <\/p>\n<\/li>\n<li>\n<p><a href=\"#2\">\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 spark application \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 python.<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#3\">\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 Hadoop.<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#4\">\u0421\u043a\u043b\u0435\u0438\u0432\u0430\u0442\u0435\u043b\u044c (Spark gluer) \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 hdfs.<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"#5\">\u041f\u0430\u043c\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 (alter table, hdfs cleaner).<\/a><\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e Apache Hadoop (\u00ab\u0425\u0430\u0434\u0443\u043f\u00bb) \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041e\u043d \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430, \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u043e\u0442\u0435\u043d \u0442\u0435\u0440\u0430\u0431\u0430\u0439\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<\/blockquote>\n<p><strong>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Hadoop<\/strong><\/p>\n<ol>\n<li>\n<p><em>Hadoop Common.<\/em> <br \/>\u041d\u0430\u0431\u043e\u0440 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u0443\u0442\u0438\u043b\u0438\u0442. <\/p>\n<\/li>\n<li>\n<p><em>HDFS (Hadoop Distributed File System).<\/em> <br \/>\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0430\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0443\u0437\u043b\u0430\u0445 (\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445).<\/p>\n<\/li>\n<li>\n<p><em>YARN (Yet Another Resource Negotiator).<\/em> <br \/>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p><em>Hadoop MapReduce.<\/em> <br \/>\u041f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 MapReduce-\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c nodes \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 Hadoop \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Hive &#8212; \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0438\u0437 HDFS \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f MapReduce. <\/p>\n<p><a class=\"anchor\" name=\"1\" id=\"1\"><\/a><\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u043f\u0430\u0440\u043a\u0430<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b: \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u0448\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445, \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u0442\u044c \u043a \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044e \u043b\u0438\u043c\u0438\u0442\u043e\u0432, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 pyspark (\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0435). \u0415\u0441\u043b\u0438 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439, \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f (\u0438\u043b\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f) \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. <\/p>\n<pre><code class=\"python\">conf = SparkConf() conf.set('spark.dynamicAllocation.maxExecutors', '20') conf.set('spark.executor.cores', '5') conf.set('spark.executor.memory', '15g') conf.set('spark.executor.memoryOverhead', '2g') conf.set('spark.driver.memoryOverhead', '1g') conf.set('spark.scheduler.mode', 'FAIR') conf.set('spark.yarn.queue', f'root.users.{short_user_name}')<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<p><u>dynamicAllocation.maxExecutors<\/u>  &#8212; \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e executor\u2019\u043e\u0432 \u043f\u0440\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432,<br \/><u>executor.cores<\/u> \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044f\u0434\u0435\u0440 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e executor\u2019\u0430,<br \/><u>executor.memory<\/u> \u2013 \u043e\u0431\u044a\u0451\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e executor\u2019\u0430,<br \/><u>spark.executor.memoryOverhead<\/u> &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u043d\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u0434\u043b\u044f execitor\u2019a (\u0435\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u0430\u0448\u0438\u043d\u0443 \u0432 \u0441\u0432\u043e\u043f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u0430 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u042f\u0440\u043d\u043e\u043c. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435: 1-2 Gb),<br \/><u>spark.driver.memoryOverhead<\/u> \u2013 \u043e\u0431\u044a\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043a\u0430\u0436\u0434\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 Spark \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435,<br \/><u>spark.scheduler.mode<\/u> \u2013 \u043c\u0435\u0442\u043e\u0434 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u0439,<br \/><u>spark.yarn.queue<\/u> \u2013 \u0438\u043c\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u0438 spark.<\/p>\n<\/div>\n<\/details>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0435\u0435 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432: <\/p>\n<ul>\n<li>\n<p> spark.dynamicAllocation.enabled=true (\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432),<\/p>\n<\/li>\n<li>\n<p> spark.shuffle.service.enabled=true (\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0442\u0430\u0434\u0438\u0438 shuffle),<\/p>\n<\/li>\n<li>\n<p> spark.dynamicAllocation.executorIdleTimeout=120s (\u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f executor \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b),<\/p>\n<\/li>\n<li>\n<p> spark.dynamicAllocation.cachedExecutorIdleTimeout=600s (\u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f executor \u0441 \u0437\u0430\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438),<\/p>\n<\/li>\n<li>\n<p>spark.port.maxRetries=50 (\u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0440\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c Spark \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0430\u0440\u0442\u043e\u043c).<\/p>\n<\/li>\n<\/ul>\n<figure class=\"float full-width\"><\/figure>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0432 Running Applications \u0437\u0430 \u0442\u0435\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432\u0430\u0448\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043e \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0431\u0438\u0440\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0443 \u043a\u043e\u043b\u043b\u0435\u0433, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b. <\/p>\n<p>\u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c\u00a0<br \/><u>spark.dynamicAllocation.maxExecutors\u00a0X\u00a0spark.executor.cores<\/u>\u00a0\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 <br \/>\u0438 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c\u00a0<u>spark.dynamicAllocation.maxExecutors\u00a0X\u00a0spark.executor.memory<\/u> \u043f\u0430\u043c\u044f\u0442\u0438\u00a0\u0432 \u0441\u0430\u043c\u043e\u043c \u043f\u043b\u043e\u0445\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.    <\/p>\n<p><a class=\"anchor\" name=\"2\" id=\"2\"><\/a><\/p>\n<h3>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/h3>\n<p>\u0418\u043c\u0435\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 Running applications, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0447\u0435\u0442 \u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 spark application.<\/p>\n<p>\u042d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c YARN \u0438 python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. <a href=\"https:\/\/newtechaudit.ru\/monitoring-resursov-spark-prilozhenij-s-pomoshhyu-python\/\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0437\u0434\u0435\u0441\u044c.<\/a><\/p>\n<pre><code class=\"python\">import subprocess import requests import re import pandas as pd from bs4 import BeautifulSoup<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b  \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439,<\/p>\n<pre><code class=\"python\">cmd = yarn application \u2013list applications = subprocess.check_output(cmd, shell = True).splitlines()<\/code><\/pre>\n<p> \u0434\u0430\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/p>\n<pre><code class=\"python\">cmd = yarn application \u2013status &lt;app_id> status  = subprocess.check_output(cmd, shell = True).splitlines()<\/code><\/pre>\n<p>\u041f\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0443 \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0434\u0430\u0442\u0443 \u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>\u0414\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0442\u0438\u043f\u0430 SPARK \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c request \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a YARN Resource manager UI \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u0434\u0430\u0447\u0430\u0445.<\/p>\n<pre><code class=\"python\">site_res = requests.get(\"http:\/\/msk-hdp----------- \/proxy\/\"+app_id+\"\/environment\/\", auth=(user_name, password)).text site_jobs = requests.get(\"http:\/\/msk-hdp-----------\/proxy\/\"+app_id+\"\/\", auth=(user_name, password)).text<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>pandas dataframe \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 (\u0441\u043a\u0440\u044b\u0442\u044b id)<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447. \u041f\u043e \u0434\u0430\u0442\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0434\u043d\u044f. <\/p>\n<pre><code class=\"python\">jobs_info = BeautifulSoup(site_jobs, 'lxml').find_all('table', attrs={'id': 'completedJob-table'}) <\/code><\/pre>\n<figure class=\"float\"><\/figure>\n<p>\u041c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434, \u043d\u043e \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u0418\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043d\u0430 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043f\u0440\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 7 \u0434\u043d\u0435\u0439 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <u>yarn application \u2013kill &lt;app_id><\/u>.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a UI \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 email \u043d\u043e\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430\u043c. <\/p>\n<p>\u042d\u0442\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432 docker \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432 airflow. <\/p>\n<p><a class=\"anchor\" name=\"3\" id=\"3\"><\/a><\/p>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 Hadoop<\/h3>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0442\u0435\u043c, \u043a\u0430\u043a \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u044b \u043d\u0430 \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 HDFS \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0431\u043b\u043e\u043a\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 64 \u0438\u043b\u0438 128 \u041c\u0431, \u0430 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0430 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0443\u0437\u043b\u0430 \u0438\u043c\u0451\u043d \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. <\/p>\n<p>\u0424\u0430\u0439\u043b\u044b \u0438 \u0431\u043b\u043e\u043a\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0438\u043c\u0435\u043d \u0432 HDFS \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043c\u0435\u0441\u0442\u043e \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d. <\/p>\n<figure class=\"full-width\">\n<div><figcaption>hdfs<\/figcaption><\/div>\n<\/figure>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0435\u043c\u043a\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u043d \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0430 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0443\u0437\u043b\u0430 \u0438\u043c\u0435\u043d. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 HDFS \u043f\u043b\u043e\u0445\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0440\u0430\u0432\u0435\u043d 150 \u0431\u0430\u0439\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 HDFS \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e: \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430 NameNode, \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e. <\/p>\n<p>\u0427\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0430\u0439\u043b \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 1 \u041c\u0431 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0431\u043b\u043e\u043a\u0430 128 \u041c\u0431, \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043f\u043e 1 \u041c\u0431 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0443\u0436\u0435 \u0432 \u0434\u0432\u0443\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c 300 \u0431\u0430\u0439\u0442 \u043d\u0430 NameNode, \u0445\u043e\u0442\u044f \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u0432 150. <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u0439,<\/p>\n<\/li>\n<li>\n<p>\u0440\u043e\u0441\u0442 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, <\/p>\n<\/li>\n<li>\n<p>\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0444\u0430\u0439\u043b\u043e\u0432? \u041f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 Hive \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u044e\u0447 \u0440\u0430\u0437\u0434\u0435\u043b\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 spark.sql.shuffle.partitions \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 200, \u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 Partition By \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0432 50 \u0446\u0435\u043b\u0435\u0432\u044b\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432, \u0431\u0443\u0434\u0435\u0442 200 \u0437\u0430\u0434\u0430\u0447 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432 50 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432. <br \/>\u041a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043e\u043a\u043e\u043b\u043e 200*50=10000 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<details class=\"spoiler\">\n<summary>spark.sql.shuffle.partitions<\/summary>\n<div class=\"spoiler__content\">\n<p><u>spark.sql.shuffle.partitions<\/u> \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f (\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439) join \u0438\u043b\u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0439.<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0443 \u0432\u0430\u0441, \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u043b\u043e\u043a \u0438 \u043c\u0435\u0441\u0442\u043e \u043d\u0430 NameNode: <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043b\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0447\u0438\u0441\u043b\u043e\u043c \u0444\u0430\u0439\u043b\u043e\u0432 <u>\u043f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438<\/u> \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/figcaption><\/div>\n<\/figure>\n<blockquote>\n<p>\u041f\u0430\u0440\u0442\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (partitioning) \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0447\u0430\u0441\u0442\u0438, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u041a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0444\u0440\u0435\u0439\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0447\u0442\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0438\u043b\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0430, Spark \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<\/blockquote>\n<p>\u042d\u0442\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 Spark \u043d\u0430\u0434 Pandas. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044f\u0445 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. <\/p>\n<p>Apache spark \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 (\u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435):<\/p>\n<ol>\n<li>\n<p>\u041f\u0430\u0440\u0442\u0438\u0446\u0438\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 repartition \u0438\u043b\u0438 coalesce.<br \/>repartition \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 coalesce \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0430\u0440\u0442\u0438\u0446\u0438\u044f \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430 partitionBy (\u044d\u0442\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044f\u043c \u0432 Hive).\u00a0\u00a0\u00a0 <\/p>\n<\/li>\n<\/ol>\n<p><u>DataFrame.repartition(numPartitions, cols)<\/u><em> \u2013 <\/em>\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 DataFrame, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u043e \u0445\u0435\u0448\u0443. \u0426\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 numPartitions \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0446\u0435\u043b\u0435\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432. \u0421\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 cols \u0437\u0430\u0434\u0430\u0435\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p><em>\u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434. \u0417\u0434\u0435\u0441\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0435\u0442 repartition \u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043f\u043e\u0442\u043e\u043c \u0443\u0436\u0435 partition by \u0434\u043b\u044f \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u0434\u0438\u0441\u043a\u0435. <\/em><\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<pre><code class=\"python\">sdf.repartition(num_files_partitions, partition_columns)      .write      .partitionBy(partition_columns)      .mode(mode)      .format(wr_format)      .saveAsTable(table_name)<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430<em> <\/em><u>repartition(num_files_partitions)<\/u> \u0438\u043b\u0438 <u>coalesce(<\/u><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-356028","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/356028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=356028"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/356028\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=356028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=356028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=356028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}