SlideShare a Scribd company logo
1 of 18
Download to read offline
Jumping Bean 
Map Reduce With Bash 
(the power of the Unix philosophy)
Jumping Bean 
About Me 
● Solutions integrator at Jumping Bean 
– Developer & Trainer 
– Technologies 
● Java 
● PHP 
● HTML5/Javascript 
● Linux 
– What I am planning to do: 
● The Internet of things
Jumping Bean 
Map/Reduce with Bash 
● Purpose of this presentation is: 
– to demonstrate the power and flexibility of the Unix 
philosophy, 
– what awesome solutions can be created by using simple 
bash script and userland tools, 
– cool utilities and tools 
● The purpose is not: 
– to suggest that Map/Reduce is best done with bash 
– best given constraint – see business problem
Unix Philosophy 
“is a set of cultural norms and philosophical 
approaches to developing small yet capable 
Jumping Bean 
software” - Wikipedia
Jumping Bean 
Unix Philosophy 
“Early Unix developers were important in bringing 
the concepts of modularity and reusability into 
software engineering practice, spawning a 
'software tools' movement” - Wikipedia
Jumping Bean 
Business Problem 
● Nuclear Engineering department needs to run monte-carlo methods 
on data to calculate something to do with core temperature of nuclear 
reactors :), 
● Post-grad students need to run analysis as part of their course work, 
● Analysis can take days or weeks to run, 
● University has invested in 900 node cluster, 
● Cluster used for research when not used by students 
● Tool used for analysis is 
– written in Fortran. 
– single threaded, 
● No money for fancy-pants solution
Jumping Bean 
Business Problem 
● As-Is system 
– Professor uses laptop and desktop, 
– Manually starts application with simple script, 
– Start script x number of times where x=number of 
cores, 
– Waits for days, 
– Manually checks progress, 
– Not scalable to 900 nodes!
Jumping Bean 
Business Problem 
● Unknowns 
– How 900 node cluster set up i.e using any cluster software or virtualisation? 
● Open Stack? 
● Open Nebula? 
● KVM? 
– Tools available to IT department – I.e how they do deploys, monitoring, user 
management etc 
● Requirements 
– independence from IT department or experts for help, 
– Student & lecturer IT skills is limited to Fortran & some bash scripting skills, 
– Due to security concerns prevent IT staff from gaining access to research, 
● Keep it simple – Proof of concept
Jumping Bean 
What is Map/Reduce? 
● Programming model for 
– Processing and generating large datasets, 
– Using a parallel distribution algorithm, 
– On a cluster or set of distributed nodes 
● Popularised by Google and the advent of cloud computing 
● Apache Hadoop – full blown map/reduce framework. Used 
to analyse your social media data, “understand the 
customer” and by numerous agencies with 3 letter 
acronyms. 
– “Really we only trying to help you know yourself better”
Jumping Bean 
Map/Reduce Steps 
● Map – Master node takes large dataset and 
distributes it to compute nodes to perform 
analysis on. The compute nodes return a result, 
● Reduce – Gather the results of the compute 
nodes and aggregate results into final answer
Jumping Bean 
What we need 
● Controller node functions 
– to distribute data to nodes, 
– execute calculation functions 
– collect results 
● Management node functions 
– distribute application and scripts to compute nodes, 
● Compute node functions 
– Scripts to run the single threaded application in parallel on multi core processors 
● Security Requirements 
– Prevent system administrators from gaining access to core application , script or 
data
Jumping Bean 
Controller Functions 
● How to distribute files to a node (map), execute calculations & gather 
results (reduce)? 
– Use split to split input files, 
– Use ssh to distribute files, execute processes, 
● How to do this to multiple (900) nodes? 
– Use parallel ssh (pssh), paralle scp, 
● Issues: 
– Copying public key to 900 machines? 
– Give each student their own account? 
● Solution 
– Set up ldap authentication (password based) or 
– Include controller nodes root public key in compute node image, distribute 2ndary keys via scripts 
using pssh 
– Fancy pants – chef, ansible
Management Node Functions 
● Use parallel ssh to distribute scripts from 
management node to compute nodes, 
● Using Ansible or Chef could be a next 
evolutionary step to automate system 
maintenance 
Jumping Bean
Jumping Bean 
Compute Node Functions 
● Basically bash scirpt - How to parallelise single threaded 
application to use multiple cores on modern CPUs? 
● xargs 
– pass through list of input files, 
– -n set each iteration to run on one input file 
– -P set number of processes to start in parallel 
– Script waits for completion of processing & check output 
● GNU parallels 
– Can run commands in parallel using 1 or more hosts 
– More options for target input placement {}, string replacement 
– Can pass output as input to another process
Jumping Bean 
Compute/Controller Node 
● At end of compute node process either 
compute node pings controller node, 
● Controller node waits for pssh to return to carry 
out next step. I.e – reduce process or start next 
script with output from 1st being input to 2nd step, 
● Check for errors and reschedule failed 
computes,
Jumping Bean 
Security 
● Each student should have separate account 
– Linux mutli-user system. User home directory for storing files and results 
● Each user should be limited in resource usage 
– Simple 
● ulimit 
● psacct 
– Advanced 
● Cgroups 
● Namespaces 
● Students can execute but not read bash script file, special permissions 
– Use sudo or 
– Linux capabilities 
● setcap – eg setcap "cap_kill=+ep" script.sh
Jumping Bean 
Security 
● Limit the root user 
– Linux capabilities 
● setcap, capsh,pscap 
● Disable root account – grant CAP_SYS_ADMIN as 
needed, 
● /etc/security/capabilities.conf
Jumping Bean 
Resources 
● Parallel SSH, 
● Xargs, 
● GNU parallel, 
● cgroups, 
● namespaces, 
● Linux capabilities 
● Twitter - @mxc4 
● Gplus – Mark Clarke 
● Jumping Bean 
● Cyber Connect 
● Jozi Linux User Grou 
p 
● Jozi Java User Group 
● Maker Labs

More Related Content

More from Jumping Bean

Linux Containers & Docker
Linux Containers & DockerLinux Containers & Docker
Linux Containers & DockerJumping Bean
 
Introduction to Web Sockets
Introduction to Web SocketsIntroduction to Web Sockets
Introduction to Web SocketsJumping Bean
 
Secrets of a linux ninja Software Freedom Day 2013 Johannesburg, South Africa
Secrets of a linux ninja  Software Freedom Day 2013 Johannesburg, South AfricaSecrets of a linux ninja  Software Freedom Day 2013 Johannesburg, South Africa
Secrets of a linux ninja Software Freedom Day 2013 Johannesburg, South AfricaJumping Bean
 
M-Learning application development with open source
M-Learning application development with open sourceM-Learning application development with open source
M-Learning application development with open sourceJumping Bean
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSJumping Bean
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android DevelopmentJumping Bean
 
Glassfish An Introduction
Glassfish An IntroductionGlassfish An Introduction
Glassfish An IntroductionJumping Bean
 
IPv6 - Jozi Linux User Group Presentation
IPv6  - Jozi Linux User Group PresentationIPv6  - Jozi Linux User Group Presentation
IPv6 - Jozi Linux User Group PresentationJumping Bean
 
SELinux Johannesburg Linux User Group (JoziJUg)
SELinux Johannesburg Linux User Group (JoziJUg)SELinux Johannesburg Linux User Group (JoziJUg)
SELinux Johannesburg Linux User Group (JoziJUg)Jumping Bean
 

More from Jumping Bean (10)

Linux Containers & Docker
Linux Containers & DockerLinux Containers & Docker
Linux Containers & Docker
 
Introduction to Web Sockets
Introduction to Web SocketsIntroduction to Web Sockets
Introduction to Web Sockets
 
Secrets of a linux ninja Software Freedom Day 2013 Johannesburg, South Africa
Secrets of a linux ninja  Software Freedom Day 2013 Johannesburg, South AfricaSecrets of a linux ninja  Software Freedom Day 2013 Johannesburg, South Africa
Secrets of a linux ninja Software Freedom Day 2013 Johannesburg, South Africa
 
M-Learning application development with open source
M-Learning application development with open sourceM-Learning application development with open source
M-Learning application development with open source
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 
Glassfish An Introduction
Glassfish An IntroductionGlassfish An Introduction
Glassfish An Introduction
 
Java logging
Java loggingJava logging
Java logging
 
IPv6 - Jozi Linux User Group Presentation
IPv6  - Jozi Linux User Group PresentationIPv6  - Jozi Linux User Group Presentation
IPv6 - Jozi Linux User Group Presentation
 
SELinux Johannesburg Linux User Group (JoziJUg)
SELinux Johannesburg Linux User Group (JoziJUg)SELinux Johannesburg Linux User Group (JoziJUg)
SELinux Johannesburg Linux User Group (JoziJUg)
 

Recently uploaded

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 

Recently uploaded (20)

Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 

