gpt4 book ai didi

amazon-web-services - 如何将连接器添加到 Amazon EMR 上的 presto

转载 作者:行者123 更新时间:2023-12-04 00:14:08 24 4
gpt4 key购买 nike

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

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

  1. 从 AWS 控制台启动了一个 3 节点 EMR 集群。
  2. 手动通过 SSH 连接到主节点以在配置单元中创建一个外部表,查看 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 个节点上手动运行以下命令重新启动 presto

    sudo restart presto-server

此设置似乎运行良好。

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

我的应用程序是否有正确的方法(使用 boto 或其他方法)更新配置

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

最佳答案

我相信您可以运行一个简单的 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

关于amazon-web-services - 如何将连接器添加到 Amazon EMR 上的 presto,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36068935/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com