Building an AMI
Starting with Gurobi 8.0, we have greatly simplified the process to create a custom AMI running the Gurobi Remote Services, and we will no longer provide predefined AMIs. This will give you more flexibility to start your servers in any AWS data center around the world. Also, you will be able to select and maintain the operating system. At the time of writing this guide, we recommend using the latest ubuntu 18.04 LTS AMI (we will assume such a choice in the following instructions).
Building an AMI manually
In order to create manually the AMI, please follow these steps, you should be very familiar with EC2:
- Launch an EC2 instance:
- Select the latest ubuntu 18.04 LTS AMI base AMI from the Community. You may want to search available
with the base name
ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-2018or refer to the ubuntu image locator
- Select the
t2.microinstance type, there is no need to select a larger instance to create the image.
- Make sure to setup a security group that is allowing SSH on port 22.
- Assign a key so that you will be able to log in to the instance (we will call it
- Wait for the instance to be running and lookup the instance public DNS name (we will call it
- Select the latest ubuntu 18.04 LTS AMI base AMI from the Community. You may want to search available AMIs with the base name
- Copy the server package to your instance:
scp -i key.pem gurobi_server9.0.0_linux64.tar.gz ubuntu@ec2-instance:/tmp/
- Log in to your instance:
ssh -i key.pem ubuntu@ec2-instance
- Unpack the server package:
sudo tar xfz /tmp/gurobi_server9.0.0_linux64.tar.gz -C /opt/
- Replace the configuration file with the predefined AWS configuration:
sudo cp /opt/gurobi_server9.0.0/linux64/bin/grb_rs_aws.cnf /opt/gurobi_server9.0.0/linux64/bin/grb_rs.cnfAlternatively, you can copy a configuration file that you prepared in advance.
- Review and update the configuration file as necessary (optional):
sudo vi /opt/gurobi_server9.0.0/linux64/bin/grb_rs.cnf
- Start the Remote Services:
sudo /opt/gurobi_server9.0.0/linux64/bin/grb_rs start
- Verify the log. The log messages are automatically forwarded to the syslog and also to service.log rotating
tail -f /opt/gurobi_server9.0.0/linux64/bin/service.logThe log file should indicate that the server started. Disregard the message about the license being invalid, unless you modified the configuration file with a
CLOUDKEY. However, make sure that there is no errors about the configuration file and properties. Here is a sample of the expected output:
... 2018-03-01T17:20:46Z - info : Starting API server (HTTP) on port 80...
- Log out of the instance
- Select the instance in the EC2 dashboard and run the action Image/Create Image, then wait for your image to be ready.
- Once the AMI is available, you can terminate the instance.
Building an AMI with Packer
You can easily automate the creation of the AMI using Packer. Here is a sample script provided as-is. You can easily extend it to copy a predefined configuration file, or to set up TLS encryption by copying your private key and certificate. With this script example, Packer will also select the latest ubuntu 18.04 base AMI for you. To use this script, please follow these steps:
- Install Packer
- Create a new directory
- Download the script
gurobi-ami.jsonand save it in this new directory
- Download the server package
gurobi_server9.0.0_linux64.tar.gzand save it in this new directory
- Run Packer from this directory and provide your AWS access key and secret on the command line:
$ packer build \ -var 'aws_access_key=YOUR ACCESS KEY' \ -var 'aws_secret_key=YOUR SECRET KEY' \ gurobi-ami.json