What are the Hadoop MapReduce concepts?

What do you mean by Map-Reduce programming?

MapReduce is a programming model designed for processing large volumes of data in parallel by dividing the work into a set of independent tasks.

The MapReduce programming model is inspired by functional languages and targets data-intensive computations. The input data format is application-specific, and is specified by the user. The output is a set of <key,nilai> pairs. The user expresses an algorithm using two functions, Map and Reduce. The Map function is applied on the input data and produces a list of intermediate <key,nilai> pairs. The Reduce function is applied to all intermediate pairs with the same key. It typically performs some kind of merging operation and produces zero or more output pairs. Finally, the output pairs are sorted by their key value. In the simplest form of MapReduce programs, the programmer provides just the Map function. All other functionality, including the grouping of the intermediate pairs which have the same key and the final sorting, disediakan oleh runtime.

Fasa model MapReduce

Unit peringkat atas kerja dalam MapReduce adalah pekerjaan yang. kerja biasanya mempunyai peta dan mengurangkan fasa, walaupun fasa mengurangkan boleh ditinggalkan. For example, mempertimbangkan pekerjaan MapReduce yang dikira berapa kali setiap perkataan digunakan merentasi satu set dokumen. Fasa peta mengira perkataan dalam setiap dokumen, maka mengurangkan fasa mengumpulkan data setiap dokumen ke dalam tuduhan perkataan yang merangkumi keseluruhan koleksi.

Semasa fasa peta, data input ini dibahagikan kepada perpecahan input untuk analisis oleh tugas-tugas peta berjalan selari seluruh kelompok Hadoop yang. Secara lalai, rangka kerja MapReduce mendapat data input dari Hadoop Diedarkan Sistem Fail (HDFS).

Fasa mengurangkan menggunakan hasil daripada tugas-tugas peta sebagai input kepada satu set mengurangkan tugas-tugas selari. Mengurangkan tugas-tugas menyatukan data ke keputusan akhir. Secara lalai, kedai-kedai rangka kerja MapReduce keputusan dalam HDFS.

Walaupun fasa mengurangkan bergantung kepada output daripada fasa peta, peta dan mengurangkan pemprosesan tidak semestinya berurutan. Itu dia, mengurangkan tugas-tugas boleh bermula sebaik sahaja mana-mana peta tugas selesai. Ia tidak perlu untuk semua tugasan peta untuk melengkapkan sebelum sebarang mengurangkan tugas boleh mula.

MapReduce beroperasi pada pasangan-nilai utama. Dari segi konsep, pekerjaan MapReduce mengambil satu set pasangan input-nilai utama dan menghasilkan satu set pasangan kunci-nilai pengeluaran dengan meluluskan data melalui peta dan mengurangkan fungsi. Tugas peta menghasilkan set pertengahan pasangan nilai utama yang mengurangkan tugas-tugas menggunakan sebagai input.

Kunci dalam pasangan peta output tidak perlu menjadi unik. Antara pemprosesan peta dan pemprosesan mengurangkan, a shuffle step sorts all map output values with the same key into a single reduce input (key, value-list) pair, where the ‘value’ is a list of all values sharing the same key. Thus, the input to a reduce task is actually a set of (key, value-list) pairs.

Though each set of key-value pairs is homogeneous, the key-value pairs in each step need not have the same type. For example, the key-value pairs in the input set (KV1) can be (string, string) pairs, with the map phase producing (string, integer) pairs as intermediate results (KV2), and the reduce phase producing (integer, string) pairs for the final results (KV3).

Kunci dalam pasangan peta output tidak perlu menjadi unik. Antara pemprosesan peta dan pemprosesan mengurangkan, a shuffle step sorts all map output values with the same key into a single reduce input (key, value-list) pair, where the ‘value’ is a list of all values sharing the same key. Thus, the input to a reduce task is actually a set of (key, value-list) pairs.

Example demonstrating MapReduce concepts

The example demonstrates basic MapReduce concept by calculating the number of occurrence of each word in a set of text files.

The MapReduce input data is divided into input splits, and the splits are further divided into input key-value pairs. Dalam contoh ini, set data input adalah dua dokumen, Document1 dan document2. The InputFormat subkelas membahagikan set data ke dalam satu perpecahan setiap dokumen, untuk sejumlah 2 berpecah:

Note: Rangka kerja MapReduce membahagikan data input yang ditetapkan menjadi ketulan dipanggil perpecahan menggunakan subkelas org.apache.hadoop.mapreduce.InputFormat yang disediakan dalam konfigurasi kerja. Splits yang dicipta oleh Pelanggan menerusi tempatan dan dimasukkan ke dalam maklumat kerja yang disediakan kepada Tracker menerusi. The JobTracker mewujudkan tugas peta bagi setiap perpecahan. Setiap tugas peta menggunakan RecordReader yang disediakan oleh subkelas InputFormat untuk mengubah perpecahan menjadi pasangan input-nilai utama.

A (nombor talian, text) pasangan-nilai utama dijana bagi setiap baris dalam dokumen input. Fungsi peta membuang nombor talian dan menghasilkan satu talian (perkataan, mengira) pair for each word in the input line. The reduce phase produces (perkataan, mengira) pairs representing aggregated word counts across all the input documents. Given the input data shown the map-reduce progression for the example job is:

The output from the map phase contains multiple key-value pairs with the same key: The ‘oats’ and ‘eat’ keys appear twice. Recall that the MapReduce framework consolidates all values with the same key before entering the reduce phase, so the input to reduce is actually (key, values) pairs. Therefore, the full progression from map output, through reduce, to final results is shown above.

