<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Boy Burin on Medium]]></title>
        <description><![CDATA[Stories by Boy Burin on Medium]]></description>
        <link>https://medium.com/@boyburin_29108?source=rss-9d64b588e3e6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Os_JhIwzhCGr30xN.</url>
            <title>Stories by Boy Burin on Medium</title>
            <link>https://medium.com/@boyburin_29108?source=rss-9d64b588e3e6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 19:12:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@boyburin_29108/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[Day 10] Big Data School #2 Date 09/06/2017]]></title>
            <link>https://medium.com/@boyburin_29108/day-10-big-data-school-2-date-09-06-2017-476366f8a213?source=rss-9d64b588e3e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/476366f8a213</guid>
            <dc:creator><![CDATA[Boy Burin]]></dc:creator>
            <pubDate>Mon, 12 Jun 2017 06:12:06 GMT</pubDate>
            <atom:updated>2017-06-12T06:12:06.045Z</atom:updated>
            <content:encoded><![CDATA[<p>วันนี้อาจารย์ มาบรรยายเกี่ยวกับ Big data as a Service on Google Cloud platform โดยมี key สำคัญดังนี้</p><p><strong>Handle Big data</strong></p><ol><li>Hadoop on premise (ไม่มีปัญหาด้าน latency)</li><li>Hadoop on Cloud VM (ปัญหา latencyหรือ speed แต่ค่าใช้จ่ายสูง)</li><li>Cloud storage + cloud process (มีปัญหา Latency หรือ speed)</li></ol><p><strong>Google Cloud storage (จ่ายตามใช้)</strong></p><ul><li>Nearline and coldline (cold data) → เหมาะกับ data ที่ไม่ค่อยได้โดยเรียกใช้งานบ่อยๆ โดยราคาถูกมาก</li></ul><p>โดยก่อนอาจารย์บรรยายได้ให้มาทำ presentation กลุ่มเราไม่ต้อง presentation แต่ให้ลองแก้ไขปัญหาที่ได้รับมาโดยวาด flow การจัดการกับ log data ที่มาจาก website ว่าต้องทำอย่างไร โดยเริ่มแรกต้อง ingest ข้อมูลก่อนจากนั้นนำไปเก็ยอาจจะเป็น HDFS แล้วใช้ Hive หรือ Spark ทำการวิเคราะห์ ซึ่ง solution ที่นำเสนอไปตอนแรกมีการใช้ services เยอะไปเกินความจำเป็น เราต้องมองถึงด้านการลงทุนด้วยว่าถ้าเราใช้หลายตัวจะเป็นยังไง คุ้มไหมห</p><p>— — — โดยหลังฝึกงานเสร็จ — — — -</p><p>วันนี้ได้ไปพบเพื่อนๆที่สยามโดยได้ไปกินซูซิ, บิงซู และคุยงาน Project ก่อนจะถึงบ้านในเวลา 5 ทุ่ม และวันนี้ฝนตกหนักมาก ร้องไห้หนักมาก</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=476366f8a213" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Day 9] Big Data School #2 Date 08/06/2017]]></title>
            <link>https://medium.com/@boyburin_29108/day-9-big-data-school-2-date-08-06-2017-3c0ffc62a467?source=rss-9d64b588e3e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c0ffc62a467</guid>
            <dc:creator><![CDATA[Boy Burin]]></dc:creator>
            <pubDate>Mon, 12 Jun 2017 06:11:07 GMT</pubDate>
            <atom:updated>2017-06-12T06:11:07.783Z</atom:updated>
            <content:encoded><![CDATA[<p>ในวันนี้พี่โอ๊ตได้มาบรรยายเกี่ยวกับ Spark โดยได้สอนตาม material ที่ชื่อว่า Cloudera Developer Training for Apache Spark ซึ่งได้เรียบเรียงเนื้อหาได้เข้าใจง่ายมากๆ รวมถึงได้สอนการใช้ dataproc แบบพื้นฐานรวมถึงการติดตั้ง Jupyter บน dataproc</p><p><strong>— — -พักเที่ยง — — —</strong></p><p>วันนี้ไปกินเซเว่น โดยซื้อไส้กรอกบุชเชอร์และอกไก่ชิ้นโตแสนอร่อย</p><p><strong>— — หลังพักกลางวัน — — -</strong></p><p>ช่วงบ่ายได้พูดถึง Spark ต่อโดยมี key ที่สำคัญอีกดังนี้</p><p><strong>Install Jupiter on dataproc</strong></p><p>gs://dataproc-initialization-actions/jupyter/jupyter.sh</p><p><strong>Script for creating Scala</strong></p><p>#!/bin/bash</p><p>apt install apt-transport-https -y</p><p>echo “deb <a href="https://dl.bintray.com/sbt/debian">https://dl.bintray.com/sbt/debian</a> /” | sudo tee -a /etc/apt/sources.list.d/sbt.list</p><p>apt-key adv — keyserver hkp://keyserver.ubuntu.com:80 — recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823</p><p>apt update</p><p>apt install sbt -y</p><p>git clone <a href="https://github.com/alexarchambault/jupyter-scala.git">https://github.com/alexarchambault/jupyter-scala.git</a></p><p>cd jupyter-scala</p><p>sbt publishLocal</p><p>./jupyter-scala — id scala-develop — name “Scala (develop)” — force</p><p><strong>RDD (Resilient Distributed Dataset) → RDD is immutable</strong></p><ul><li>Resilient → if data in memory lost, it can be recreate</li><li>Distributed → store in distributed across cluster</li></ul><p><strong>Two type of RDD</strong></p><ul><li>Action → return value</li><li>Transform → new RDD</li></ul><p><strong>Lazy execution</strong></p><p>RDD are not always immediately materialized</p><ul><li>RDD is materialized in memory upon the first action that use it.</li></ul><p><strong>**Transformation can be chain together (เรียกใช้ต่อเนื่อง)</strong></p><p><strong>**Functional programming (State not change)</strong></p><ul><li><strong>*Sc.parallelize(collection) </strong>for creating RDD from collections instead of files</li></ul><p>หลังจากนั้นก็ทำการเตรียม powerpoint โดยทำการสรุปสิ่งที่เรียนมาเพื่อนำไป present ในวันพรุ่งนี้</p><p>— — -กลับบ้าน — — -</p><p>วันนี้ก็นั่ง MRT กลับเช่นเคย โดยก่อนกลับก็แวะเอสพานาดเพื่อออกกำลังกาย และถึงบ้านประมาณ 4 ทุ่ม</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c0ffc62a467" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Day 8] Big Data School #2 Date 07/06/2017]]></title>
            <link>https://medium.com/@boyburin_29108/day-8-big-data-school-2-date-07-06-2017-2f936bfd19a5?source=rss-9d64b588e3e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f936bfd19a5</guid>
            <dc:creator><![CDATA[Boy Burin]]></dc:creator>
            <pubDate>Mon, 12 Jun 2017 06:08:33 GMT</pubDate>
            <atom:updated>2017-06-12T06:08:33.311Z</atom:updated>
            <content:encoded><![CDATA[<p>วันนี้เป็นวันที่สามท่ีอาจารย์เอกอนันต์มาบรรยาย โดยวันนี้อาจารย์ในช่วงเช้าอาจารย์ได้ลองให้พวกเราทำการตรวจสอบและแก้ไข docker image ที่อาจารย์สร้างขึ้นมาเอง ซึ่งสนุกมากๆ</p><p>— — -พักกลางวัน — — —</p><p>วันนี้ได้ลองไปกินไก่ย่างโดยร้านอยู่ทางเดียวกับทางที่ใช้ไป bts โดยซื้อกลับมากินที่บริษัท ไก่อร่อยมากๆกินเพลินมากๆ เพราะปกติชอบกินไก่ย่างอยู่แล้ว เสียดายไม่ได้ถ่ายรูปเอาไว้</p><p>— — — หลังพักกลางวัน — — —</p><p>ช่วงบ่ายอาจารย์มาบรรยายต่อเกี่ยวกับ service ที่เรียกว่า Spark โดยเป็น processing framework เช่นเดียวกับ MapReduce แต่ทำงานได้ไวกว่าเพราะ Spark เป็น in memory process โดยได้เรียนรู้สิ่งต่างๆมากมายตั้งแต่ architecture จนถึงการนำไปใช้งานโดยใช้ Jupyter notebook ซึ่งเป็น tool ที่สะดวกมากเพราะเราสามารถใช้ประมวลผลแบบ interact ได้ทันทีรวมถึงเหมาะมากในการใช้ visualize เพราะว่า เราใช้ PySpark ซึ่งก็คือ Python + Spark เพราะ Python จึงมั่นใจได้ว่า มี libraries ที่เกี่ยวกับการ visualize มากมาย</p><p>โดย Spark มี key สำคัญดังนี้</p><p>Spark context (master node) อาจไม่ใช่ master node ของ HDFS → resource management</p><p>Worker node → มีตัว executer ข้อมูลที่ตัวเองเก็บ (data locality) โดย concept เหมือน HDFS เลย</p><ul><li>มี cache ทำให้ทำงานแบบ in memory process ได้ ระวังเรื่อง cache ไม่พอเราสามารถเขียนให้พอดี cache ได้</li><li>เมื่อ woker node เสร็จแล้วส่งไปที่ spark context โดยใช้ memory ของ driver ที่อยู่ใน spark context แต่ result ที่ออกมาน้อยเพราะส่วนใหญ่เป็น (map)reduce</li><li>Directed acrylic graph บรรจุรายการและลำดับในการประมวลผลแต่ยังไม่ประมวลผมจนกว่ามีการ run คำสั่งในกลุ่มของ action สังเกตว่าเมื่อเราทำการ map หรือ reducebykey ไม่มีการประมวลผลเกิดขึ้นแต่จะถูกนำไปเก็บใน direct acylic graph</li><li>มี 2 กลุ่ม action และ transformation</li></ul><p>Spark ไม่สามารถทำ visulization ได้ ต้องอาศัย API ของแต่ละภาษา เช้นใช้ library ของ python แต่มันจะกิน memory ของ spark context</p><p>sc → ใน pyspark หรือ spark shell คือ spark context</p><p>— — — กลับบ้าน — — — —</p><p>โดยวันนี้ไปเอสพานาดเช่นเคยเพื่อออกกำลังกาย และหลังออกกำลังกายได้ไปลองอาหารไต้หวันที่อยู่ที่เอสพานาดซึ่งก็คือร้าน ‘Ning Kee’ เป็นร้านหม้อไฟต้นตำหรับไต้หวัน โดยได้เลือกซุปหม่าล่า เพราะว่าชอบมากตั้งแต่ร้านหม้อไฟศาสตร์แถวมหาลัย โดยจะออกเผ็ดและร้อนมากๆ แต่อร่อยสุดๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*0At3J0IEBOIbLQmVYPXc3A.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f936bfd19a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Day 7] Big Data School #2 Date 06/06/2017]]></title>
            <link>https://medium.com/@boyburin_29108/day-7-big-data-school-2-date-06-06-2017-ae954b4905a3?source=rss-9d64b588e3e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae954b4905a3</guid>
            <dc:creator><![CDATA[Boy Burin]]></dc:creator>
            <pubDate>Mon, 12 Jun 2017 06:07:58 GMT</pubDate>
            <atom:updated>2017-06-12T06:07:58.355Z</atom:updated>
            <content:encoded><![CDATA[<p>วันนี้อาจารย์เอกอนันต์ได้เข้ามาบรรยายต่อจากเมื่อวาน โดยวันนี้อาจารย์ได้ทำการพูดถึงตัว ingestion data อีกตัวหนึ่งที่สำคัญนั่นก็คือ Kafka โดย kafka จะใช้หลักการของการ produce และ subscribe โดย producers คือคนที่ส่งข้อมูลให้ ส่วน subscribers จะทำหน้าที่ดึงข้อมูลที่สนใจมาเก็บไว้เพื่อใช้งานต่อไป เรามารู้จัก key สำคัญของ Kafka กันดีกว่า</p><ul><li><strong>แต่ละ client แบ่งแยกได้ด้วย topic บน Kafka</strong></li><li><strong>เราเรียก data ว่า message หรือ event</strong></li><li><strong>Offset ก็คือ index ของข้อมูล</strong></li><li><strong>Topic หนึ่งอาจมีได้หลาย partitions ในพื้นที่จัดเก็บข้อมูล</strong></li><li><strong>Partition สามารถ replicate ได้</strong></li></ul><p>โดยเราอาจมอง topic เป็นช่องทางที่ใช้ในการรับส่งข้อมูลที่เราสนใจ และจะมี service ที่เรียกว่า Zookeeper ซึ่งจะเป็นตัวชี้ตำแหน่ง partitions ไหน offsets ไหน</p><p>ข้อสังเกตเวลา producers ส่งข้อมูลต้องไปที่ port ของ Kafka (9092)โดยตรง ในทางตรงกันข้าม subscribers จะต้องไปที่ port ของ Zookeeper ถ้าต้องการรับข้อมูลผ่าน Kafka (2181)</p><p><strong>— — จากนั้นก้ไปพักกลางวัน — — —</strong></p><p>โดยวันนี้ได้ลองไปกิน ramen ที่อยู่ใกล้ๆกับบริษัท</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zu_Fo031UbW9de2NjMFEQQ.jpeg" /></figure><p>เมื่ออาหารมาถึงโต๊ะก็ได้ทำการเติมกระเทียมและจากนั้นก็กินทันที โดยรสชาติอร่อยมากๆ และร้านนี้ยังมีกระเทียมสดให้เราทำการบดและใส่เท่าไรก็ได้ตามที่เราต้องการ ว้าว !!! รสชาติคล้ายๆกับ ramen กระเทียมที่กินบ่อยมากๆที่ญี่ปุ่น</p><p><strong>— — — หลังจากพักกลางวันเสร็จ — — — -</strong></p><p>อาจารย์ได้ให้พวกเราลองทำ workshop โดยประยุกต์ใช้สิ่งที่เราได้เรียนรู้มา โดยเริ่มตั้งแต่การนำเข้าข้อมูล, การเก็บข้อมูล, และการทำ data analysis</p><p><strong>— — กลับบ้าน — — -</strong></p><p>โดยตอนเย็นก็กลับบ้าน โดยใช้ MRT และ คนเยอะมากเนื่อจากเปป็นเวลาเลิกงานพอดี โดยก่อนจะกลับบ้านก็แวะ เอสพานาดรัชดา เพื่อออกกำลังกาย จากนั้นก็ถึงบ้านประมาณ 3 ทุ่ม</p><p><strong>— — — — — — — — — — — — — Kafka — — — — — — — — — — — -— — — -</strong></p><p><strong>Kafka</strong></p><p>ทำการ start Kafka</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J9Z2DM1LrO-zQjvw." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kDKrqJa3uswieKJ-." /></figure><p>ทำการ produce และ consume</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bmWQYVASmuprcIl-." /></figure><p>ลอง telnet เพื่อ check port 9092 และ 2181</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8-ufvE3JPAtPjdJh." /></figure><p>ทำการ consume data จาก kafka ที่มาจาก “mytopic1003” topic จะสังเกตเห็น log ต่างๆที่มาจากไฟล์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yl0J0TFffEVHVgme." /></figure><p><strong>— — — — — — — — - — — — — Workshop 1 — — — — — — — — — — — — -</strong></p><p><strong>Workshop 1</strong></p><p>เริ่มแรกเราต้องทำการติดตั้งและ download Java และ flume บน server instance ของเรา หลังจากนั้น ก็ทำการ run flume ให้เชื่อมต่อกับ kafka ของเราโดยใช้ไฟล์ flume configuration โดยจากภาพ flume เราได้ทำการเชื่อมระหว่าง ไฟล์ log ของเราบน server instances กับ Kafka ที่อยู่ใน container ของเรา โดยไฟล์เกี่ยวกับการ login และ logout ของ users</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MD7aTPCqyDvIiU6o." /></figure><p>ต่อไปเราต้องเข้าไปใน cloudera container ทำการ download ‘kafka_2.11–0.9.0.1’ จากนั้นทำการ start โดยใช้ 2 คำสั่ง ‘bin/zookeeper-server-start.sh config/zookeeper.properties’ และตามด้วย ‘bin/kafka-server-start.sh config/server.properties’ และอย่าลืมตรวจสอบว่า port 2181 เป็นของใครโดยใช้คำสั่ง ‘netstat -nlp|grep 2181’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z6GP0DwFIxI45UdM." /></figure><p>ลอง telnet เพื่อ check port 9092 และ 2181</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KRLifqoYGAmGVIMp." /></figure><p>ทำการ consume data จาก kafka ที่มาจาก “mytopic1003” topic จะสังเกตเห็น log ต่างๆที่มาจากไฟล์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sIduiYqqL0uV_MSa." /></figure><p>ทำการ connect flume กับ HBase และ HDFS โดยดึงข้อมูลจาก kafka source โดยเอามาจาก ‘mytopic1003’ topic</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n2qXM-bP64MYgVRZ." /></figure><p>ทำการสร้าง ‘hauthlog1’ Hbase ขึ้นมา (ต้องสร้างก่อนที่จะ connect flume เข้ากับ HBase) และจะสังเกตว่าข้อมูลได้ถูกนำไปเก็บข้าง HBase ท่ีเราระบุเรียบร้อย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xQhY_TeomeZmIL-m." /></figure><p>ทำการสร้าง Hive table ขึ้นมาจาก HBase ที่เราได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-FJSWUvSrynlURtd." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4rC2WDswNXVKG1bE." /></figure><p>ลองทำการเลือก rows ที่มีคำว่า ‘boyburin’ อยู่</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sCAjzC8utsPTw8uR." /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae954b4905a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Day 6 ] Big Data School #2 Date 05/06/2017]]></title>
            <link>https://medium.com/@boyburin_29108/day-6-big-data-school-2-date-05-06-2017-3e14f3b6506a?source=rss-9d64b588e3e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e14f3b6506a</guid>
            <dc:creator><![CDATA[Boy Burin]]></dc:creator>
            <pubDate>Mon, 12 Jun 2017 06:07:20 GMT</pubDate>
            <atom:updated>2017-06-12T06:07:20.615Z</atom:updated>
            <content:encoded><![CDATA[<p>วันนี้ได้กลับมาฝึกงานต่อที่ชั้น 8 โดยวันนี้มี อาจารย์เอกอนันต์ มาบรรยายเกี่ยวกับ Hadoop ecosystem อาจารย์บรรยายสนุกมาก โดยมีการถามเพื่อให้เราได้คิดและทำความเข้าใจ โดยอาจารย์ได้พูดถึงหัวข้อดังต่อไปนี้</p><p><strong>— — HDFS vs HBase — —</strong></p><p>HDFS เวลาเราจะเข้าถึงไฟล์ต้องทำ Batch processing หรือ process ทั้งก้อนแต่ถ้าเราอยากได้ข้อมูลแค่บางตัวโดยใช้ key ละ ดังนั้น HBase ช่วยเราได้โดยการให้สิ่งที่เรียกว่า Random access</p><p><strong>— — ประเภทของ Data — —</strong></p><p><strong>Structured data</strong> → เป็น data ที่มีโครงสร้างที่แน่นอน เราจะพบเห็นในรูปของพวกตารางหรือ Relational database</p><p><strong>Semi structured data</strong> → เป็น data ที่มี delimiter คงที่เช่น (‘,’ , ‘:’)</p><p><strong>Unstructured data</strong> → เป็น data ที่หา delimiter คงที่ไม่ได้เลย เช่นพวกข้อมูลที่เป็น text จาก social</p><p><strong>— — Hadoop core functions — —</strong></p><p><strong>Process</strong> → MapReduce (ใน Hadoop 1.o)</p><p><strong>Storage</strong> → Hadoop distributed file system (HDFS)</p><p><strong>— — Hadoop 1.o vs Hadoop 2.o — —</strong></p><p><strong>Hadoop 1.0</strong> → MapReduce (cluster resource management and data processing)</p><p><strong>Hadoop 2.0 </strong>→ YARN (cluster resource management), MapReduce (data processing), others (data processing)</p><p>— — สิ้นสุดเกี่ยวกับเนื้อหาช่วงเช้า — —</p><p>โดยหลังจากนั้นอาจารย์ให้ทำ powerpoint เพื่อใช้ในการ presentation ในช่วงบ่ายโดยเกี่ยวกับ hadoop services ได้แก่ Pig, Hive, HBase, Impala และ Ingestion services (Sqoop และ Flume)</p><p>โดยหลังจาก presentation ก็ได้ทำการฝึกใช้งาน services ต่างๆ ไฟล์ข้างล่างจะเป็นสิ่งที่ได้ทำไป</p><p>— — เป็นสิ่งที่ได้ลองเรียนรู้ในวันนี้ — —</p><p><strong>— — — — — — — — — — -Hadoop ecosystem — — — — — — — — — — — —</strong></p><p><strong>Pig</strong></p><p>ทำการโหลดไฟล์ ‘pg2600.txt’ มาไว้ใน HDFS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bgpZ2KCXJv7mi6Uk." /></figure><p>เข้า Pig จาก command line แล้วทำการพิมพ์คำสั่ง โดยในกรณีนี้จะเป็น interactive shell โดยเราใช้ Pig ในการทำ word count</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7RFj3DerJW4zra2f." /></figure><p>เราจะได้ไฟล์ output ออกมา ซึ่งจะเป็นไฟล์ที่บอก word count</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qdLSj52H289ybdVQ." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uowEb-LJ_07yGmkk." /></figure><p>เราทำการโหลดไฟล์ ‘2008.csv’ มาไว้ใน HDFS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YF0Gc7D4x04ta9s9." /></figure><p>ทำการเขียน Script ใน Pig Editor ที่อยู่ใน Hue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_x7oPHrjNH_7Qhtt." /></figure><p>ต่อไปทำการ run script โดยเราสามารถดู Job running ได้ผ่านทาง Job browser และเมื่อเสร็จจะได้ไฟล์ออกมาตามที่เราระบุใน script</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vQ6m4dS_iAyj21Vt." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Iu-vBM3O-PwU24zW." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ADOgr8YQIJBVo2gP." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DSqVD-YMzTmSoEUs." /></figure><p><strong>Hive</strong></p><p>ใช้งาน Hive ผ่าน command line โดยทำการสร้าง ‘test_tbl’ table พร้อมกับทำการ check table โดยการใช้คำสั่ง ‘show tables’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kj7DmLFn3wBA_Fx1." /></figure><p>ทำการ check ไฟล์ table ที่เราสร้างขึ้น ใน Hive warehouse</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n4KUIFwRAWjGZckX." /></figure><p>ทำการแก้ไข table โดยในกรณีนี้ทำการ add column ใหม่ ขึ้นมาชื่อ ‘remarks’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/0*m5Yszi2dGknDGIUd." /></figure><p>ทำการตรวจาสอบ data ในไฟล์ที่เราจะนำไปใช้งาน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/0*hippHfewBbLdJeSk." /></figure><p>โหลดไฟล์ขึ้นไปบน HDFS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tW8_KM2K93MwLCmc." /></figure><p>ทำการสร้าง external table ของ hive เอา data ที่เราพึ่งโหดลเข้ามาใส่ใน table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DXzAT1l-hmDZ1goe." /></figure><p>ทำการ upload ‘201402_trip_data.csv’ มาไว้ที่ HDFS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ROnO49XSYMaOQZEc." /></figure><p>ต่อไปจะลองสร้าง Hive โดยใช้ Hue เริ่มแรกเราจะเข้าไปยัง metastoe table ทำการสร้าง table พร้อมกับเลือก data ที่เราต้องการนำไปใส่ใน table กำหนด ชื่อและประเภทของแต่ละ columns รวมถึงบอก delimeter ที่ใช้ในการแบ่งข้อมูลออกเป็น columns</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l7KnupZped0hgVYx." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jm02EPF5CB8NPAgY." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ys49sLFvZKT12IB6." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xR524IVqWJA-P-EW." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4JNYYCWvO9_WjU1a." /></figure><p>ทำการ select ข้อมูลที่เราต้องการจาก hive table ที่เราสร้าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EdehQlPAt7bYjmr8." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A0nUdJl5eUcCNzca." /></figure><p>ลองใช้สร้าง hive table จากข้อมูลของ NASA</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MftEPy8_Y52bBhQF." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X40ZZDLYtxHdotS0." /></figure><p><strong>Impala</strong></p><p>ใช้คำสั่งเพื่อเข้าไปใน impala shell จากนั้นทำการสร้าง ‘t1’ table ขึ้นมา สังเกตุว่า table จะถูกนำไปเก็บที่เดียวกับ hive table คือ hive warehouse</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ph9bRiLI8vLJvDt9." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/0*Fi3BwsVB8JW75svG." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jjXoCCsQqFIhKHex." /></figure><p>ลองทำการ insert ข้อมูลเข้าไป 1 row</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1e7XnICxpVr06YUg." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I0Ep-py1osFeiVp7." /></figure><p>ต่อไปทำการ upload ไฟล์ ‘books’ เอามาไว้ใน HDFS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-DB7W49TwGNx469h." /></figure><p>จากนั้นทำการสร้าง ‘books’ table และนำ data จาก ‘books’ ไปใส่ใน table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/0*xTcuc49wENDdY46B." /></figure><p>ลองทำการนับจำนวน rows ทั้งหมด</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/0*JwcXhdcvDnfbOcwb." /></figure><p>สังเกตว่าเราลอง query ข้อมูลจาก weblogtest โดยใช้ impala แต่เราไม่สามารถ query ได้เพราะว่า SerDe library ไม่มีใน impala ถึงแม้ impala จะไปใช้ metastore ของ Hive แต่ก็ไม่สามารถ query ได้ ‘SerDe library ‘org.apache.hadoop.hive.contrib.serde2.RegexSerDe’ is not supported. ‘</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DpB7KT3n2SuY0Yev." /></figure><p><strong>Sqoop</strong></p><p>ทำการลง mySQL ใน docker จากนั้นเข้าไปใน mySQL container และทำการเข้าไปใน mySQL shell จากนั้นลองทำการสร้าง table และ insert ข้อมูลเข้าไป 7 ตัว และทำการ select มาดุ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fbRGx0PRQGJBWD19." /></figure><p>ทำการ check IPAddress เพื่อที่จะ connection mySQL database นี้จาก hadoop server ของเรา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LWi1zegQNPd2fKKD." /></figure><p>ลองทำการโหลด table จาก mySQL เข้ามาที่ HDFS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5tl-JwheR9ga6r90." /></figure><p>ในกรณีโหลดมาใส่ใน Hive table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1Y340z20Y-PNcsQS." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rmcAMqClSjBmwG0s." /></figure><p>กรณีนี้โหลดเข้าไปใน Hbase</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2pGOLVLyEd-mXo1j." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G0BfNqYdh3O3FKyA." /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JQ8M9QU4QbL5WW2K." /></figure><p>ทำการ export ข้อมูลเพิ่มเข้าไปใน mySQL สองตัวจาก HDFS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uTtPEfH2ewdIUMKR." /></figure><p><strong>Flume</strong></p><p>ทำการ start agent โดยการ run ‘flume-ng agent — name a1 — conf conf — conf-file conf/example.conf’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-df11sXmZfrE0iAu." /></figure><p>ลองดึงข้อมูลมาจาก twitter โดยใช้ flume โดยเราทำการโหลด agent configuration สำหรับ twitter แล้วทำการ run agent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JXKsynSIauPPrH6K." /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e14f3b6506a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 5 Big Data School #2 Date 02/06/2017]]></title>
            <link>https://medium.com/@boyburin_29108/big-data-school-2-date-02-06-2017-86e2dc26b1ba?source=rss-9d64b588e3e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/86e2dc26b1ba</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[boyburinbigdata]]></category>
            <dc:creator><![CDATA[Boy Burin]]></dc:creator>
            <pubDate>Sat, 03 Jun 2017 09:01:40 GMT</pubDate>
            <atom:updated>2017-06-03T09:11:55.227Z</atom:updated>
            <content:encoded><![CDATA[<p>วันนี้เป็นวันที่สองที่ได้ขึ้นมาที่ชั้น 12 โดยวันนี้เราจะได้ลองใช้ HDFS ซึ่งเราจะทดลองเก็บไฟล์ไว้บน HDFS กัน จากนั้นเราจะมาลอง HBase ซึ่งเป็น NoSQL ที่สร้างอยู่บนพื้นฐานของ HDFS และในเมื่อเรารู้จักการเก็บข้อมูลบน Hadoop แล้วเราจะมาทำความรู้จักกับ core สำคัญอีกอย่างหนึ่งซึ่งก็คือ MapReduce ที่ใช้สำหรับประมวลผลนั่นเอง</p><p>HDFS</p><p>โดยเราได้ลองทำการ upload file ขึ้นไปบน HDFS โดยใช้ hue และได้ลองใช้คำสั่ง “hadoop fs -put file” ในการ upload file เช่นเดียวกับการใช้ hue นอกจากนั้นยังมีคำสั่ง “hadoop fs -ls path” ซึ่งใช้สำหรับดู file และ directory ทั้งหมดใน path นั้น</p><p>HBase</p><p>service นี้ใช้สำหรับเก็บข้อมูลซึ่งอยู่บนพื้นฐานของ HDFS แต่เพราะว่า HDFS ไม่สามารถทำ random access ได้ เราจึงต้องพึ่ง HBase ที่สามารถทำได้ โดย HBase เป็น NoSQL database และเป็น wide column นั่นคือสามารถขยายด้านข้างเท่าไรก็ได้ ไม่ตายตัวเหมือน RDBMS โดยเราจะต้องใช้ command ของ HBase หรือใช้ Java ก็ได้ในการทำ operation กับ HBase เช่นการสร้าง table หรือ การทำ CRUD(Create, Read, Update, Delete)</p><p>MapReduce</p><p>เราได้ทำความรู้จัก HDFS แล้วซึ่งเป็น core สำหรับการเก็บสิ่งต่าง เมื่อเรามี Storage (ข้อมูล) เราก็ต้องมีตัวที่เอาไว้ process ซึ่งนั่นก็คือ MapReduce นั่นเอง โดยเราจะต้องเขียนโปรแกรมภาษา Java ขึ้นมาและ submit job ขึ้นไปยัง hadoop โดยจะต้องระบุไฟล์ข้อมูลที่เราต้องการ process ด้วย โดยจากภาพข้างล่างจะเป็นการโชว์สถานะของ Job ที่เราส่งไป process</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-i7whm25sVmVf212IslELw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-E6pzDmnAXucu9q_7irVow.png" /></figure><p>ทำ Cloudera cluster โดยใช้ server 4 ตัว</p><p>เริ่มจากการสร้าง compute engine instances ทั้งหมด 4 ตัว โดยจะให้ตัวหนึ่งเป็น master node และที่เหลือเป็น slaves</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0PGIUc8eVpR6CGOheFoj-g.png" /></figure><p>ต่อจากนั้นทำการเปลี่ยน password ให้ทุก instances เป็น password เดียวกันและทำการแก้ไฟล์ /etc/ssh/sshd_config เพื่อเปลี่ยนแปลง permission การ login ระหว่าง instances</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QaYcaDhVKMVy6hShWfgCcg.png" /></figure><p>ทำการ generate key ให้กับทุก instances เพื่อใช้ในการ connect ไปยัง instances ที่ไม่ใช่ของตัวเอง โดยเราต้องทำการ copy public key ไปให้ instances ที่เหลือจากตัวอย่างต้องทำการ copy ทั้งหมด 4x3 = 12 ครั้ง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6zyaXQdTi2rv0GSdIrVNYA.png" /></figure><p>ต่อไปเราทำการ set ให้ค่า swappiness เป็นศูนย์ เพราะว่า default เป็น 60 หมายความว่าเรามีโอกาสใช้ Harddisk หรือ SSD ของเราแทน ram ในกรณีที่ ram ไม่พอ แต่ในกรณีนี้เราต้องการให้ใช้แค่ ram</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H_YUIhFuBoUXHRM4uDMThQ.png" /></figure><p>ต่อไปเราทำการโหลด cloudera manager มาลงที่เครื่อง master node และทำตามขั้นตอนวิธีไปเรื่อยๆจนสิ้นสุด จะมีแจ้งว่าให้เราเข้าไปยัง port 7180 โดยใช้ external url ของ master node</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6i3Muuvhy8C4I3EQWWsmcA.png" /></figure><p>เพื่อเข้ามาจะเจอหน้าต่าง login โดย username และ password จะเป็น “admin”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pEwFs6FBkuNuuAWTrPFCug.png" /></figure><p>เมื่อเข้ามาจะมีให้ยอมรับ license และเริ่มต้นทำ cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gs53xt3F_r3I6O9C7JrsIg.png" /></figure><p>ทำการ install cluster โดยมีการลง package ต่างๆที่จำเป็น</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foYgXkdOBfZ31sBW46UB9Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZpbxSVAkRU0wn4uwDROTw.png" /></figure><p>ทำการติดตั้ง services ต่างๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WneSJZDHySUAj6qceCPYWQ.png" /></figure><p>เมื่อเสร็จเรียบร้อยจะเข้ามายังหน้า home ซึ่งจะมีบอก status ของ services ต่างๆโดยเราสามารถเพิ่มหรือลบ services ได้และยัง ทำการ monitor services และ ทรัพยากรของ cluster เราได้อีกด้วย และนี่คือการติดตั้ง cloudera cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xh5ZZxGJPm2TXYQzm3AZkw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86e2dc26b1ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 4 Big Data School #2 Date 01/06/2017]]></title>
            <link>https://medium.com/@boyburin_29108/big-data-school-2-date-01-06-2017-7fb1c497b5b6?source=rss-9d64b588e3e6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fb1c497b5b6</guid>
            <category><![CDATA[boyburinbigdata]]></category>
            <dc:creator><![CDATA[Boy Burin]]></dc:creator>
            <pubDate>Sat, 03 Jun 2017 09:00:37 GMT</pubDate>
            <atom:updated>2017-06-03T09:10:56.024Z</atom:updated>
            <content:encoded><![CDATA[<p>วันนี้เป็นการขึ้นมาใช้ห้องที่ชั้น 12 เป็นครั้งแรก โดยงานวันนี้พวกเราได้ทดลองเรียนรู้เกี่ยวกับการติดตั้ง commercial hadoop (cloudera และ hortonwork) ซึ่งเป็น docker version รวมถึงได้ศึกษา command พื้นฐานของ docker บน linux command line</p><p>ซึ่งเราสามารถติดตั้ง docker บนเครื่อง local หรือ server ก็ได้ โดยวันนี้ได้ทำการติดตั้ง docker บน google compute engine instance ซึ่งเป็นหนึ่งในบริการของ Google Cloud Platform นั่นเอง</p><p>การติดตั้ง Hortonworks</p><p>ก่อนอื่นเราต้องติดตั้ง docker-engine จากนั้น downloads ตัว hortonworks docker image และทำการ load ไปที่ docker image ของเรา หลังจากนั้นก็ทำการสร้าง script ที่ใช้สำหรับสร้าง container ของ hortonworks และ connect ผ่าน ssh โดยใช้ command “ssh -p 2222 root@localhost” โดยถ้าเป็นการเข้ามาครั้งแรกเราจะต้องทำการใส่ password “hadoop” หลังจากนั้นระบบจะให้เราเปลี่ยน password และครั้งหน้าเราจะใช้ password ใหม่ในการ connect กับ hortonworks</p><p>การติดตั้ง Cloudera</p><p>เราจะต้องทำการใช้ตัว docker.io เนื่องจากต้องใช้บาง driver หรือ library ซึ่งไม่มีในตัว docker-engine หลังจากนั้นใช้คำสั่ง “pull” เพื่อทำการดึง image file ของ cloudera ลงมา และจากนั้นก็ทำการติดตั้งโดยใช้ command ของ docker ในการ run หลังจากเสร็จสิ้นเราจะได้ container ของ cloudera ออกมา</p><p>โดยทั้งสองแบบจะมีหน้าต่างการจัดการสิ่งต่างโดย hortonworks เรียกว่า ambari ส่วน cloudera เรียกว่า hue โดยทั้งคู่จะเข้าผ่าน port 8888 โดยใช้ external url ของตัว compute engine instance</p><p>เราสามารถหยุดการทำงานของ container ได้โดยใช้ “docker stop containerid” หรือเริ่มการทำงานด้วย “docker start containerid” และถ้าเราต้องการกลับเข้าไปใน container เราจะใช้ “docker attach containerid” แต่ในกรณี hortonworks เราจะเอาคำสั่งบางส่วนจากไฟล์ script ที่เราใช้มาทำการเปิดใช้งาน services ต่างๆและทำการ connect โดย ssh เช่นเดิม</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fb1c497b5b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>