Building AWS AMI on Ubuntu 20 and mono 6 for Omicsoft Cloud Computing

From Array Suite Wiki

Jump to: navigation, search

Contents

Build AWS AMI for OmicSoft Cloud Computing

OmicSoft Cloud uses customized Ubuntu-based Amazon Machine Images (AMIs) as the template for creating compute instances for running cloud-based analyses. These AMIs require a few key components, including the Oshell engine, packages for transferring data to and from AWS S3 storage, and Docker.

Tips.pngOmicSoft generally recommends using our pre-built Compute AMIs


OmicSoft provides default AMIs for cloud computing, based on Ubuntu. Alternatively, users can build their own AMI then follow the configuration steps below.

On-demand compute instances to analyze ArrayServer jobs (i.e. AMIs used for OmicSoft Cloud analysis) must use an Ubuntu image. We recommend explicitly specifying the preferred AMI from the list below, in ArrayServer.cfg in the Ami and AmiSnapshot parameters, or by building your own Ubuntu AMI with the configuration steps outlined below.

If you build your own AMI, the AMI should be built following the instructions below exactly, including the file paths to software tools. Please be aware the OmicSoft support can only provide limited advice on troubleshooting custom AMIs, because of the large number of configuration options that can impact performance.

Configure your own Ubuntu image