MapReduce Job Life Cycle

Following is the life cycle of a typical MapReduce job and the roles of the primary actors.The full life cycle are more complex so here we will concentrate on the primary components.

The Hadoop configuration can be done in different ways but the basic configuration consists of the following.

  • Single master node running Job Tracker
  • Multiple worker nodes running Task Tracker

Following are the life cycle components of MapReduce job.

  • Local Job client: The local job Client prepares the job for submission and hands it off to the Job Tracker.
  • Job Tracker: The Job Tracker schedules the job and distributes the map work among the Task Trackers for parallel processing.
  • Task Tracker: Each Task Tracker spawns a Map Task. The Job Tracker receives progress information from the Task Trackers.

Once map results are available, the Job Tracker distributes the reduce work among the Task Trackers for parallel processing.

Each Task Tracker spawns a Reduce Task to perform the work. The Job Tracker receives progress information from the Task Trackers.

Semua tugas peta tidak perlu selesai sebelum mengurangkan tugas-tugas mula dijalankan. Mengurangkan tugas-tugas boleh bermula sebaik sahaja tugas peta mula melengkapkan. Thus, peta dan mengurangkan langkah-langkah yang sering bertindih.

Fungsi komponen yang berbeza dalam pekerjaan MapReduce

Pelanggan menerusi: pelanggan menerusi melaksanakan tugas-tugas berikut

  • Mengesahkan konfigurasi kerja
  • Menjana berpecah input. Ini pada dasarnya membelah kerja input menjadi ketulan
  • Salinan sumber pekerjaan (konfigurasi, kerja fail JAR, perpecahan input) ke lokasi yang dikongsi, seperti direktori HDFS, di mana ia boleh diakses untuk Tracker Kerja dan Tugas Trackers
  • Menyerahkan tugas ke Tracker menerusi

Job Tracker: Job Tracker melaksanakan tugas-tugas berikut

  • Ini ditambah dengan faktor perpecahan input dari lokasi dikongsi bersama Ayub Pelanggan diletakkan maklumat yang
  • Mencipta satu tugas peta bagi setiap perpecahan
  • Tugaskan setiap peta tugas kepada Task Tracker (nod pekerja)

After the map task is complete, Job Tracker does the following tasks

  • Creates reduce tasks up to the maximum enabled by the job configuration.
  • Assigns each map result partition to a reduce task.
  • Assigns each reduce task to a Task Tracker.

Task Tracker: A Task Tracker manages the tasks of one worker node and reports status to the Job Tracker.

Task Tracker does the following tasks when map or reduce task is assigned to it

  • Fetches job resources locally
  • Spawns a child JVM on the worker node to execute the map or reduce task
  • Reports status to the Job Tracker

Debugging Map Reduce

Hadoop keeps logs of important events during program execution. Secara lalai, these are stored in the logs/ subdirectory of the hadoop-version/ directory where you run Hadoop from. Log files are named hadoop-username-service-hostname.log. The most recent data is in the .log file; older logs have their date appended to them. The username in the log filename refers to the username under which Hadoop was started — this is not necessarily the same username you are using to run programs. The service name refers to which of the several Hadoop programs are writing the log; these can be jobtracker, namenode, datanode, secondarynamenode, or tasktracker. All of these are important for debugging a whole Hadoop installation. But for individual programs, the tasktracker logs will be the most relevant. Any exceptions thrown by your program will be recorded in the tasktracker logs.

The log directory will also have a subdirectory called userlogs. Here there is another subdirectory for every task run. Setiap tugas merekodkan stdout dan stderr kepada dua fail dalam direktori ini. Perhatikan bahawa pada pelbagai nod Hadoop kelompok, log ini tidak berpusat agregat — anda perlu menyemak log / userlogs / direktori setiap TaskNode untuk keluaran mereka.

Debugging dalam suasana yang diedarkan adalah rumit dan memerlukan login ke beberapa mesin untuk mengakses data log. Kalau boleh, Program hendaklah unit diuji dengan menjalankan Hadoop dalam negara. Konfigurasi lalai yang digunakan oleh Hadoop berjalan dalam “tunggal contoh” mod, di mana keseluruhan program MapReduce ini dijalankan pada misalan yang sama Jawa seperti yang dipanggil JobClient.runJob(). Menggunakan penyahpepijat seperti Eclipse, anda boleh menetapkan titik putus di dalam peta() atau mengurangkan() kaedah untuk mencari pepijat anda.

Adalah mengurangkan kerja wajib?

Sesetengah kerja boleh melengkapkan semua kerja mereka semasa fasa peta. SO Kerja boleh memetakan hanya kerja. Untuk menghentikan pekerjaan selepas peta selesai, menetapkan bilangan mengurangkan tugas-tugas kepada sifar.

Kesimpulan

Modul ini menyifatkan platform pelaksanaan MapReduce di tengah-tengah sistem Hadoop yang. Dengan menggunakan MapReduce, tahap yang tinggi keselarian boleh dicapai oleh aplikasi. Rangka kerja MapReduce menyediakan tahap yang tinggi toleransi kesalahan bagi aplikasi yang berjalan di atasnya dengan mengehadkan komunikasi yang boleh berlaku antara nod.

============================================= ============================================== Buy best TechAlpine Books on Amazon
============================================== ---------------------------------------------------------------- electrician ct chestnutelectric
error

Enjoy this blog? Please spread the word :)

Follow by Email
LinkedIn
LinkedIn
Share