【问题标题】:Push data from aws lambda to redshift将数据从 aws lambda 推送到 redshift
【发布时间】:2016-09-22 22:04:33
【问题描述】:

我正在尝试创建一个将连接到 RedShift 的 Lambda 函数:

var pg = require('pg');
var conString = 'postgresql://username:Password@JDBC-URL';
var client = new pg.Client(conString);
client.connect(function(err) { if(err) {
        console.log('could not connect to redshift', err);
    }
    });
pgClient.end();

但我得到了这个例外:

Unable to import module 'index': Error 
at Function.Module._resolve Filename (module.js:325:15) 
at Function.Module._load (module.js:276:25) 
at Module.require (module.js:353:17) 
at require (internal/module.js:12:17) 
at Object.<anonymous> (/var/task/index.js:1:72) 
at Module._compile (module.js:409:26) 
at Object.Module._extensions..js (module.js:416:10) 
at Module.load (module.js:343:32) 
at Function.Module._load (module.js:300:12) 
at Module.require (module.js:353:17)

谁能帮帮我。

谢谢。

【问题讨论】:

  • 有解决办法吗?

标签: amazon-web-services amazon-redshift aws-lambda


【解决方案1】:

如果您的目标是将数据从 AWS Lambda 推送到 Amazon Redshift,您可以使用 AWS Lambda Redshift Loader

见: A Zero-Administration Amazon Redshift Database Loader

【讨论】:

    【解决方案2】:

    另一种从 Lambda 将数据加载到 Amazon Redshift 的成功方法是通过 kinesis firehose[1],它可以在内部将数据保存在 s3 中,而推荐使用这种方法将数据加载到 redshift 而不是插入命令。[2]

    数据流: Lambda > Firehose (s3) > Redshift。

    对于那些使用这种方式来节省时间的人的进一步阅读建议(即使它是故障排除指南,如果事先阅读它可以节省大量时间): https://stackoverflow.com/a/34221861/2406687

    脚注:

    [1] http://docs.aws.amazon.com/redshift/latest/dg/t_Loading_data.html 上的“COPY 命令是加载表的最有效方式。您也可以使用 INSERT 命令将数据添加到表中,尽管它的效率远低于使用 COPY”。

    [2]http://docs.aws.amazon.com/firehose/latest/dev/what-is-this-service.html

    【讨论】:

      猜你喜欢
      • 2016-11-13
      • 2016-10-31
      • 2018-04-13
      • 1970-01-01
      • 1970-01-01
      • 2018-09-14
      • 2019-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多