Install YARN on Mac OS X

I’d been bothered by a whole bunch of problems when I tried to install Hadoop 2.2.0 (YARN) on my Mac OS X system. Thanks to Alex JF for the tutorial which works with both Linux and Mac OS X.