zoukankan      html  css  js  c++  java
  • AWS Redshift 采坑记

    1.不要使用快速启动集群的方式建立,否则vpc是一个巨坑

    2.要配置对应的Role 并配置化 role arn

    3..net 连接类

    using Amazon.Redshift;
    using Amazon.Redshift.Model;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Odbc;
    using System.Text;
    
    namespace eXconsole
    {
         public  class redshiftdb
        {
            public void TestConnectivityOnMasterNode(string clusterName)
            {
                using (IAmazonRedshift redshiftClient = new AmazonRedshiftClient())
                {
                    try
                    {
                        DataSet ds = new DataSet();
                        DataTable dt = new DataTable();
                        DescribeClustersRequest describeClustersRequest = new DescribeClustersRequest() { ClusterIdentifier = clusterName };
                        DescribeClustersResponse describeClustersResponse = redshiftClient.DescribeClustersAsync().GetAwaiter().GetResult();
                        Cluster firstMatch = describeClustersResponse.Clusters[0];
    
                        String mainDbName = firstMatch.DBName;
                        String endpointAddress = firstMatch.Endpoint.Address;
                        int endpointPort = firstMatch.Endpoint.Port;
                        string masterUsername = firstMatch.MasterUsername;
                        string password = "your master password";
    
    
                        string odbcConnectionString = string.Concat("Driver={PostgreSQL Unicode}; Server=", endpointAddress
                            , "; Database=", mainDbName, "; UID=", masterUsername, "; PWD=", password
                            , "; Port=", endpointPort);
                        string odbcConnectionDsn = "DSN=UrlsRedShiftDb";
                        string query = "SELECT datname FROM pg_database WHERE datistemplate = false;";
    
                        using (OdbcConnection conn = new OdbcConnection(odbcConnectionString))
                        {
                            try
                            {
                                conn.Open();
                                OdbcDataAdapter da = new OdbcDataAdapter(query, conn);
                                da.Fill(ds);
                                dt = ds.Tables[0];
                                foreach (DataRow row in dt.Rows)
                                {
                                    Console.WriteLine(row["datname"]);
                                }
    
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Exception caught while communicating with RedShift master node: ");
                                Console.WriteLine(ex.Message);
                            }
                        }
                    }
                    catch (AmazonRedshiftException e)
                    {
                        Console.WriteLine("Postgresql command execution on master node has failed.");
                        Console.WriteLine("Amazon error code: {0}",
                            string.IsNullOrEmpty(e.ErrorCode) ? "None" : e.ErrorCode);
                        Console.WriteLine("Exception message: {0}", e.Message);
                    }
                }
            }
        }
    }
  • 相关阅读:
    css绘制各种图形,三角形,长方形,梯形
    函数中,对形参做不加var的全局溢出赋值,可改变形参所指向的实参的本身值
    求数组中最大值,最小值
    placeholder 效果的实现,input提示字,获取焦点时消失
    js里apply用法
    jquery.lazyload.js-v1.9.1延时加载插件,已兼容ie6和各大浏览器
    移动端 元素外面使用伪类after加边框 导致其内部元素无法选中
    element组件知识点总结
    常用样式总结
    深入理解iframe
  • 原文地址:https://www.cnblogs.com/Johnson-zhao/p/10758126.html
Copyright © 2011-2022 走看看