分类: Amazon Web Service

  • Java BigDecimal 转换为 Parquet Decimal

    记录个问题。有用户想通过 Java 自行生成 Parquet 文件,不通过 Hive, Spark 等软件。

    用户直接将 BigDecimal toByteArray(),然后用 Hive/Athena 都读不出来正确的数值。查看 Hive 的做法,它实际上是用 unscaledValue() 转换成 BigInt,再 toByteArray() 存入 Parquet 的。
    (更多…)

  • 如何模拟EMRFS处理S3返回503 Slow Down的情况

    在 EMRFS (EMR 5.25) 的配置文件 /usr/share/aws/emr/emrfs/conf/emrfs-default.xml 里看到 fs.s3.sleepTimeSeconds 这个参数。按照配置文件里的注释,这个参数控制 S3 调用失败重试的间隔,默认是10秒。
    由于 EMRFS 闭源,想测试一下,验证这个参数是否有效。
    (更多…)

  • 安装并使用 xrdp 连接 ubuntu 桌面


    公司的电脑是 Windows 10, 不给管理员权限,什么都干不了。 在不买新电脑的前提下,只好通过远程连接到 AWS 的 Ubuntu 桌面上工作。 记录一下安装方法。

    环境

    – AWS
    – Ubuntu 18.04
    (更多…)

  • hive failed renaming s3 table with error “New location for this table already exist”

    Issue

    – In hive-cli, rename table with command:
    [cc lang=”text”]
    hive> alter table large_table_bk rename to large_table;
    [/cc]

    – 10 minutes later, it prompts error.
    [cc]
    FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Unable to alter table. New location for this table default.large_table already exists : s3://feichashao-hadoop/warehouse/large_table
    [/cc]

    – However, before executing the “rename” command, the directory was not exist in S3, so we don’t expect such an error.
    (更多…)

  • hive-server2 remains 2k+ s3n-worker threads after job finished


    tldr: This is a bug in EMR 5.6. Upgrading to EMR 5.8 or above can solve the issue.

    Issue

    User reported that he sees 2000+ s3n-worker threads after job finished. He has to restart the hive-server2 service everyday to mitigate the issue.
    [cc lang=”text”]
    # sudo -u hive jstack 11089 | grep s3n-worker | wc -l
    2000
    [/cc]

    The threads are repeating from s3n-worker-0 to s3n-worker-19. In another word, there are 100 * 20 s3n-worker threads.
    [cc lang=”text”]
    “s3n-worker-19” #70 daemon prio=5 os_prio=0 tid=0x00007f5ac4cf0800 nid=0x10ad waiting on condition [0x00007f5ac1dee000]
    ……
    “s3n-worker-1” #52 daemon prio=5 os_prio=0 tid=0x00007f5ac5462000 nid=0x109b waiting on condition [0x00007f5aca23f000]
    “s3n-worker-0” #51 daemon prio=5 os_prio=0 tid=0x00007f5ac5480000 nid=0x109a waiting on condition [0x00007f5aca641000]
    ……
    [/cc]

    Environment

    AWS EMR 5.6
    (更多…)

  • Spark RDD checkpoint on S3 exits with exception intermittently

    Issue

    – Run a spark job and save RDD checkpoint to S3.
    – Spark job failed intermittently with below error:
    [cc lang=”text”]
    org.apache.spark.SparkException: Checkpoint RDD has a different number of partitions from original RDD. Original RDD [ID: xxx, num of partitions: 6]; Checkpoint RDD [ID: xxx, num of partitions: 5].
    [/cc]
    (更多…)

  • AWS SNS 自定义邮件格式

    AWS 的 SES (Simple Email Service) 可以提供邮件收发服务。对于邮件收发的反馈,如 Bounce message, 可以发送到 SNS (Simple Notification Service) 作进一步处理。SNS 可以指定某个邮件地址作为订阅者,将消息发送到该邮箱中。然而,SNS发出来的邮件是 JSON,可读性不好,例如:
    [cc lang=”text”]
    {“notificationType”:”Delivery”,”mail”:{“timestamp”:”2019-02-18T06:03:02.669Z”,”source”:”kfc@feichashao.com”,”sourceArn”:”arn:aws:ses:us-west-2:xxxxxx:identity/feichashao.com”,”sourceIp”:”205.251.234.36″,”sendingAccountId”:”xxxxxx”,”messageId”:”01010168ff335c8d-f00ce1c1-e103-49cd-912f-9f397c7a463c-000000″,”destination”:[“feichashao@gmail.com”],”headersTruncated”:false,”headers”:[{“name”:”From”,”value”:”kfc@feichashao.com”},{“name”:”To”,”value”:”feichashao@gmail.com”},{“name”:”Subject”,”value”:”free kfc”},{“name”:”MIME-Version”,”value”:”1.0″},{“name”:”Content-Type”,”value”:”text/plain; charset=UTF-8″},{“name”:”Content-Transfer-Encoding”,”value”:”7bit”}],”commonHeaders”:{“from”:[“kfc@feichashao.com”],”to”:[“feichashao@gmail.com”],”subject”:”free kfc”}},”delivery”:{“timestamp”:”2019-02-18T06:03:03.917Z”,”processingTimeMillis”:1248,”recipients”:[“feichashao@gmail.com”],”smtpResponse”:”250 2.0.0 OK 1550469783 q2si13329671plh.79 – gsmtp”,”remoteMtaIp”:”74.125.20.27″,”reportingMTA”:”a27-30.smtp-out.us-west-2.amazonses.com”}}
    [/cc]

    怎么能让这个提醒邮件变得更加友好呢? SNS目前不支持自定义邮件格式。一个思路是,将 SNS 的消息发送到 Lambda 上,让 Lambda 处理好格式后,再发送到指定邮箱。即 SES -> SNS -> Lambda -> SES.
    (更多…)

  • Hive 中使用 UDF (用户自定义函数) 示例

    记个简单的步骤方便后面使用。想实现的效果是自定义一个函数,用在 Hive 中。例如,在字符串前加个 Hello.
    [cc lang=”text”]
    hive> select hello(firstname) from people limit 10;
    OK
    Hello hehe
    [/cc]
    (更多…)

  • 如何使 Hive 对 DynamoDB 进行并发读取?

    问题背景

    DynamoDB 创建了类似如下的表:
    [cc lang=”text”]
    {
    “accessid”: “c63b88a3-1503-4c2c-a7c2-3a1ffde7bff9”, // Primary key.
    “date”: “2018-12-12”,
    “when”: “2018-12-12 17:22:15”,
    “context”: “something”
    }
    [/cc]
    这个表用来记录访问记录,以 accessid (随机字符串) 作为 Primary key. Date 记录当条记录的生成日期。

    我们希望通过 Hive 每天将前一天的数据从 DynamoDB 备份到 S3 上,具体方法可参考文档[1].
    [cc lang=”text”]
    hive> INSERT OVERWRITE TABLE s3_table
    > SELECT * FROM ddb_table WHERE date=”2018-12-12″;
    [/cc]
    Dynamodb表里存放了很多天的数据,执行以上操作会消耗很长时间,如何能加快速度?比如让 Hive 进行并发读取?
    (更多…)

  • Hive 去除 CSV 字段中的双引号

    问题

    在 AWS 中,可以开启详细账单的功能。开启详细账单后,AWS 每天会多次将详细的账单数据存入到指定的 S3 bucket 中[1]。
    账单数据是一个 CSV 文件,示例如下:
    [cc lang=”text”]
    “InvoiceID”,”PayerAccountId”,”LinkedAccountId”,”RecordType”,”ProductName”,”RateId”,”SubscriptionId”,”PricingPlanId”,”UsageType”,”Operation”,”AvailabilityZone”,”ReservedInstance”,”ItemDescription”,”UsageStartDate”,”UsageEndDate”,”UsageQuantity”,”Rate”,”Cost”
    “Estimated”,”xxxxxxxxxxxx”,”xxxxxxxxxxxx”,”LineItem”,”Amazon Simple Queue Service”,”16850885″,”1846142824″,”1292565″,”CNN1-Requests-Tier1″,”GetQueueAttributes”,””,”N”,”First 1,000,000 Amazon SQS Requests per month are free”,”2019-01-01 00:00:00″,”2019-01-01 01:00:00″,”60.0000000000″,”0.0000000000″,”0.0000000000″
    “Estimated”,”xxxxxxxxxxxx”,”xxxxxxxxxxxx”,”LineItem”,”Amazon Simple Queue Service”,”16850885″,”1846142824″,”1292565″,”CNN1-Requests-Tier1″,”GetQueueUrl”,””,”N”,”First 1,000,000 Amazon SQS Requests per month are free”,”2019-01-01 00:00:00″,”2019-01-01 01:00:00″,”180.0000000000″,”0.0000000000″,”0.0000000000″
    [/cc]
    第一行是每个字段的名字,后面的行是相应的数据。
    (更多…)