{"id":7493,"date":"2013-07-12T02:08:52","date_gmt":"2013-07-11T17:08:52","guid":{"rendered":"http:\/\/fukata.org\/?p=7493"},"modified":"2017-08-11T22:58:47","modified_gmt":"2017-08-11T22:58:47","slug":"batch-script-migration-to-emr-3-days","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/7493\/","title":{"rendered":"3\u65e5\u3067\u65e2\u5b58\u306e\u30d0\u30c3\u30c1\u3092EMR\u306b\u79fb\u884c\u3057\u305f\u8a71"},"content":{"rendered":"
\u5148\u9031\u672b\u304b\u3089\u6025\u6fc0\u306b\u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u304c\u5897\u3048\u3066\u65e2\u5b58\u306e\u96c6\u8a08\u30d0\u30c3\u30c1\u3001\u30b5\u30fc\u30d0\u3067\u306f\u51e6\u7406\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u305f\u306e\u3067\u4eca\u9031\u982d\u304b\u3089\u6025\u907dEMR\u306b\u79fb\u3059\u3053\u3068\u3092\u6c7a\u610f\u3057\u307e\u3057\u305f\u3002<\/p>\n
<\/p>\n
\u76ee\u6b21<\/p>
\u4ee5\u524d\u306e\u69cb\u6210\u306f\u3053\u3093\u306a\u611f\u3058\u3002<\/p>\n
\r\n +----[S3]\r\n[AD\u30b5\u30fc\u30d0]N-----N[LogProxy]N--+\r\n +----[\u96c6\u8a08\u30b5\u30fc\u30d0]\r\n<\/pre>\nAD\u30b5\u30fc\u30d0\u304b\u3089LogProxy\u306b\u5bfe\u3057\u3066\u30e9\u30a6\u30f3\u30c9\u30ed\u30d3\u30f3\u3067\u30ed\u30b0\u3092\u8ee2\u9001\u3057\u3066LogProxy\u304b\u3089\u96c6\u8a08\u30b5\u30fc\u30d0(\u5358\u4f53\u30b5\u30fc\u30d0)\u306b\u96c6\u3081\u308b\u3068\u3044\u3046\u3082\u306e\u3002\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u5148\u3068\u3057\u3066S3\u3092\u5229\u7528\u3057\u3066\u3044\u307e\u3059\u3002\u30ed\u30b0\u306e\u8ee2\u9001\u306b\u306f\u3082\u3061\u308d\u3093fluentd\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002fluentd\u304c\u7121\u304b\u3063\u305f\u3089\u3068\u601d\u3046\u3068\u30be\u30c3\u3068\u3057\u307e\u3059\u3002<\/p>\n
\u30ed\u30b0\u306e\u6d41\u91cf\u304c\u591a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u9045\u5ef6\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u308a\u3001Log Proxy\u5074\u3067\u96c6\u8a08\u30b5\u30fc\u30d0\u306b\u6d41\u3057\u3066\u3044\u308b\u5206\u306e\u30ed\u30b0\u304c\u6ea2\u308c\u3066\u3057\u307e\u3046\u3068\u3044\u3046\u3053\u3068\u3082\u898b\u53d7\u3051\u3089\u308c\u307e\u3057\u305f\u3002\u4eee\u306b\u30ed\u30b0\u304c\u6b63\u5e38\u306b\u96c6\u8a08\u30b5\u30fc\u30d0\u306b\u96c6\u307e\u3063\u305f\u3068\u3057\u3066\u3082\u96c6\u8a08\u51e6\u7406\u304c\u9577\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u3001\u6642\u9593\u5225\u306e\u96c6\u8a08\u3082\u65e5\u3005\u5ef6\u3073\u3066\u304a\u308a\u30011\u65e5\u5206\u306e\u518d\u96c6\u8a08\u306b\u95a2\u3057\u3066\u306f\u30a2\u30db\u304b\u3063\u3066\u304f\u3089\u3044\u6642\u9593\u304c\u639b\u304b\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n
\u305d\u3046\u3044\u3046\u3053\u3068\u3082\u3042\u3063\u3066EMR\u306b\u79fb\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n
\u5168\u4f53\u7684\u306a\u69cb\u6210\u81ea\u4f53\u306f\u5909\u308f\u3063\u3066\u304a\u3089\u305a\u3001LogProxy\u304b\u3089S3\u3078\u30a2\u30c3\u30d7\u3057\u305f\u30ed\u30b0\u3092EMR\u306b\u98df\u308f\u3059\u3068\u3044\u3046\u3082\u306e\u3002\u305f\u3060\u3001\u5168\u3066S3\u306b\u79fb\u3059\u3068\u6c17\u8efd\u306b\u30ed\u30b0\u3092\u898b\u305f\u3044\u6642\u306b\u4e0d\u4fbf\u306a\u306e\u3067\u3001EMR\u3067\u51e6\u7406\u3057\u306a\u304f\u3066\u3082\u5927\u4e08\u592b\u306a\u91cf\u306e\u30ed\u30b0\u306b\u95a2\u3057\u3066\u306f\u4eca\u307e\u3067\u96c6\u8a08\u30b5\u30fc\u30d0\u3067\u3001\u591a\u3044\u3082\u306e\u3060\u3051EMR\u3067\u51e6\u7406\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u3001EMR\u3067\u51e6\u7406\u3055\u305b\u308b\u30ed\u30b0\u306b\u95a2\u3057\u3066\u3082\u3001\u50be\u5411\u3092\u898b\u305f\u308a\u7d71\u8a08\u30c7\u30fc\u30bf\u3092\u7b97\u51fa\u3059\u308b\u306e\u306b\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u5f8c(1\/100\u3068\u304b)\u3092\u96c6\u8a08\u30b5\u30fc\u30d0\u306b\u6d41\u3059\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n
S3\u3078\u306fYYYY\/MM\/DD\/HH\/hoge.${AD\u30b5\u30fc\u30d0\u306eHOST}.${LogProxy\u30b5\u30fc\u30d0\u306eHOST.PORT}.log<\/strong>\u306e\u3088\u3046\u306b\u6642\u9593\u307e\u3067\u968e\u5c64\u5316\u3055\u308c\u3066\u305d\u306e\u4e2d\u306b\u5404\u7a2e\u30ed\u30b0\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n
hive or streaming?<\/span><\/h2>\n
EMR\u3067java,hive,streaming\u306a\u3069\u3069\u308c\u3092\u4f7f\u304a\u3046\u304b\u8ff7\u3063\u305f\u6319\u53e5\u3001\u8abf\u67fb\u3092\u3059\u308b\u6642\u9593\u3082\u306a\u304b\u3063\u305f\u306e\u3067\u4ee5\u524d\u5c11\u3057\u89e6\u3063\u305f\u3053\u3068\u304c\u3042\u308bstreaming\u306b\u3057\u307e\u3057\u305f\u3002\u51e6\u7406\u304c\u7c21\u5358\u306a\u3082\u306e\u306fhive\u3092\u4f7f\u3063\u305f\u65b9\u304cmapper\/reducer\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u304b\u306a\u304f\u3066\u304f\u3066\u30e1\u30f3\u30c6\u6027\u3082\u4e0a\u304c\u308b\u306e\u3067\u69d8\u5b50\u3092\u898b\u306a\u304c\u3089streaming\u3067\u5b9f\u88c5\u3057\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3092hive\u3067\u518d\u5b9f\u88c5\u3057\u3088\u3046\u304b\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n
\u30b8\u30e7\u30d6\u306e\u767b\u9332\u3068\u53d6\u308a\u8fbc\u307f<\/span><\/h2>\n
cron\u306a\u3069\u304b\u3089\u5b9a\u671f\u7684\u306b\u30b8\u30e7\u30d6\u3092\u767b\u9332\u3059\u308b\u305f\u3081\u306e\u4ed5\u7d44\u307f\u3068\u3001\u51e6\u7406\u304c\u7d42\u308f\u3063\u305f\u30b8\u30e7\u30d6\u3092\u65e2\u5b58DB(mysql)\u3078\u53d6\u308a\u8fbc\u3080\u305f\u3081\u306e\u4ed5\u7d44\u307f\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n
\u30b8\u30e7\u30d6\u306e\u767b\u9332<\/span><\/h3>\n
\u30b8\u30e7\u30d6\u306e\u767b\u9332\u306felastic-mapreduce-ruby<\/a>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3092\u4f7f\u3048\u3070\u51fa\u6765\u308b\u3093\u3067\u3059\u304c\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306e\u30ed\u30fc\u30c9\u3068\u304b\u8272\u3005\u65e2\u5b58\u30a2\u30d7\u30ea\u3068\u5171\u901a\u5316\u3057\u305f\u304b\u3063\u305f\u306e\u3067perl\u304b\u3089\u547c\u3076\u3053\u3068\u306b\u3002\u3002\u3002\u3053\u3093\u306a\u611f\u3058\u3067\u767b\u9332\u51fa\u6765\u308b\u3002<\/p>\n
\r\nperl job_register.pl --func='hoge_func' --from='2013-07-11 00:00:00' --to='2013-07-12 00:00:00'\r\n<\/pre>\n\u3059\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u306e\u5f15\u6570\u3067elastic-mapreduce-ruby\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<\/p>\n
\r\nelastic-mapreduce --create --stream \\\r\n--enable-debugging \\\r\n--mapper s3n:\/\/bucket\/path\/to\/mapper \\\r\n--reducer s3n:\/\/bucket\/path\/to\/reducer \\\r\n--log-uri s3n:\/\/bucket\/path\/to\/debug\/YYYY\/MM\/DD\/hoge_func_HHMMSS\r\n--output s3n:\/\/bucket\/path\/to\/output\/YYYY\/MM\/DD\/hoge_func_HHMMSS\r\n--master-instance-type m1.small \\\r\n--slave-instance-type m1.small \\\r\n--num-instances 3 \\\r\n--input s3n:\/\/bucket\/path\/to\/logs\/2013\/07\/11\/*\/impression.*.log.gz,s3n:\/\/bucket\/path\/to\/logs\/2013\/07\/11\/*\/click.*.log.gz\r\n<\/pre>\ninstance-type\u3001num-instances\u306a\u3069\u5404\u7a2e\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u95a2\u3057\u3066\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306f\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066job_register.pl\u306e\u5f15\u6570\u3067\u4e0a\u66f8\u304d\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u3067\u3001\u6642\u9593\u5e2f\u6bce\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u6570\u3092\u5909\u3048\u305f\u308a\u3059\u308b\u306e\u3082\u697d\u3067\u3059\u3002<\/p>\n
\u53d6\u308a\u8fbc\u307f<\/span><\/h3>\n
\u5148\u307b\u3069\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u304b\u3089\u767b\u9332\u3055\u308c\u305f\u30b8\u30e7\u30d6ID\u306f\u30b8\u30e7\u30d6\u30ad\u30e5\u30fc\u306b\u767b\u9332\u3055\u308c\u3001\u76e3\u8996\u7528worker\u3067\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u76e3\u8996\u3057\u3066\u3001\u6b63\u5e38\u7d42\u4e86\u3057\u3066\u3044\u305f\u3089\u5404\u51e6\u7406(hoge_func\u7b49)\u500b\u5225\u306e\u53d6\u308a\u8fbc\u307f\u30d0\u30c3\u30c1\u3092\u5b9f\u884c\u3059\u308b\u3068\u3044\u3046\u3082\u306e\u3092\u5b9f\u88c5\u3057\u3066\u3044\u307e\u3059\u3002\u30b9\u30c6\u30fc\u30bf\u30b9\u304c\u51e6\u7406\u4e2d\u306e\u5834\u5408\u306f\u4e00\u5b9a\u6642\u9593\u5f8c\u306b\u518d\u5ea6\u30c1\u30a7\u30c3\u30af\u3002\u7570\u5e38\u7d42\u4e86\u3001\u30ad\u30e3\u30f3\u30bb\u30eb\u306e\u5834\u5408\u306f\u30b8\u30e7\u30d6\u30ad\u30e5\u30fc\u304b\u3089\u524a\u9664\u3002\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<\/p>\n
\u51e6\u7406\u500b\u5225\u306e\u53d6\u308a\u8fbc\u307f\u30d0\u30c3\u30c1\u306b\u95a2\u3057\u3066\u306fworker\u304b\u3089\u3057\u304b\u8d77\u52d5\u3067\u304d\u306a\u3044\u3068\u958b\u767a\u6642\u306a\u3069\u3081\u3093\u3069\u304f\u3055\u3044\u306e\u3067\u30b9\u30af\u30ea\u30d7\u30c8\u5358\u4f53\u3067\u3082\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n
\u307e\u3068\u3081<\/span><\/h2>\n
1\u65e5\u5206\u306e\u96c6\u8a08\u304c20\u6642\u9593\u5f31\u304b\u304b\u3063\u3066\u3044\u305f\u306e\u304c1\u6642\u9593\u672a\u6e80\u3067\u7d42\u308f\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u308a\u3068\u30b9\u30b1\u30fc\u30eb\u3059\u308b\u3063\u3066\u7d20\u6674\u3089\u3057\u3044\uff01\u3053\u3093\u306a\u3053\u3068\u306a\u3089\u3055\u3063\u3055\u3068EMR\u306b\u79fb\u3057\u3066\u304a\u3051\u3070\u826f\u304b\u3063\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5148\u9031\u672b\u304b\u3089\u6025\u6fc0\u306b\u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u304c\u5897\u3048\u3066\u65e2\u5b58\u306e\u96c6\u8a08\u30d0\u30c3\u30c1\u3001\u30b5\u30fc\u30d0\u3067\u306f\u51e6\u7406\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u305f\u306e\u3067\u4eca\u9031\u982d\u304b\u3089\u6025\u907dEMR\u306b\u79fb\u3059\u3053\u3068\u3092\u6c7a\u610f\u3057\u307e\u3057\u305f\u3002 … \u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":2,"featured_media":9223372036854775807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1980],"tags":[1039],"_links":{"self":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/7493"}],"collection":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/comments?post=7493"}],"version-history":[{"count":0,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/7493\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media\/9223372036854775807"}],"wp:attachment":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media?parent=7493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/categories?post=7493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/tags?post=7493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}