You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 11:03:34 UTC

svn commit: r1132223 - in /incubator/mesos/trunk/ec2: deploy.centos64/root/mesos-ec2/create-swap deploy.centos64/root/mesos-ec2/setup deploy.centos64/root/mesos-ec2/setup-slave mesos_ec2.py

Author: benh
Date: Sun Jun  5 09:03:34 2011
New Revision: 1132223

URL: http://svn.apache.org/viewvc?rev=1132223&view=rev
Log:
Added option for configuring swap space on each cluster node

Added:
    incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/create-swap   (with props)
Modified:
    incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/setup
    incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/setup-slave
    incubator/mesos/trunk/ec2/mesos_ec2.py

Added: incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/create-swap
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/create-swap?rev=1132223&view=auto
==============================================================================
--- incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/create-swap (added)
+++ incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/create-swap Sun Jun  5 09:03:34 2011
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+if [ $# -lt 1 ]; then
+  echo "Usage: create-swap <amount of MB>"
+  exit 1
+fi
+
+if [ -e /mnt/swap ]; then
+  echo "/mnt/swap already exists" >&2
+  exit 1
+fi
+
+SWAP_MB=$1
+dd if=/dev/zero of=/mnt/swap bs=1M count=$SWAP_MB
+mkswap /mnt/swap
+swapon /mnt/swap
+echo "Added $SWAP_MB MB swap file /mnt/swap"

Propchange: incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/create-swap
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/setup
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/setup?rev=1132223&r1=1132222&r2=1132223&view=diff
==============================================================================
--- incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/setup (original)
+++ incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/setup Sun Jun  5 09:03:34 2011
@@ -16,10 +16,12 @@ echo "Setting up Mesos master on `hostna
 OS_NAME=$1
 DOWNLOAD_METHOD=$2
 BRANCH=$3
+SWAP_MB=$4
 
 MASTERS_FILE="masters"
 MASTERS=`cat $MASTERS_FILE`
 NUM_MASTERS=`cat $MASTERS_FILE | wc -l`
+OTHER_MASTERS=`cat $MASTERS_FILE | sed '1d'`
 SLAVES=`cat slaves`
 ZOOS=`cat zoo`
 
@@ -32,6 +34,7 @@ fi
 
 # Scripts that get used for/while running Mesos.
 SCRIPTS="copy-dir
+         create-swap
          mesos-daemon
          redeploy-mesos
          setup-slave              
@@ -59,7 +62,7 @@ echo "Setting executable permissions on 
 for s in $SCRIPTS; do chmod u+x $s; done
 
 echo "Running setup-slave on master to mount filesystems, etc..."
-./setup-slave
+./setup-slave $SWAP_MB
 
 echo "SSH'ing to master machine(s) to approve key(s)..."
 for master in $MASTERS; do
@@ -82,11 +85,11 @@ if [[ $NUM_ZOOS != 0 ]] ; then
   done
 fi
 
-# Try to SSH to each slave to approve their key. Since some slaves may be
-# slow in starting, we retry failed slaves up to 3 times.
-TODO="$SLAVES"  # List of slaves to try (initially all of them)
-TRIES="0"       # Number of times we've tried so far
-echo "SSH'ing to slaves to approve keys..."
+# Try to SSH to each cluster node to approve their key. Since some nodes may
+# be slow in starting, we retry failed slaves up to 3 times.
+TODO="$SLAVES $ZOO $OTHER_MASTERS" # List of nodes to try (initially all)
+TRIES="0"                          # Number of times we've tried so far
+echo "SSH'ing to other cluster nodes to approve keys..."
 while [ "e$TODO" != "e" ] && [ $TRIES -lt 4 ] ; do
   NEW_TODO=
   for slave in $TODO; do
@@ -100,68 +103,33 @@ while [ "e$TODO" != "e" ] && [ $TRIES -l
   if [ "e$NEW_TODO" != "e" ] && [ $TRIES -lt 4 ] ; then
       sleep 15
       TODO="$NEW_TODO"
-      echo "Re-attempting SSH to slaves to approve keys..."
+      echo "Re-attempting SSH to cluster nodes to approve keys..."
   else
       break;
   fi
 done
 
-if [[ $NUM_MASTERS -gt 1 ]] ; then
-  echo "RSYNC'ing /root/mesos-ec2 to other master servers..."
-  for master in `cat $MASTERS_FILE | sed '1d'`; do
-      echo $master
-      rsync -e "ssh $SSH_OPTS" -az /root/mesos-ec2 $master:/root & sleep 0.3
-  done
-  wait
-fi
-
-if [[ $NUM_ZOOS != 0 ]] ; then
-  echo "RSYNC'ing /root/mesos-ec2 to ZooKeeper servers..."
-  for zoo in $ZOOS; do
-      echo $zoo
-      rsync -e "ssh $SSH_OPTS" -az /root/mesos-ec2 $zoo:/root & sleep 0.3
-  done
-  wait
-fi
-
-echo "RSYNC'ing /root/mesos-ec2 to slaves..."
-for slave in $SLAVES; do
-  echo $slave
-  rsync -e "ssh $SSH_OPTS" -az /root/mesos-ec2 $slave:/root &
-  scp $SSH_OPTS ~/.ssh/id_rsa $slave:.ssh &
+echo "RSYNC'ing /root/mesos-ec2 to other cluster nodes..."
+for node in $SLAVES $ZOO $OTHER_MASTERS; do
+  echo $node
+  rsync -e "ssh $SSH_OPTS" -az /root/mesos-ec2 $node:/root &
+  scp $SSH_OPTS ~/.ssh/id_rsa $node:.ssh &
   sleep 0.3
 done
 wait
 
-echo "Running slave setup script on slave and zookeeper nodes..."
-for node in $SLAVES $ZOO; do
+echo "Running slave setup script on other cluster nodes..."
+for node in $SLAVES $ZOO $OTHER_MASTERS; do
   echo $node
-  ssh -t $SSH_OPTS root@$node "mesos-ec2/setup-slave" & sleep 0.3
+  ssh -t $SSH_OPTS root@$node "mesos-ec2/setup-slave $SWAP_MB" & sleep 0.3
 done
 wait
 
-if [[ $NUM_MASTERS -gt 1 ]] ; then
-  echo "Running slave setup script on other masters..."
-  for master in `cat $MASTERS_FILE | sed '1d'`; do
-    echo $master
-    rsync -e "ssh $SSH_OPTS" mesos-ec2/setup-slave & sleep 0.3
-  done
-  wait
-  echo "RSYNC'ing HDFS config files to other masters..."
-  for master in `cat $MASTERS_FILE | sed '1d'`; do
-    echo $master
-    rsync -e "ssh $SSH_OPTS" -az $EPHEMERAL_HDFS/conf $master:$EPHEMERAL_HDFS &
-    rsync -e "ssh $SSH_OPTS" -az $PERSISTENT_HDFS/conf $master:$PERSISTENT_HDFS &
-    sleep 0.3
-  done
-  wait
-fi
-
-echo "RSYNC'ing HDFS config files to slaves..."
-for slave in $SLAVES; do
-  echo $slave
-  rsync -e "ssh $SSH_OPTS" -az $EPHEMERAL_HDFS/conf $slave:$EPHEMERAL_HDFS &
-  rsync -e "ssh $SSH_OPTS" -az $PERSISTENT_HDFS/conf $slave:$PERSISTENT_HDFS &
+echo "RSYNC'ing HDFS config files to other cluster nodes..."
+for node in $SLAVES $ZOO $OTHER_MASTERS; do
+  echo $node
+  rsync -e "ssh $SSH_OPTS" -az $EPHEMERAL_HDFS/conf $node:$EPHEMERAL_HDFS &
+  rsync -e "ssh $SSH_OPTS" -az $PERSISTENT_HDFS/conf $node:$PERSISTENT_HDFS &
   sleep 0.3
 done
 wait

Modified: incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/setup-slave
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/setup-slave?rev=1132223&r1=1132222&r2=1132223&view=diff
==============================================================================
--- incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/setup-slave (original)
+++ incubator/mesos/trunk/ec2/deploy.centos64/root/mesos-ec2/setup-slave Sun Jun  5 09:03:34 2011
@@ -12,6 +12,9 @@ HOSTNAME=$PRIVATE_DNS  # Fix the bash bu
 
 echo "Setting up Mesos slave on `hostname`..."
 
+# Read command-line arguments
+SWAP_MB=$1
+
 # Mount options to use for ext3 and xfs disks (the ephemeral disks
 # are ext3, but we use xfs for EBS volumes to format them faster)
 EXT3_MOUNT_OPTS="defaults,noatime,nodiratime"
@@ -75,3 +78,6 @@ fi
 # Remove ~/.ssh/known_hosts because it gets polluted as you start/stop many
 # clusters (new machines tend to come up under old hostnames)
 rm -f /root/.ssh/known_hosts
+
+# Create swap space on /mnt
+/root/mesos-ec2/create-swap $SWAP_MB

Modified: incubator/mesos/trunk/ec2/mesos_ec2.py
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/ec2/mesos_ec2.py?rev=1132223&r1=1132222&r2=1132223&view=diff
==============================================================================
--- incubator/mesos/trunk/ec2/mesos_ec2.py (original)
+++ incubator/mesos/trunk/ec2/mesos_ec2.py Sun Jun  5 09:03:34 2011
@@ -26,7 +26,7 @@ def parse_args():
   parser.add_option("-s", "--slaves", type="int", default=1,
       help="Number of slaves to launch (default: 1)")
   parser.add_option("-w", "--wait", type="int", default=60,
-      help="Number of seconds to wait for cluster to come up (default: 60)")
+      help="Number of seconds to wait for cluster nodes to start (default: 60)")
   parser.add_option("-k", "--key-pair",
       help="Key pair to use on instances")
   parser.add_option("-i", "--identity-file", 
@@ -54,12 +54,14 @@ def parse_args():
       help="Resume installation on a previously launched cluster " +
            "(for debugging)")
   parser.add_option("-f", "--ft", metavar="NUM_MASTERS", default="1", 
-      help="Number of masters to run. Default is 1. " + 
-           "Greater values cause Mesos to run in FT mode with ZooKeeper.")
+      help="Number of masters to run. Default is 1. Greater values " + 
+           "make Mesos run in fault-tolerant mode with ZooKeeper.")
   parser.add_option("--ebs-vol-size", metavar="SIZE", type="int", default=0,
       help="Attach a new EBS volume of size SIZE (in GB) to each node as " +
            "/vol. The volumes will be deleted when the instances terminate. " +
            "Only possible on EBS-backed AMIs.")
+  parser.add_option("--swap", metavar="SWAP", type="int", default=1024,
+      help="Swap space to set up per node, in MB (default: 1024)")
   (opts, args) = parser.parse_args()
   opts.ft = int(opts.ft)
   if len(args) != 2:
@@ -264,7 +266,8 @@ def setup_cluster(conn, master_nodes, sl
     scp(master, opts, opts.identity_file, '/root/.ssh/id_rsa')
   print "Running setup on master..."
   ssh(master, opts, "chmod u+x mesos-ec2/setup")
-  ssh(master, opts, "mesos-ec2/setup %s %s %s" % (opts.os, opts.download, opts.branch))
+  ssh(master, opts, "mesos-ec2/setup %s %s %s %s" %
+      (opts.os, opts.download, opts.branch, opts.swap))
   print "Done!"