{"id":377709,"date":"2024-06-01T15:00:59","date_gmt":"2024-06-01T15:00:59","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=377709"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=377709","title":{"rendered":"<span>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f PostgreSQL \u0438 Hadoop<\/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>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043d\u0435\u043a\u043e\u0435 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u044c\u0435, \u0433\u0434\u0435 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u2014 \u043c\u043e\u0449\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 <strong>PostgreSQL<\/strong>, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u2014 \u043d\u0435\u043e\u0431\u044a\u044f\u0442\u043d\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u044b <strong>Hadoop<\/strong>. \u0412\u044b\u0431\u043e\u0440 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u043c, \u043d\u043e \u0437\u0430\u0447\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0435 \u0438\u0437 \u043e\u0431\u043e\u0438\u0445?<\/p>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044f \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u043e\u0449\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043c\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c Hadoop \u0438 \u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b HDFS \u0438 Hive<\/h4>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b Hadoop \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Java. \u041d\u0443\u0436\u043d\u043e \u044e\u0437\u0430\u0442\u044c JDK \u0432\u0435\u0440\u0441\u0438\u0438 8 \u0438\u043b\u0438 \u0432\u044b\u0448\u0435, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c 21 \u0432\u0435\u0440\u0441\u0438\u044e:<\/p>\n<pre><code class=\"bash\">sudo apt-get update sudo apt-get install openjdk-21-jdk<\/code><\/pre>\n<p>Hadoop \u0442\u0440\u0435\u0431\u0443\u0435\u0442 SSH \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u043c\u0438 <abbr class=\"habraabbr\" title=\"\u0412 Unix-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, &quot;\u0434\u0435\u043c\u043e\u043d\u044b&quot; (\u0430\u043d\u0433\u043b. daemons) \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0444\u043e\u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. Hadoop \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0435\u043c\u043e\u043d\u044b \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.\" data-title=\"&lt;p>\u0412 Unix-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, &quot;\u0434\u0435\u043c\u043e\u043d\u044b&quot; (\u0430\u043d\u0433\u043b. daemons) \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0444\u043e\u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. Hadoop \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0435\u043c\u043e\u043d\u044b \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.&lt;\/p>&#187; data-abbr=&#187;\u0434\u0435\u043c\u043e\u043d\u0430\u043c\u0438 &#171;>\u0434\u0435\u043c\u043e\u043d\u0430\u043c\u0438 <\/abbr>Hadoop:<\/p>\n<pre><code class=\"bash\">sudo apt-get install ssh<\/code><\/pre>\n<p>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e Hadoop \u0441 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430 Apache \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0435\u0435:<\/p>\n<pre><code class=\"bash\">wget https:\/\/downloads.apache.org\/hadoop\/common\/hadoop-3.4.0.\/hadoop-3.4.0.tar.gz tar -xzf hadoop-3.4.0.tar.gz sudo mv hadoop-3.4.0. \/usr\/local\/hadoop<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b <code>~\/.bashrc<\/code>:<\/p>\n<pre><code class=\"bash\">export HADOOP_HOME=\/usr\/local\/hadoop export PATH=$PATH:$HADOOP_HOME\/bin:$HADOOP_HOME\/sbin export HADOOP_CONF_DIR=$HADOOP_HOME\/etc\/hadoop export YARN_HOME=$HADOOP_HOME<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\">source ~\/.bashrc<\/code><\/pre>\n<p>\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>$HADOOP_HOME\/etc\/hadoop<\/code>:<\/p>\n<ul>\n<li>\n<p><code>core-site.xml<\/code><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">&lt;configuration>     &lt;property>         &lt;name>fs.defaultFS&lt;\/name>         &lt;value>hdfs:\/\/localhost:9000&lt;\/value>     &lt;\/property> &lt;\/configuration><\/code><\/pre>\n<ul>\n<li>\n<p><code>hdfs-site.xml<\/code><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">&lt;configuration>     &lt;property>         &lt;name>dfs.replication&lt;\/name>         &lt;value>1&lt;\/value>     &lt;\/property>     &lt;property>         &lt;name>dfs.namenode.name.dir&lt;\/name>         &lt;value>file:\/\/\/usr\/local\/hadoop\/data\/namenode&lt;\/value>     &lt;\/property>     &lt;property>         &lt;name>dfs.datanode.data.dir&lt;\/name>         &lt;value>file:\/\/\/usr\/local\/hadoop\/data\/datanode&lt;\/value>     &lt;\/property> &lt;\/configuration><\/code><\/pre>\n<ul>\n<li>\n<p><code>mapred-site.xml<\/code><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">&lt;configuration>     &lt;property>         &lt;name>mapreduce.framework.name&lt;\/name>         &lt;value>yarn&lt;\/value>     &lt;\/property> &lt;\/configuration><\/code><\/pre>\n<ul>\n<li>\n<p><code>yarn-site.xml<\/code><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">&lt;configuration>     &lt;property>         &lt;name>yarn.nodemanager.aux-services&lt;\/name>         &lt;value>mapreduce_shuffle&lt;\/value>     &lt;\/property>     &lt;property>         &lt;name>yarn.nodemanager.aux-services.mapreduce.shuffle.class&lt;\/name>         &lt;value>org.apache.hadoop.mapred.ShuffleHandler&lt;\/value>     &lt;\/property> &lt;\/configuration><\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 HDFS \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Hadoop:<\/p>\n<pre><code class=\"bash\">hdfs namenode -format start-dfs.sh start-yarn.sh<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 Hadoop, \u043e\u0442\u043a\u0440\u044b\u0432 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 NameNode \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>http:\/\/localhost:9870<\/code>.<\/p>\n<p><strong>\u0414\u0430\u043b\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c Hive<\/strong><\/p>\n<p>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c Hive:<\/p>\n<pre><code class=\"bash\">wget https:\/\/downloads.apache.org\/hive\/hive-4.0.0\/apache-hive-4.0.0-bin.tar.gz tar -xzf apache-hive-4.0.0-bin.tar.gz sudo mv apache-hive-4.0.0-bin \/usr\/local\/hive<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b <code>~\/.bashrc<\/code>:<\/p>\n<pre><code class=\"bash\">export HIVE_HOME=\/usr\/local\/hive export PATH=$PATH:$HIVE_HOME\/bin export HADOOP_HOME=\/usr\/local\/hadoop export PATH=$PATH:$HADOOP_HOME\/bin<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\">source ~\/.bashrc<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0434\u043b\u044f Hive \u0432 HDFS:<\/p>\n<pre><code class=\"bash\">hdfs dfs -mkdir \/tmp hdfs dfs -mkdir -p \/user\/hive\/warehouse hdfs dfs -chmod g+w \/tmp hdfs dfs -chmod g+w \/user\/hive\/warehouse<\/code><\/pre>\n<p>\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b <code>hive-site.xml<\/code> \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>$HIVE_HOME\/conf<\/code>:<\/p>\n<pre><code class=\"xml\">&lt;configuration>     &lt;property>         &lt;name>javax.jdo.option.ConnectionURL&lt;\/name>         &lt;value>jdbc:derby:;databaseName=metastore_db;create=true&lt;\/value>         &lt;description>JDBC connect string for a JDBC metastore&lt;\/description>     &lt;\/property>     &lt;property>         &lt;name>javax.jdo.option.ConnectionDriverName&lt;\/name>         &lt;value>org.apache.derby.jdbc.EmbeddedDriver&lt;\/value>         &lt;description>Driver class name for a JDBC metastore&lt;\/description>     &lt;\/property>     &lt;property>         &lt;name>hive.metastore.warehouse.dir&lt;\/name>         &lt;value>\/user\/hive\/warehouse&lt;\/value>         &lt;description>location of default database for the warehouse&lt;\/description>     &lt;\/property> &lt;\/configuration><\/code><\/pre>\n<p><strong>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c FDW \u0434\u043b\u044f Hadoop \u0432 PostgreSQL<\/strong><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c PostgreSQL \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:<\/p>\n<pre><code class=\"bash\">sudo apt-get install postgresql postgresql-contrib<\/code><\/pre>\n<p>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u043a\u0435\u043c \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c HDFS FDW:<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/your-github\/hdfs_fdw cd hdfs_fdw make sudo make install<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0432 PostgreSQL:<\/p>\n<pre><code class=\"sql\">CREATE EXTENSION hdfs_fdw;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0433\u043e\u0442\u043e\u0432\u0430 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e Hadoop \u0438 Hive \u0441 PostgreSQL \u0447\u0435\u0440\u0435\u0437 FDW.<\/p>\n<h4>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 PostgreSQL \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a Hadoop \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>CREATE SERVER<\/code>. \u042d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 FDW \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c.<\/p>\n<pre><code class=\"sql\">CREATE SERVER hdfs_server FOREIGN DATA WRAPPER hdfs_fdw OPTIONS (host '127.0.0.1', port '10000');<\/code><\/pre>\n<ul>\n<li>\n<p><code>hdfs_server<\/code> \u2014 \u0438\u043c\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445.<\/p>\n<\/li>\n<li>\n<p><code>FOREIGN DATA WRAPPER hdfs_fdw<\/code> \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 FDW.<\/p>\n<\/li>\n<li>\n<p><code>OPTIONS<\/code> \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>host<\/code> \u0438 <code>port<\/code> Hive \u0438\u043b\u0438 Spark \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0432\u043d\u0435\u0448\u043d\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443:<\/p>\n<pre><code class=\"sql\">CREATE USER MAPPING FOR current_user SERVER hdfs_server OPTIONS (username 'hadoop_user', password 'hadoop_password');<\/code><\/pre>\n<ul>\n<li>\n<p><code>FOR current_user<\/code> \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f PostgreSQL.<\/p>\n<\/li>\n<li>\n<p><code>OPTIONS<\/code> \u2014 \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 Hadoop.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u043d\u0435\u0448\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>CREATE FOREIGN TABLE<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"sql\">CREATE FOREIGN TABLE hdfs_table (     id INT,     name TEXT ) SERVER hdfs_server OPTIONS (dbname 'default', table_name 'hdfs_table');<\/code><\/pre>\n<ul>\n<li>\n<p><code>hdfs_table<\/code> \u2014 \u0438\u043c\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 PostgreSQL.<\/p>\n<\/li>\n<li>\n<p><code>SERVER hdfs_server<\/code> \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a \u043a\u0430\u043a\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p><code>OPTIONS<\/code> \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>dbname<\/code> \u0438 <code>table_name<\/code>, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043d\u0430 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 Hive \u0438\u043b\u0438 Spark.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438:<\/p>\n<pre><code class=\"sql\">SELECT * FROM hdfs_table WHERE id > 10;<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>hdfs_table<\/code>, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0439\u0441\u044f \u0432 Hadoop, \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 PostgreSQL.<\/p>\n<p><strong>Push-down<\/strong> \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0447\u0430\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0412 Hadoop push-down \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 FDW.<\/p>\n<p>\u0414\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f push-down \u0432 PostgreSQL \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 FDW. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f push-down \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432:<\/p>\n<pre><code class=\"sql\">ALTER SERVER hdfs_server OPTIONS (SET enable_aggregate_pushdown 'true');<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e push-down \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<p><strong>MapReduce<\/strong> \u2014 \u044d\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0434\u0430\u0447. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441 Hive, MapReduce \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440. \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 Hive:<\/p>\n<pre><code class=\"pgsql\">CREATE TABLE weblogs (     client_ip STRING,     request_date STRING,     request STRING,     response_code STRING,     bytes INT ) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ';<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<pre><code>LOAD DATA LOCAL INPATH '\/path\/to\/weblogs.txt' INTO TABLE weblogs;<\/code><\/pre>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 MapReduce:<\/p>\n<pre><code class=\"sql\">SELECT client_ip, COUNT(*) AS request_count FROM weblogs WHERE request_date LIKE '2021%' GROUP BY client_ip ORDER BY request_count DESC;<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 Hive \u0438\u043c\u0435\u0435\u0442 SQL-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u044f\u0437\u044b\u043a <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/azure\/hdinsight\/hadoop\/hdinsight-use-hive\">HiveQL <\/a>\u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u043c\u0438\u0441\u044f \u0432 HDFS. <\/p>\n<hr\/>\n<p>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f PostgreSQL \u0441 Hadoop \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043c\u043e\u0449\u043d\u044b\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 PostgreSQL \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Hadoop.  <\/p>\n<p><em>\u0412\u0441\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u0430 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u0430\u0445 OTUS: <\/em><a href=\"https:\/\/otus.pw\/2BeC\/\"><em>\u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435<\/em><\/a><em> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0430 <\/em><a href=\"https:\/\/otus.pw\/Ofn9\/\"><em>\u0432 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u0435<\/em><\/a><em> \u2014 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0443\u0440\u043e\u043a\u0438.<\/em><\/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\/817063\/\"> https:\/\/habr.com\/ru\/articles\/817063\/<\/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>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043d\u0435\u043a\u043e\u0435 \u043f\u0435\u0440\u0435\u043f\u0443\u0442\u044c\u0435, \u0433\u0434\u0435 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u2014 \u043c\u043e\u0449\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 <strong>PostgreSQL<\/strong>, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u2014 \u043d\u0435\u043e\u0431\u044a\u044f\u0442\u043d\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u044b <strong>Hadoop<\/strong>. \u0412\u044b\u0431\u043e\u0440 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u043c, \u043d\u043e \u0437\u0430\u0447\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u043e, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0435 \u0438\u0437 \u043e\u0431\u043e\u0438\u0445?<\/p>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044f \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u043e\u0449\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043c\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c Hadoop \u0438 \u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b HDFS \u0438 Hive<\/h4>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b Hadoop \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Java. \u041d\u0443\u0436\u043d\u043e \u044e\u0437\u0430\u0442\u044c JDK \u0432\u0435\u0440\u0441\u0438\u0438 8 \u0438\u043b\u0438 \u0432\u044b\u0448\u0435, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c 21 \u0432\u0435\u0440\u0441\u0438\u044e:<\/p>\n<pre><code class=\"bash\">sudo apt-get update sudo apt-get install openjdk-21-jdk<\/code><\/pre>\n<p>Hadoop \u0442\u0440\u0435\u0431\u0443\u0435\u0442 SSH \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u043c\u0438 <abbr class=\"habraabbr\" title=\"\u0412 Unix-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, &quot;\u0434\u0435\u043c\u043e\u043d\u044b&quot; (\u0430\u043d\u0433\u043b. daemons) \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0444\u043e\u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. Hadoop \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0435\u043c\u043e\u043d\u044b \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.\" data-title=\"&lt;p> \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. Hadoop \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0435\u043c\u043e\u043d\u044b \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.&#187; data-title=&#187;&lt;p>\u0412 Unix-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, &quot;\u0434\u0435\u043c\u043e\u043d\u044b&quot; (\u0430\u043d\u0433\u043b. daemons) \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0444\u043e\u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. Hadoop \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0435\u043c\u043e\u043d\u044b \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.&lt;\/p>&#187; data-abbr=&#187;\u0434\u0435\u043c\u043e\u043d\u0430\u043c\u0438 &#171;>\u0434\u0435\u043c\u043e\u043d\u0430\u043c\u0438 <\/abbr>Hadoop:<\/p>\n<pre><code class=\"bash\">sudo apt-get install ssh<\/code><\/pre>\n<p>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e Hadoop \u0441 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430 Apache \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0435\u0435:<\/p>\n<pre><code class=\"bash\">wget https:\/\/downloads.apache.org\/hadoop\/common\/hadoop-3.4.0.\/hadoop-3.4.0.tar.gz tar -xzf hadoop-3.4.0.tar.gz sudo mv hadoop-3.4.0. \/usr\/local\/hadoop<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b <code>~\/.bashrc<\/code>:<\/p>\n<pre><code class=\"bash\">export HADOOP_HOME=\/usr\/local\/hadoop export PATH=$PATH:$HADOOP_HOME\/bin:$HADOOP_HOME\/sbin export HADOOP_CONF_DIR=$HADOOP_HOME\/etc\/hadoop export YARN_HOME=$HADOOP_HOME<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\">source ~\/.bashrc<\/code><\/pre>\n<p>\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>$HADOOP_HOME\/etc\/hadoop<\/code>:<\/p>\n<ul>\n<li>\n<p><code>core-site.xml<\/code><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">&lt;configuration>     &lt;property>         &lt;name>fs.defaultFS&lt;\/name>         &lt;value>hdfs:\/\/localhost:9000&lt;\/value>     &lt;\/property> &lt;\/configuration><\/code><\/pre>\n<ul>\n<li>\n<p><code>hdfs-site.xml<\/code><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">&lt;configuration>     &lt;property>         &lt;name>dfs.replication&lt;\/name>         &lt;value>1&lt;\/value>     &lt;\/property>     &lt;property>         &lt;name>dfs.namenode.name.dir&lt;\/name>         &lt;value>file:\/\/\/usr\/local\/hadoop\/data\/namenode&lt;\/value>     &lt;\/property>     &lt;property>         &lt;name>dfs.datanode.data.dir&lt;\/name>         &lt;value>file:\/\/\/usr\/local\/hadoop\/data\/datanode&lt;\/value>     &lt;\/property> &lt;\/configuration><\/code><\/pre>\n<ul>\n<li>\n<p><code>mapred-site.xml<\/code><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">&lt;configuration>     &lt;property>         &lt;name>mapreduce.framework.name&lt;\/name>         &lt;value>yarn&lt;\/value>     &lt;\/property> &lt;\/configuration><\/code><\/pre>\n<ul>\n<li>\n<p><code>yarn-site.xml<\/code><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">&lt;configuration>     &lt;property>         &lt;name>yarn.nodemanager.aux-services&lt;\/name>         &lt;value>mapreduce_shuffle&lt;\/value>     &lt;\/property>     &lt;property>         &lt;name>yarn.nodemanager.aux-services.mapreduce.shuffle.class&lt;\/name>         &lt;value>org.apache.hadoop.mapred.ShuffleHandler&lt;\/value>     &lt;\/property> &lt;\/configuration><\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 HDFS \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Hadoop:<\/p>\n<pre><code class=\"bash\">hdfs namenode -format start-dfs.sh start-yarn.sh<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 Hadoop, \u043e\u0442\u043a\u0440\u044b\u0432 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 NameNode \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>http:\/\/localhost:9870<\/code>.<\/p>\n<p><strong>\u0414\u0430\u043b\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c Hive<\/strong><\/p>\n<p>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c Hive:<\/p>\n<pre><code class=\"bash\">wget https:\/\/downloads.apache.org\/hive\/hive-4.0.0\/apache-hive-4.0.0-bin.tar.gz tar -xzf apache-hive-4.0.0-bin.tar.gz sudo mv apache-hive-4.0.0-bin \/usr\/local\/hive<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b <code>~\/.bashrc<\/code>:<\/p>\n<pre><code class=\"bash\">export HIVE_HOME=\/usr\/local\/hive export PATH=$PATH:$HIVE_HOME\/bin export HADOOP_HOME=\/usr\/local\/hadoop export PATH=$PATH:$HADOOP_HOME\/bin<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"bash\">source ~\/.bashrc<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0434\u043b\u044f Hive \u0432 HDFS:<\/p>\n<pre><code class=\"bash\">hdfs dfs -mkdir \/tmp hdfs dfs -mkdir -p \/user\/hive\/warehouse hdfs dfs -chmod g+w \/tmp hdfs dfs -chmod g+w \/user\/hive\/warehouse<\/code><\/pre>\n<p>\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b <code>hive-site.xml<\/code> \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>$HIVE_HOME\/conf<\/code>:<\/p>\n<pre><code class=\"xml\">&lt;configuration>     &lt;property>         &lt;name>javax.jdo.option.ConnectionURL&lt;\/name>         &lt;value>jdbc:derby:;databaseName=metastore_db;create=true&lt;\/value>         &lt;description>JDBC connect string for a JDBC metastore&lt;\/description>     &lt;\/property>     &lt;property>         &lt;name>javax.jdo.option.ConnectionDriverName&lt;\/name>         &lt;value>org.apache.derby.jdbc.EmbeddedDriver&lt;\/value>         &lt;description>Driver class name for a JDBC metastore&lt;\/description>     &lt;\/property>     &lt;property>         &lt;name>hive.metastore.warehouse.dir&lt;\/name>         &lt;value>\/user\/hive\/warehouse&lt;\/value>         &lt;description>location of default database for the warehouse&lt;\/description>     &lt;\/property> &lt;\/configuration><\/code><\/pre>\n<p><strong>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c FDW \u0434\u043b\u044f Hadoop \u0432 PostgreSQL<\/strong><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c PostgreSQL \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:<\/p>\n<pre><code class=\"bash\">sudo apt-get install postgresql postgresql-contrib<\/code><\/pre>\n<p>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u043a\u0435\u043c \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c HDFS FDW:<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/your-github\/hdfs_fdw cd hdfs_fdw make sudo make install<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0432 PostgreSQL:<\/p>\n<pre><code class=\"sql\">CREATE EXTENSION hdfs_fdw;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0433\u043e\u0442\u043e\u0432\u0430 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e Hadoop \u0438 Hive \u0441 PostgreSQL \u0447\u0435\u0440\u0435\u0437 FDW.<\/p>\n<h4>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 PostgreSQL \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a Hadoop \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>CREATE SERVER<\/code>. \u042d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 FDW \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c.<\/p>\n<pre><code class=\"sql\">CREATE SERVER hdfs_server FOREIGN DATA WRAPPER hdfs_fdw OPTIONS (host '127.0.0.1', port '10000');<\/code><\/pre>\n<ul>\n<li>\n<p><code>hdfs_server<\/code> \u2014 \u0438\u043c\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445.<\/p>\n<\/li>\n<li>\n<p><code>FOREIGN DATA WRAPPER hdfs_fdw<\/code> \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 FDW.<\/p>\n<\/li>\n<li>\n<p><code>OPTIONS<\/code> \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>host<\/code> \u0438 <code>port<\/code> Hive \u0438\u043b\u0438 Spark \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u0432\u043d\u0435\u0448\u043d\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443:<\/p>\n<pre><code class=\"sql\">CREATE USER MAPPING FOR current_user SERVER hdfs_server OPTIONS (username 'hadoop_user', password 'hadoop_password');<\/code><\/pre>\n<ul>\n<li>\n<p><code>FOR current_user<\/code> \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f PostgreSQL.<\/p>\n<\/li>\n<li>\n<p><code>OPTIONS<\/code> \u2014 \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 Hadoop.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u043d\u0435\u0448\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>CREATE FOREIGN TABLE<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"sql\">CREATE FOREIGN TABLE hdfs_table (     id INT,     name TEXT ) SERVER hdfs_server OPTIONS (dbname 'default', table_name 'hdfs_table');<\/code><\/pre>\n<ul>\n<li>\n<p><code>hdfs_table<\/code> \u2014 \u0438\u043c\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 PostgreSQL.<\/p>\n<\/li>\n<li>\n<p><code>SERVER hdfs_server<\/code> \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a \u043a\u0430\u043a\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p><code>OPTIONS<\/code> \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>dbname<\/code> \u0438 <code>table_name<\/code>, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043d\u0430 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 Hive \u0438\u043b\u0438 Spark.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438:<\/p>\n<pre><code class=\"sql\">SELECT * FROM hdfs_table WHERE id > 10;<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>hdfs_table<\/code>, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0439\u0441\u044f \u0432 Hadoop, \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 PostgreSQL.<\/p>\n<p><strong>Push-down<\/strong> \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0447\u0430\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0412 Hadoop push-down \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 FDW.<\/p>\n<p>\u0414\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f push-down \u0432 PostgreSQL \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 FDW. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f push-down \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432:<\/p>\n<pre><code class=\"sql\">ALTER SERVER hdfs_server OPTIONS (SET enable_aggregate_pushdown 'true');<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e push-down \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<p><strong>MapReduce<\/strong> \u2014 \u044d\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0434\u0430\u0447. \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441 Hive, MapReduce \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440. \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 Hive:<\/p>\n<pre><code class=\"pgsql\">CREATE TABLE weblogs (     client_ip STRING,     request_date STRING,     request STRING,     response_code STRING,     bytes INT ) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ';<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<pre><code>LOAD DATA LOCAL INPATH '\/path\/to\/weblogs.txt' INTO TABLE weblogs;<\/code><\/pre>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 MapReduce:<\/p>\n<pre><code class=\"sql\">SELECT client_ip, COUNT(*) AS request_count FROM weblogs WHERE request_date LIKE '2021%' GROUP BY client_ip ORDER BY request_count DESC;<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 Hive \u0438\u043c\u0435\u0435\u0442 SQL-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u044f\u0437\u044b\u043a <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/azure\/hdinsight\/hadoop\/hdinsight-use-hive\">HiveQL <\/a>\u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u043c\u0438\u0441\u044f \u0432 HDFS. <\/p>\n<hr\/>\n<p>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f PostgreSQL \u0441 Hadoop \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043c\u043e\u0449\u043d\u044b\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 PostgreSQL \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Hadoop.  <\/p>\n<p><em>\u0412\u0441\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u0430 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u0430\u0445 OTUS: <\/em><a href=\"https:\/\/otus.pw\/2BeC\/\"><em>\u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435<\/em><\/a><em> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0430 <\/em><a href=\"https:\/\/otus.pw\/Ofn9\/\"><em>\u0432 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u0435<\/em><\/a><em> \u2014 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0443\u0440\u043e\u043a\u0438.<\/em><\/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\/817063\/\"> https:\/\/habr.com\/ru\/articles\/817063\/<\/a><br \/><\/br><\/br><\/p>\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-377709","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/377709","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=377709"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/377709\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=377709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=377709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=377709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}