Created
November 15, 2013 19:57
-
-
Save xslogic/7490599 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Get job properties | |
| JOB=nodemanager | |
| index=<%= index %> | |
| host_suffix=<%= spec.networks.methods(false).grep(/[^=]$/).first.to_s %>.<%= spec.deployment %>.<%= p("global.boshType")%> | |
| server=<%= index %>.<%= spec.job.name %>.${host_suffix} | |
| yum_repo_server=0.<%= p("global.yum-repo_job") %>.${host_suffix} | |
| RUN_DIR=/var/vcap/sys/run/$JOB | |
| LOG_DIR=/var/vcap/sys/log/$JOB | |
| STORE_DIR=/var/vcap/store/$JOB | |
| TMPDIR=/var/vcap/data/tmp/$JOB | |
| PIDFILE= | |
| RUNAS=root | |
| export PATH=$PATH:/var/vcap/jobs/$JOB/bin | |
| export TMPDIR=$TMPDIR | |
| YARN_LOG=<%= p("resourcemanager.log_dir") %> | |
| case $1 in | |
| # remember to make the start idempotent! | |
| start) | |
| mkdir -p $RUN_DIR $LOG_DIR $STORE_DIR $TMPDIR | |
| chown -R $RUNAS:$RUNAS $RUN_DIR $LOG_DIR $STORE_DIR $TMPDIR | |
| #Set hostname | |
| echo -e "HOSTNAME=$server" > /etc/sysconfig/network | |
| hostname $server | |
| # Stemcell builder should fix it. Currently this is a workaround. | |
| chmod 644 /etc/resolv.conf | |
| chmod 777 /tmp | |
| # Create local repo file [If does not exist already] | |
| phd-repo-file="/etc/yum.repos.d/phd.repo" | |
| if [[ ! -f $phd-repo-file ]] ; then | |
| echo -e "[phd]\nname=CentOS-PHD packages for \$basearch\nbaseurl=http://$yum_repo_server/phd\nenabled=1\ngpgcheck=0\nprotect=1\n" > /etc/yum.repos.d/phd.repo | |
| fi | |
| mkdir -p /var/vcap/data/gphdtmp | |
| chmod 777 /var/vcap/data/gphdtmp | |
| mkdir -p $YARN_LOG | |
| chmod 777 $YARN_LOG | |
| disk_mount_point=/var/vcap/data/yarn-local | |
| # Install YARN RPMs | |
| OUT=`yum --disablerepo=\* --enablerepo=phd install jdk hadoop-hdfs hadoop-mapreduce hadoop-yarn-nodemanager -y 2>&1` | |
| echo $OUT >> $LOG_DIR/$JOB.stdout.log | |
| echo "$disk_mount_point, $server" >> $LOG_DIR/$JOB.stdout.log | |
| # Fixup directories | |
| mkdir -p $disk_mount_point/mapred/local | |
| mkdir -p $disk_mount_point/yarn/userlogs | |
| mkdir -p $disk_mount_point/yarn/nm-local-dir | |
| mkdir -p $disk_mount_point/io/local | |
| chown -R yarn $disk_mount_point | |
| # copy the config files to /etc/gphd/hadoop/conf | |
| cp /var/vcap/jobs/$JOB/config/* /etc/gphd/hadoop/conf/ | |
| chmod 755 /etc/gphd/hadoop/conf/* | |
| OUT=`/etc/init.d/hadoop-yarn-nodemanager start 2>&1` | |
| echo $OUT >> $LOG_DIR/$JOB.stdout.log | |
| ;; | |
| stop) | |
| # Stop the NM | |
| OUT=`/etc/init.d/hadoop-yarn-nodemanager stop 2>&1` | |
| echo $OUT >> $LOG_DIR/$JOB.stdout.log | |
| ;; | |
| *) | |
| echo "Usage: $JOB_ctl {start|stop}" ;; | |
| esac | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment