Skip to content

Commit 2644901

Browse files
committed
Hello World tutorial.
1 parent 5d456b8 commit 2644901

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

docs/source/hello_world.rst

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
.. _hello_world:
2+
3+
.. toctree::
4+
:maxdepth: 2
5+
6+
####################################
7+
Running your first job on cfncluster
8+
####################################
9+
10+
This tutorial will walk you through running your first "Hello World" job on cfncluster.
11+
12+
If you haven't yet, you will need to following the :doc:`getting started <getting_started>` guide to install cfncluster and configure your CLI.
13+
14+
Verifying your installation
15+
===========================
16+
17+
First, we'll verify that cfncluster is correctly installed and configured. ::
18+
19+
$ cfncluster version
20+
21+
This should return the running version of cfncluster. If it gives you a message about configuration, you will need to run the following to configure cfncluster. ::
22+
23+
$ cfncluster configure
24+
25+
26+
Creating your First Cluster
27+
===========================
28+
29+
Now it's time to create our first cluster. Because our workload isn't performance intensive, we will use the default instance sizes of t2.micro. For production workloads, you'll want to choose an instance size which better fits your needs.
30+
31+
We're going to call our cluster "hello-world". ::
32+
33+
$ cfncluster create hello-world
34+
35+
You'll see some messages on your screen about the cluster creating. When it's finished, it will provide the following output::
36+
37+
Starting: hello-world
38+
Status: cfncluster-hello-world - CREATE_COMPLETE
39+
Output:"MasterPrivateIP"="192.168.x.x"
40+
Output:"MasterPublicIP"="54.148.x.x"
41+
Output:"GangliaPrivateURL"="http://192.168.x.x/ganglia/"
42+
Output:"GangliaPublicURL"="http://54.148.x.x/ganglia/"
43+
44+
The message "CREATE_COMPLETE" shows that the cluster created sucessfully. It also provided us with the public and private IP addresses of our master node. We'll need this IP to log in.
45+
46+
Logging into your Master instance
47+
=================================
48+
You'll use your OpenSSH pem file and the ec2-user to log into your master instance. ::
49+
50+
ssh -i /path/to/keyfile.pem [email protected]
51+
52+
Once logged in, run the command "qhost" to ensure that your compute nodes are setup and configured. ::
53+
54+
[ec2-user@ip-192-168-1-86 ~]$ qhost
55+
HOSTNAME ARCH NCPU NSOC NCOR NTHR LOAD MEMTOT MEMUSE SWAPTO SWAPUS
56+
----------------------------------------------------------------------------------------------
57+
global - - - - - - - - - -
58+
ip-192-168-1-125 lx-amd64 2 1 2 2 0.15 3.7G 130.8M 1024.0M 0.0
59+
ip-192-168-1-126 lx-amd64 2 1 2 2 0.15 3.7G 130.8M 1024.0M 0.0
60+
61+
As you can see, we have two compute nodes in our cluster, both with 2 threads available to them.
62+
63+
Running your first job
64+
=====================
65+
Now we'll create a simple job which sleeps for a little while and then outputs it's own hostname.
66+
67+
Create a file called "hellojob.sh" with the following contents. ::
68+
69+
#!/bin/bash
70+
sleep 30
71+
echo "Hello World from $(hostname)"
72+
73+
Next, submit the job using "qsub" and ensure it runs. ::
74+
75+
$ qsub hellojob.sh
76+
Your job 1 ("hellojob.sh") has been submitted
77+
78+
Now, you can vew your queue and check the status of the job. ::
79+
80+
$ qstat
81+
job-ID prior name user state submit/start at queue slots ja-task-ID
82+
-----------------------------------------------------------------------------------------------------------------
83+
1 0.55500 hellojob.s ec2-user r 03/24/2015 22:23:48 [email protected] 1
84+
85+
The job is currently in a running state. Wait 30 seconds for the job to finish and run qsub again. ::
86+
87+
$ qstat
88+
$
89+
90+
Now that there are no jobs in the queue, we can check for output in our current directory. ::
91+
92+
$ ls -l
93+
total 8
94+
-rw-rw-r-- 1 ec2-user ec2-user 48 Mar 24 22:34 hellojob.sh
95+
-rw-r--r-- 1 ec2-user ec2-user 0 Mar 24 22:34 hellojob.sh.e1
96+
-rw-r--r-- 1 ec2-user ec2-user 34 Mar 24 22:34 hellojob.sh.o1
97+
98+
Here, we see our job script, an "e1" and "o1" file. Since the e1 file is empty, there was no output to stderr. If we view the .o1 file, we can see any output from our job. ::
99+
100+
$ cat hellojob.sh.o1
101+
Hello World from ip-192-168-1-125
102+
103+
We can see that our job sucessfully ran on instance "ip-192-168-1-125".

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ cfncluster is a framework that deploys and maintains High Performance Clusters (
1616
welcome
1717
configuration
1818
functional
19+
tutorials
1920

2021
Getting Started
2122
---------------

docs/source/tutorials.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. _tutorials
2+
3+
Tutorials
4+
#########
5+
6+
Here you can find tutorials for best practices guides for getting started with cfncluster.
7+
8+
.. toctree::
9+
10+
hello_world

0 commit comments

Comments
 (0)