Skip to content

StarCluster AMI Cookbook Scientific Linux 6.2

00gavin edited this page Nov 14, 2012 · 3 revisions

Here is the build log for a Scientific Linux AMI: ami-d60185bf

This image is based off of Jamie Kinney's Scientific Linux 6.2 x86_64 AMI.

$ starcluster start -s 1 foocluster -n ami-999d49f0
$ starcluster get foocluster /opt/sge6-fresh .
$ starcluster terminate foocluster
$ starcluster start -o -s 1 -i t1.micro -n ami-e2a0058b imagehost
$ starcluster listclusters --show-ssh-status imagehost
$ starcluster sshmaster imagehost -u ec2-user
$ sudo sed -i.bak -e's/\#PermitRootLogin\ yes/PermitRootLogin\ without-password/g' /etc/ssh/sshd_config
$ sudo sed -i.bak -e's/\#UseDNS\ yes/UseDNS\ no/g' /etc/ssh/sshd_config
$ sudo cp -f /home/ec2-user/.ssh/authorized_keys /root/.ssh/authorized_keys
$ sudo service sshd reload
$ exit
$ starcluster put imagehost ./sge6-fresh /opt/
$ rsync -e "ssh -i $HOME/starcluster/foocluster.rsa" -avP --delete sge6-fresh -l root ec2-23-23-64-53.compute-1.amazonaws.com:/opt/
$ starcluster sshmaster imagehost
# yum -y install yum-fastestmirror yum-conf-epel
# yum -y update
# yum -y install openmpi-devel nfs-utils-lib-devel java-1.6.0-openjdk-devel tmux zsh ksh tcsh \
  unzip mysql-server mysql httpd emacs ntsysv freetype-devel libpng-devel blas-devel lapack-devel \
  atlas-devel lbzip2 bzip2-devel ncurses-devel sqlite-devel zlib-devel libjpeg-devel mercurial ipython \
  python-imaging python-boto python-virtualenv Cython python-nose python-gnutls python-pip ruby
# echo "exit 0" >> /etc/init.d/portmap
# chmod +x /etc/init.d/portmap
# yum -y groupinstall "Development Tools"
# yum -y install infinipath-psm-devel
# yumdownloader --source openmpi
# rpm --import https://www.redhat.com/security/fd431d51.txt
# yum-builddep openmpi-1.5.4-1.el6.src.rpm
# rpm -ivh openmpi-1.5.4-1.el6.src.rpm
# rpmbuild -bb --define 'configure_options --with-sge' /root/rpmbuild/SPECS/openmpi.spec
# rpm -Uhv /root/rpmbuild/RPMS/x86_64/openmpi-1.5.4-1.el6.x86_64.rpm /root/rpmbuild/RPMS/x86_64/openmpi-devel-1.5.4-1.el6.x86_64.rpm
# echo "exclude=openmpi*" >> /etc/yum.conf
# . /etc/profile.d/modules.sh
# module load openmpi-x86_64
# ompi_info | grep -i grid
                 MCA ras: gridengine (MCA v2.0, API v2.0, Component v1.5.4)
# echo "module load openmpi-x86_64" >> /etc/profile.d/zzlocal.sh
# echo "module load openmpi-x86_64" >> /etc/profile.d/zzlocal.csh
# echo 'export PYTHONPATH=/usr/local/lib64/python2.6/site-packages:$PYTHONPATH' >> /etc/profile.d/zzlocal.sh
# echo 'setenv PYTHONPATH /usr/local/lib64/python2.6/site-packages:$PYTHONPATH' >> /etc/profile.d/zzlocal.csh
# chmod +x /etc/profile.d/zzlocal.*
# . /etc/profile.d/zzlocal.sh
# pip-python install --install-option="--prefix=/usr/local" mpi4py
# pip-python install --install-option="--prefix=/usr/local" numpy
# pip-python install --install-option="--prefix=/usr/local" scipy
# pip-python install --install-option="--prefix=/usr/local" matplotlib
# chmod u=rwx,go= /root /home/ec2-user
# vim /etc/rc.local # see below
# exit
$ starcluster listclusters
$ starcluster ebsimage i-xxxxxxxx starcluster-base-scientific-linux-6.2-x86_64-XX
>>> Your new AMI id is: ami-xxxxxxxx
$ starcluster terminate imagehost

/etc/rc.local

# update ec2-ami-tools
wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm && \
rpm -Uvh ec2-ami-tools.noarch.rpm

# reset root password
dd if=/dev/urandom count=50|md5sum|passwd --stdin root
dd if=/dev/urandom count=50|md5sum|passwd --stdin ec2-user

# update root ssh keys
sleep 40
if [ ! -d /root/.ssh ]; then
    mkdir -p /root/.ssh
    chmod 700 /root/.ssh
fi
wget http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key && \
cat openssh-key >>/root/.ssh/authorized_keys && \
chmod 600 /root/.ssh/authorized_keys
rm -f openssh-key