From AWS Console, start a new instance using Ubuntu Server 20.04 LTS (HVM), (64-bit x86) (Region: US East (N. Virginia)

ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210325 - ami-04cc2b0ad9e30a9c8
  • instance type: m4.xlarge (not so important in this phased)
  • auto-assign public IP: enabled
  • storage: 30 GiB, volume type: General Purpose SSD (gp2)
    • the 30GiB initial size must be maintained for backwards compatibility
  • Tags: Name: Oshell2021Ubuntu20Mono6
  • Security group: define a new one that allows you to access the instance
  • when launching it, select an existing key pair for which you have also the private key (for ssh access) - ex.: Omicsoft.Launching.ppk

Connect to the instance using SSH (ex.: using Putty) - user: ubuntu

Update and install the required packages

sudo apt-get install -f
sudo apt-get update
  
sudo apt-get install gcc g++ bison make git autoconf libtool automake build-essential gettext cmake python3 curl libtool-bin libgdiplus zlib1g-dev libglib2.0-dev
sudo apt-get install libpng-dev libjpeg-dev libtiff5-dev libgif-dev libgs-dev libexif-dev libx11-dev fontconfig
sudo apt-get install unzip

Build and install mono 6.12.0.122 from source:

(compile needed only for --with-large-heap=yes --enable-big-arrays=yes option ; latest mono 6 version when the AMI was build)

1. Build and install mono 6.12.0.122 from source:

$ cd ~
$ wget -c http://download.mono-project.com/sources/mono/mono-6.12.0.122.tar.xz
$ tar xvf mono-6.12.0.122.tar.xz
$ cd mono-6.12.0.122/
$ ./configure --prefix=/opt/mono-6.12.0 --with-large-heap=yes --enable-big-arrays=yes
$ sudo make
$ sudo make install
$ export PATH=$PATH:/opt/mono-6.12.0/bin/

Specify mono6 for spawned jobs

Create a symlink to the mono directory:

$ sudo ln -s /opt/mono-6.12.0/ /opt/mono-4.0.4

This is needed for backwards compatibility - OmicSoft Server maintains hard-coded paths to mono-4.0.4 for spawned-off jobs.

Remember to update ArrayServer.cfg with paths to mono6:

2. Check the mono version:

$ cd /opt/mono-6.12.0/bin
$ ./mono --version

The output should look like this: Mono JIT compiler version 6.12.0.122 (tarball Mon Sep 7 13:38:50 UTC 2020)

3. Install the certs in mono store (mono has a separate cert store than the one used by Ubuntu; compiling mono does not populate the mono cert store)

sudo /opt/mono-6.12.0/bin/certmgr --ssl -m https://resources.omicsoft.com
sudo /opt/mono-6.12.0/bin/cert-sync /etc/ssl/certs/ca-certificates.crt
wget -c https://resources.omicsoft.com/downloads/certs/resources.omicsoft.com.zip
unzip resources.omicsoft.com.zip
/path/to/mono/certmgr -add -c Trust Trust.crt

Libgdiplus

The mono config file must be edited to explicitly specify the location of libgdiplus.so

Find where libgdiplus was installed:

$ ldconfig -p | grep libgdiplus
libgdiplus.so.0 (libc6,x86-64) => /lib/libgdiplus.so.0
libgdiplus.so (libc6,x86-64) => /lib/libgdiplus.so

Edit the mono config file, usually located at (ex.): /opt/mono-6.12.0/etc/mono and add the following entry at the end of the file before </configuration>:

...
       <dllmap dll="gdiplus" target="libgdiplus.so" os="!windows"/>
       <dllmap dll="gdiplus.dll" target="libgdiplus.so"  os="!windows"/>
       <dllmap dll="gdi32" target="libgdiplus.so" os="!windows"/>
       <dllmap dll="gdi32.dll" target="libgdiplus.so" os="!windows"/>

       <dllmap dll="gdiplus.dll" target="/lib/libgdiplus.so.0"/>
</configuration>

Create a symlink to the mono directory

$ sudo ln -s /opt/mono-6.12.0/ /opt/mono-4.0.4

(replace mono-6.12.0 with the current mono version) This is needed for backwards compatibility - the code has to be able to run on older machines, that were not upgraded to mono 6.

Having both mono 4 and mono 6 in parallel on the same AWS job instance is not currently supported.

Add appropriate SSL certificates

(mono has a separate cert store than the one used by Ubuntu; compiling mono does not populate the mono cert store)

certmgr --ssl https://resources.omicsoft.com
sudo /opt/mono-6.12.0/bin/certmgr --ssl -m https://resources.omicsoft.com
 
sudo /opt/mono-6.12.0/bin/cert-sync /etc/ssl/certs/ca-certificates.crt

Verify with: certmgr -list -c -m Trust

Sqlite 3.7.14.1 2012-10-04

cd ~
wget -c http://www.sqlite.org/sqlite-autoconf-3071401.tar.gz
tar zxvf sqlite-autoconf-3071401.tar.gz
sudo mv sqlite-autoconf-3071401 sqlite
cd sqlite/
./configure --prefix=/opt/sqlite
make
sudo make install

Increase the ulimits

Increase ulimit as described at Setting up ulimit for ArrayServer

Install OShell

Assume mono (regardless of version) has been installed in sudo /[path where mono was installed]/bin/mono. We install oshell in the home directory.

cd /opt
sudo mkdir oshell
cd oshell
sudo wget -c http://omicsoft.com/software_update/OmicsoftUpdater.exe
sudo touch oshell.exe
sudo /[path where mono was installed]/bin/mono /opt/oshell/OmicsoftUpdater.exe
sudo /[path where mono was installed]/bin/mono /opt/oshell/oshell.exe --version

Install AWS CLI (currently aws-cli/1.19.17)

sudo apt-get install python3-pip
sudo pip3 install awscli
aws --version

Install Python

The version installed so far is:

$ python3 -V
Python 3.8.5

Install R

$sudo apt-get install r-base
$sudo R
  
R version 3.6.3 (2020-02-29) -- "Holding the Windsock"

Install Docker

Install Docker (20.10.*, see: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository )

sudo apt-get remove docker docker-engine docker.io containerd runc
 
sudo apt-get update
 
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) \
    stable"
 
sudo apt-get update
 
sudo apt-get install docker-ce docker-ce-cli containerd.io

Create a new AMI

  • On the EC2 Instance created above, in AWS console right click on the instance, go to Images and templates and press Create image
  • Give it a name different than the EC2 instance name
  • If an SSH is open to the EC2 Instance you will be disconnected for a while
AMI ID: ami-05a7347f863981611
Name: Official Oshell (2021, Ubuntu, Mono6)
AMI Name: Oshell2021Ubuntu20Mono6_latest
Snapshot: snap-0eabbc72359aad870