如何在Amazon EMR上添加连接器到presto

问题描述 投票:3回答:3

我已经安装了一个安装了Hive / Presto的小型EMR集群,我想在S3上查询文件并将它们导入到RDS上的Postgres。

要在S3上运行查询并将结果保存在postgres中的表中,我已完成以下操作:

  1. 从AWS控制台启动3节点EMR集群。
  2. 手动SSH进入主节点以在配置单元中创建EXTERNAL表,查看S3存储桶。
  3. 手动SSH到3个节点中的每个节点并添加新的目录文件: /etc/presto/conf.dist/catalog/postgres.properties 具有以下内容 connector.name=postgresql connection-url=jdbc:postgresql://ip-to-postgres:5432/database connection-user=<user> connection-password=<pass> 并编辑了这个文件 /etc/presto/conf.dist/config.properties 加入 datasources=postgresql,hive
  4. 通过在所有3个节点上手动运行以下命令重新启动 sudo restart presto-server

这种设置似乎运作良好。

在我的应用程序中,有多个动态创建的数据库。似乎需要为每个数据库进行那些配置/目录更改,并且需要重新启动服务器以查看新配置更改。

我的应用程序(使用boto或其他方法)是否有适当的方式来更新配置

  1. 在/etc/presto/conf.dist/catalog/的所有节点中为每个新数据库添加新目录文件
  2. 在/etc/presto/conf.dist/config.properties中的所有节点中添加新条目
  3. 优雅地在整个集群中重新启动presto(理想情况下,当它变​​为空闲时,但这不是一个主要问题。
amazon-web-services hive emr presto
3个回答
1
投票

我相信你可以运行一个简单的bash脚本来实现你想要的。除了使用--configurations参数创建新群集之外,没有其他方法可以提供所需的配置。您可以从主节点运行以下脚本。

#!/bin/sh

# "cluster_nodes.txt" with private IP address of each node.
aws emr list-instances --cluster-id <cluster-id> --instance-states RUNNING | grep PrivateIpAddress | sed 's/"PrivateIpAddress"://' | sed 's/\"//g' | awk '{gsub(/^[ \t]+|[ \t]+$/,""); print;}' > cluster_nodes.txt

# For each IP connect with ssh and configure.
while IFS='' read -r line || [[ -n "$line" ]]; do
    echo "Connecting $line"
    scp -i <PEM file> postgres.properties hadoop@$line:/tmp;
    ssh -i <PEM file> hadoop@$line "sudo mv /tmp/postgres.properties /etc/presto/conf/catalog;sudo chown presto:presto /etc/presto/conf/catalog/postgres.properties;sudo chmod 644 /etc/presto/conf/catalog/postgres.properties; sudo restart presto-server";
done < cluster_nodes.txt

0
投票

在提供群集期间:您可以在提供时提供配置详细信息。

有关如何在提供群集期间自动添加此信息,请参阅Presto Connector Configuration


0
投票

您可以通过管理控制台提供以下配置:

Create Cluster EMR Console

或者您可以使用awscli传递这些配置,如下所示:

#!/bin/bash

JSON=`cat <<JSON
[
  { "Classification": "presto-connector-postgresql",
    "Properties": {
      "connection-url": "jdbc:postgresql://ip-to-postgres:5432/database",
      "connection-user": "<user>",
      "connection-password": "<password>"
    },
    "Configurations": []
  }
]
JSON`

aws emr create-cluster --configurations "$JSON" # ... reset of params
© www.soinside.com 2019 - 2024. All rights reserved.