| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # version 0.3 |
| 3 | set -e |
| 4 | |
| 5 | # TODO |
| 6 | # add suer |
| 7 | HADOOP_RUN_USER='hadmin' |
| 8 | echoscip-shell system . . echo. '' | drbl-useradd -s $HADOOP_RUN_USER $HADOOP_RUN_USER |
| 9 | usermodscip-shell system . . usermod. $HADOOP_RUN_USER -s /bin/bashscip-shell filesystem . . `/bin/bash`. |
| 10 | |
| 11 | cpscip-shell system . . cp. /etc/hostsscip-shell filesystem . . `/etc/hosts`. /etc/hosts.bak.initialscip-shell filesystem . . `/etc/hosts.bak.initial`. |
| 12 | echoscip-shell system . . echo. "config drbl live service" |
| 13 | drbl-live start |
| 14 | |
| 15 | # drbl net device and ip, and update hostname |
| 16 | drbl_interface=$(catscip-shell system . . cat. /etc/drbl/drblpush.confscip-shell filesystem . . `/etc/drbl/drblpush.conf`. | grepscip-shell system . . grep. interface | sedscip-shell system . . sed. s/interface=//) |
| 17 | drbl_ip=$(LC_ALL=C ip addr show dev $drbl_interface | awkscip-shell system . . awk. '/inet / {print $2}scip-shell filesystem . . `/inet / {print $2}`.' | cutscip-shell system . . cut. -d/ -f1 | headscip-shell system . . head. -n1) |
| 18 | nhostname=$(getentscip-shell system . . getent. hosts $drbl_ip | awkscip-shell system . . awk. '{print $2}') |
| 19 | echoscip-shell system . . echo. $nhostname > /etc/hostnamescip-shell filesystem . . `/etc/hostname`. |
| 20 | hostnamescip-shell system . . hostname. $nhostname |
| 21 | |
| 22 | # download something from SF.net here |
| 23 | if [scip-shell system . . `[`. ! -f /opt/drbl-live-hadoop_0.3.tar.gzscip-shell filesystem . . `/opt/drbl-live-hadoop_0.3.tar.gz`. ]; then |
| 24 | wget http://prdownloads.sourceforge.net/drbl-hadoop/drbl-live-hadoop_0.3.tar.gz -O /opt/drbl-live-hadoop_0.3.tar.gzscip-shell filesystem . . `/opt/drbl-live-hadoop_0.3.tar.gz`. |
| 25 | fi |
| 26 | tarscip-shell system . . tar. -zxvf /opt/drbl-live-hadoop_0.3.tar.gzscip-shell filesystem . . `/opt/drbl-live-hadoop_0.3.tar.gz`. -C /opt/scip-shell filesystem . . `/opt/`. |
| 27 | |
| 28 | # Pre run |
| 29 | echoscip-shell system . . echo. "update base drbl image" |
| 30 | /opt/ezilla-hadoop/ezilla-hadoop-basescip-shell filesystem . . `/opt/ezilla-hadoop/ezilla-hadoop-base`. |
| 31 | mvscip-shell system . . mv. /usr/local/hadoopscip-shell filesystem . . `/usr/local/hadoop`. /usr/local/hadoop_serverscip-shell filesystem . . `/usr/local/hadoop_server`. |
| 32 | cpscip-shell system . . cp. -r /usr/local/hadoop_serverscip-shell filesystem . . `/usr/local/hadoop_server`. /usr/local/hadoop_clientscip-shell filesystem . . `/usr/local/hadoop_client`. |
| 33 | mkdirscip-shell system . . mkdir. /usr/local/hadoopscip-shell filesystem . . `/usr/local/hadoop`. |
| 34 | rmscip-shell system . . rm. /usr/local/hadoop_client/etc/hadoop/slavesscip-shell filesystem . . `/usr/local/hadoop_client/etc/hadoop/slaves`. |
| 35 | |
| 36 | cpscip-shell system . . cp. /opt/ezilla-hadoop/init.d/hadoop_dnscip-shell filesystem . . `/opt/ezilla-hadoop/init.d/hadoop_dn`. /etc/init.d/scip-shell filesystem . . `/etc/init.d/`. |
| 37 | echoscip-shell system . . echo. "$drbl_ip" > /etc/namenodescip-shell filesystem . . `/etc/namenode`. |
| 38 | echoscip-shell system . . echo. 'service_extra_added="hadoop_dn rc.local"' > /etc/drbl/client-extra-servicescip-shell filesystem . . `/etc/drbl/client-extra-service`. |
| 39 | echoscip-shell system . . echo. "$drbl_ip:/usr/local/hadoop_client /usr/local/hadoop/ nfs rw,hard,intr,nfsvers=3,tcp,nolock,defaults 0 0" > /etc/drbl/client-append-fstabscip-shell filesystem . . `/etc/drbl/client-append-fstab`. |
| 40 | echoscip-shell system . . echo. "$drbl_ip:/opt/rssh/ /root/.ssh nfs rw,hard,intr,nfsvers=3,tcp,nolock,defaults 0 0" >> /etc/drbl/client-append-fstabscip-shell filesystem . . `/etc/drbl/client-append-fstab`. |
| 41 | echoscip-shell system . . echo. "tmpfs /usr/local/hadoop/logs tmpfs defaults 0 0" >> /etc/drbl/client-append-fstabscip-shell filesystem . . `/etc/drbl/client-append-fstab`. |
| 42 | |
| 43 | catscip-shell system . . cat. << EVE > /etc/rc.localscip-shell filesystem . . `/etc/rc.local`. |
| 44 | #!/bin/sh -e |
| 45 | # |
| 46 | # rc.local |
| 47 | # |
| 48 | # This script is executed at the end of each multiuser runlevel. |
| 49 | # Make sure that the script will "exit 0" on success or any other |
| 50 | # value on error. |
| 51 | # |
| 52 | # In order to enable or disable this script just change the execution |
| 53 | # bits. |
| 54 | # |
| 55 | # By default this script does nothing. |
| 56 | |
| 57 | # add for hadoop-drbl |
| 58 | mkdir -p /media/hadoop_data/data/ |
| 59 | chown -R hadmin:hadmin /media/hadoop_data |
| 60 | mount -t tmpfs none /usr/local/hadoop/logs |
| 61 | /opt/ezilla-hadoop/ezilla-hadoop-datanode-postrun |
| 62 | # end |
| 63 | |
| 64 | exit 0 |
| 65 | EVE |
| 66 | |
| 67 | # root key |
| 68 | mkdirscip-shell system . . mkdir. -p /opt/rssh/scip-shell filesystem . . `/opt/rssh/`. |
| 69 | cpscip-shell system . . cp. /root/.ssh/id_rsa.pubscip-shell filesystem . . `/root/.ssh/id_rsa.pub`. /root/.ssh/authorized_keysscip-shell filesystem . . `/root/.ssh/authorized_keys`. |
| 70 | cpscip-shell system . . cp. /root/.ssh/* /opt/rssh/scip-shell filesystem . . `/opt/rssh/`. |
| 71 | |
| 72 | drblpush -c /etc/drbl/drblpush.confscip-shell filesystem . . `/etc/drbl/drblpush.conf`. |
| 73 | cpscip-shell system . . cp. /opt/ezilla-hadoop/init.d/hadoopscip-shell filesystem . . `/opt/ezilla-hadoop/init.d/hadoop`. /etc/init.d/scip-shell filesystem . . `/etc/init.d/`. |
| 74 | mountscip-shell system . . mount. -o bind /usr/local/hadoop_serverscip-shell filesystem . . `/usr/local/hadoop_server`. /usr/local/hadoop/scip-shell filesystem . . `/usr/local/hadoop/`. |
| 75 | chownscip-shell system . . chown. -R $HADOOP_RUN_USER:$HADOOP_RUN_USER /usr/local/hadoop* |
| 76 | rmscip-shell system . . rm. /usr/local/hadoop/etc/hadoop/slavesscip-shell filesystem . . `/usr/local/hadoop/etc/hadoop/slaves`. |
| 77 | #touch /etc/namenode_status |
| 78 | #/etc/init.d/hadoop start |
| 79 | |
| 80 | ## run example |
| 81 | #echo "run hadoop example" |
| 82 | #echo "su - $HADOOP_RUN_USER -c $HADOOP_PATH/bin/hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.3.0.jar pi 1 1" |
| 83 | #su - $HADOOP_RUN_USER -c "$HADOOP_PATH/bin/hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.3.0.jar pi 1 1" |
| 84 | # |
| 85 | #echo "su - $HADOOP_RUN_USER -c $HADOOP_PATH/bin/hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.3.0.jar TestDFSIO -write -nrFiles 2 -size 2MB" |
| 86 | #su - $HADOOP_RUN_USER -c "$HADOOP_PATH/bin/hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.3.0.jar TestDFSIO -write -nrFiles 2 -size 2MB" |
| 87 | # |
| 88 | #echo "enjoy hadoop, su to hduser to run all hadoop related commands." |