SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
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

Más contenido relacionado

Más de Jumping Bean

IPv6 - Jozi Linux User Group Presentation
IPv6  - Jozi Linux User Group PresentationIPv6  - Jozi Linux User Group Presentation
IPv6 - Jozi Linux User Group Presentation
Jumping Bean
 

Más de 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)
 

Último

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 

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