Map Reduce with Bash - An Example of the Unix Philosophy in Action

  • 1. Jumping Bean Map Reduce With Bash (the power of the Unix philosophy)
  • 2. Jumping Bean About Me ● Solutions integrator at Jumping Bean – Developer & Trainer – Technologies ● Java ● PHP ● HTML5/Javascript ● Linux – What I am planning to do: ● The Internet of things
  • 3. Jumping Bean Map/Reduce with Bash ● Purpose of this presentation is: – to demonstrate the power and flexibility of the Unix philosophy, – what awesome solutions can be created by using simple bash script and userland tools, – cool utilities and tools ● The purpose is not: – to suggest that Map/Reduce is best done with bash – best given constraint – see business problem
  • 4. Unix Philosophy “is a set of cultural norms and philosophical approaches to developing small yet capable Jumping Bean software” - Wikipedia
  • 5. Jumping Bean Unix Philosophy “Early Unix developers were important in bringing the concepts of modularity and reusability into software engineering practice, spawning a 'software tools' movement” - Wikipedia
  • 6. Jumping Bean Business Problem ● Nuclear Engineering department needs to run monte-carlo methods on data to calculate something to do with core temperature of nuclear reactors :), ● Post-grad students need to run analysis as part of their course work, ● Analysis can take days or weeks to run, ● University has invested in 900 node cluster, ● Cluster used for research when not used by students ● Tool used for analysis is – written in Fortran. – single threaded, ● No money for fancy-pants solution
  • 7. Jumping Bean Business Problem ● As-Is system – Professor uses laptop and desktop, – Manually starts application with simple script, – Start script x number of times where x=number of cores, – Waits for days, – Manually checks progress, – Not scalable to 900 nodes!
  • 8. Jumping Bean Business Problem ● Unknowns – How 900 node cluster set up i.e using any cluster software or virtualisation? ● Open Stack? ● Open Nebula? ● KVM? – Tools available to IT department – I.e how they do deploys, monitoring, user management etc ● Requirements – independence from IT department or experts for help, – Student & lecturer IT skills is limited to Fortran & some bash scripting skills, – Due to security concerns prevent IT staff from gaining access to research, ● Keep it simple – Proof of concept
  • 9. Jumping Bean What is Map/Reduce? ● Programming model for – Processing and generating large datasets, – Using a parallel distribution algorithm, – On a cluster or set of distributed nodes ● Popularised by Google and the advent of cloud computing ● Apache Hadoop – full blown map/reduce framework. Used to analyse your social media data, “understand the customer” and by numerous agencies with 3 letter acronyms. – “Really we only trying to help you know yourself better”
  • 10. Jumping Bean Map/Reduce Steps ● Map – Master node takes large dataset and distributes it to compute nodes to perform analysis on. The compute nodes return a result, ● Reduce – Gather the results of the compute nodes and aggregate results into final answer
  • 11. Jumping Bean What we need ● Controller node functions – to distribute data to nodes, – execute calculation functions – collect results ● Management node functions – distribute application and scripts to compute nodes, ● Compute node functions – Scripts to run the single threaded application in parallel on multi core processors ● Security Requirements – Prevent system administrators from gaining access to core application , script or data
  • 12. Jumping Bean Controller Functions ● How to distribute files to a node (map), execute calculations & gather results (reduce)? – Use split to split input files, – Use ssh to distribute files, execute processes, ● How to do this to multiple (900) nodes? – Use parallel ssh (pssh), paralle scp, ● Issues: – Copying public key to 900 machines? – Give each student their own account? ● Solution – Set up ldap authentication (password based) or – Include controller nodes root public key in compute node image, distribute 2ndary keys via scripts using pssh – Fancy pants – chef, ansible
  • 13. Management Node Functions ● Use parallel ssh to distribute scripts from management node to compute nodes, ● Using Ansible or Chef could be a next evolutionary step to automate system maintenance Jumping Bean
  • 14. Jumping Bean Compute Node Functions ● Basically bash scirpt - How to parallelise single threaded application to use multiple cores on modern CPUs? ● xargs – pass through list of input files, – -n set each iteration to run on one input file – -P set number of processes to start in parallel – Script waits for completion of processing & check output ● GNU parallels – Can run commands in parallel using 1 or more hosts – More options for target input placement {}, string replacement – Can pass output as input to another process
  • 15. Jumping Bean Compute/Controller Node ● At end of compute node process either compute node pings controller node, ● Controller node waits for pssh to return to carry out next step. I.e – reduce process or start next script with output from 1st being input to 2nd step, ● Check for errors and reschedule failed computes,
  • 16. Jumping Bean Security ● Each student should have separate account – Linux mutli-user system. User home directory for storing files and results ● Each user should be limited in resource usage – Simple ● ulimit ● psacct – Advanced ● Cgroups ● Namespaces ● Students can execute but not read bash script file, special permissions – Use sudo or – Linux capabilities ● setcap – eg setcap "cap_kill=+ep" script.sh
  • 17. Jumping Bean Security ● Limit the root user – Linux capabilities ● setcap, capsh,pscap ● Disable root account – grant CAP_SYS_ADMIN as needed, ● /etc/security/capabilities.conf
  • 18. Jumping Bean Resources ● Parallel SSH, ● Xargs, ● GNU parallel, ● cgroups, ● namespaces, ● Linux capabilities ● Twitter - @mxc4 ● Gplus – Mark Clarke ● Jumping Bean ● Cyber Connect ● Jozi Linux User Grou p ● Jozi Java User Group ● Maker Labs