Project

General

Profile

root / trunk / doc / manual / opennebula.tex @ 685

1
OpenNebula (\url{http://www.opennebula.org/}) is a virtual infrastructure manager that enables the dynamic deployment and re-allocation of virtual machines on a pool of physical resources. Haizea can be used to extend OpenNebula's scheduling capabilities, allowing it to support advance reservation of resources and queueing of best effort requests. OpenNebula and Haizea complement each other, since OpenNebula provides all the enactment muscle (OpenNebula can manage Xen, KVM, and VMWare VMs on a cluster) and Haizea provides the scheduling brains. Using both of them together is simple, since Haizea acts as a drop-in replacement for OpenNebula's scheduling daemon. 
2

    
3
This chapter explains how to use OpenNebula and Haizea together, and explains how to submit requests to OpenNebula to use Haizea's scheduling capabilities.
4

    
5
\section{Installing OpenNebula and Haizea}
6

    
7
If you have not already done so, you will need to install OpenNebula 1.4 and the latest version of Haizea. Start by installing OpenNebula, and then installing Haizea.
8

    
9
Before proceeding, you may want to follow the OpenNebula quickstart guide (\url{http://www.opennebula.org/doku.php?id=documentation:rel1.4:qg}) to verify that your OpenNebula installation is working fine. The rest of this document assumes that OpenNebula is correctly installed, and that you know what a \emph{virtual machine template} is (``VM templates'' is how VMs are requested to OpenNebula, so we'll be working with them quite a bit). You may also want to follow the Haizea Quickstart Guide (see Chapter~\ref{chap:quickstart}, to verify that Haizea is correctly installed.
10

    
11
\section{Configuring Haizea}
12

    
13
Haizea must be configured to run in OpenNebula mode. Haizea includes a sample OpenNebula configuration file that you can use as a starting point. This file is installed, by default, in \texttt{/usr/share/haizea/etc/sample\_opennebula.conf} (there is also a \texttt{sample\_opennebula\_barebones.conf} file that has the same options, but without any documentation). In OpenNebula mode, Haizea will process requests coming from OpenNebula, and will send all enactment commands to OpenNebula. To activate this mode, the \texttt{mode} option of the \texttt{general} section in the Haizea configuration file must be set to \texttt{opennebula}:
14

    
15
\begin{wideshellverbatim}
16
[general]
17
...
18
mode: opennebula
19
...
20
\end{wideshellverbatim}
21

    
22
Haizea interacts with OpenNebula through it's XML-RPC API, so you need to tell Haizea what host OpenNebula is on. This is done in the \texttt{opennebula} section:
23

    
24
\begin{wideshellverbatim}
25
[opennebula]
26
# Typically, OpenNebula and Haizea will be installed
27
# on the same host, so the following option should be
28
# set to 'localhost'. If they're on different hosts,
29
# make sure you modify this option accordingly.
30
host: localhost
31
\end{wideshellverbatim}
32

    
33
Additionally, if OpenNebula is not listening on its default port (2633), you can use the \texttt{port} option in the \texttt{opennebula} section to specify a different port.
34

    
35
There are also a couple options in the \texttt{scheduling} section that are relevant to OpenNebula mode, but which you do not need to concern yourself with yet (they are described at the end of this chapter).
36

    
37
\section{Running OpenNebula and Haizea together}
38

    
39
Now that Haizea is configured to run alongside OpenNebula, running them is as simple as starting the OpenNebula daemon:
40

    
41
\begin{wideshellverbatim}
42
oned
43
\end{wideshellverbatim}
44

    
45
Followed by Haizea:
46

    
47
\begin{wideshellverbatim}
48
haizea -c /usr/share/haizea/etc/sample_opennebula.conf
49
\end{wideshellverbatim}
50

    
51
The above assumes that you are running OpenNebula and Haizea in the same machine and with the same user. If this is not the case, you have to set the \texttt{ONE\_AUTH} environment variable (as described in the OpenNebula documentation) for the user and machine running Haizea. The variable must contain the path to a file containing the username and password of the OpenNebula administrator user (typically called \texttt{oneadmin}) with the format \texttt{username:password}. 
52

    
53
By default, Haizea runs as a daemon when running in OpenNebula mode. For this chapter, you may want to run it in the foreground so you can see the Haizea log messages in your console:
54

    
55
\begin{wideshellverbatim}
56
haizea --fg -c /usr/share/haizea/etc/sample_opennebula.conf
57
\end{wideshellverbatim}
58

    
59
When Haizea starts up, it will print out something like this:
60

    
61
\begin{wideshellverbatim}
62
[                      ] ENACT.ONE.INFO Fetched N nodes from OpenNebula
63
[2009-07-30 18:36:54.07] RM      Starting resource manager
64
[2009-07-30 18:36:54.07] RPCSERVER RPC server started on port 42493
65
[2009-07-30 18:36:54.07] CLOCK   Starting clock
66
\end{wideshellverbatim}
67

    
68
This means that Haizea has correctly started up, contacted OpenNebula and detected that there are N physical nodes (the value of N will depend, of course, on how many nodes you have in your system).
69

    
70
\begin{warning}
71
Haizea is a drop-in replacement for OpenNebula's default scheduler (\texttt{mm\_sched}). Do not run Haizea and \texttt{mm\_sched} at the same time, or funny things will happen.
72
\end{warning}
73

    
74
\section{A quick test}
75

    
76
At this point, OpenNebula and Haizea are both running together, and waiting for you to submit a VM request. From the user's perspective, you will still be submitting your requests to OpenNebula, and Haizea will do all the scheduling work backstage. However, you will be able to add an \texttt{HAIZEA} parameter to your OpenNebula request to access Haizea's features.
77

    
78
So, to test that OpenNebula and Haizea are working correctly, start by taking a known-good OpenNebula template. Just to be on the safe side, you may want to try it with the default scheduler first, to make sure that the VM itself works correctly, etc. Then, just add the following parameter to the template:
79

    
80
\begin{wideshellverbatim}
81
HAIZEA = [
82
  start        = "+00:00:30",
83
  duration     = "00:01:00",
84
  preemptible  = "no"
85
]
86
\end{wideshellverbatim}
87

    
88
The exact meaning of these parameters is explained later on in this document. In a nutshell, the values specified above tell Haizea to schedule the VM to start exactly 30 seconds in the future, to run for one minute, and to not allow the allocated resources to be preempted by other requests. This corresponds to an Haizea \emph{advance reservation lease} (see Chapter~\ref{chap:leases}).
89

    
90
Before you submit your request to OpenNebula, take a look at the Haizea log. You should see something like this repeating every minute:
91

    
92
\begin{wideshellverbatim}
93
[2009-07-30 18:38:44.00] CLOCK   Waking up to manage resources
94
[2009-07-30 18:38:44.00] CLOCK   Wake-up time recorded as 2009-07-30 18:38:44.00
95
[2009-07-30 18:38:44.01] CLOCK   Going back to sleep. 
96
                                 Waking up at 2009-07-30 18:38:54.00 
97
                                 to see if something interesting has happened by then.
98
\end{wideshellverbatim}
99

    
100
Haizea is configured, by default, to ask OpenNebula if there are any pending requests every minute. Since you haven't submitted anything, Haizea just wakes up every minute and goes right back to sleep. So, go ahead and submit your request (the one where you added the HAIZEA parameter). Assuming you named the template ar.one, run the following:
101

    
102
\begin{wideshellverbatim}
103
onevm submit ar.one
104
\end{wideshellverbatim}
105

    
106
If you run \texttt{onevm list} to see the VMs managed by OpenNebula, you'll see that the request is in a \texttt{pending} state:
107

    
108
\begin{wideshellverbatim}
109
  ID     USER     NAME STAT CPU     MEM        HOSTNAME        TIME
110
-------------------------------------------------------------------
111
  42    borja     test pend   0       0                 00 00:00:02
112
\end{wideshellverbatim}
113

    
114
Next time Haizea wakes up, you should see something like this:
115

    
116
\begin{wideshellverbatim}
117
[2009-07-30 18:41:49.16] CLOCK   Waking up to manage resources
118
[2009-07-30 18:41:49.16] CLOCK   Wake-up time recorded as 2009-07-30 18:41:49.00
119
[2009-07-30 18:41:49.19] LSCHED  Lease #1 has been requested.
120
[2009-07-30 18:41:49.19] LSCHED  Lease #1 has been marked as pending.
121
[2009-07-30 18:41:49.19] LSCHED  Scheduling AR lease #1, 1 nodes 
122
                                     from 2009-07-30 18:42:15.00 
123
                                       to 2009-07-30 18:43:15.00.
124
[2009-07-30 18:41:49.19] LSCHED  AR lease #1 has been scheduled.
125

    
126
[2009-07-30 18:41:49.19] CLOCK   Going back to sleep. 
127
                                 Waking up at 2009-07-30 18:42:15.00 
128
                                 to handle slot table event.
129
\end{wideshellverbatim}
130

    
131
Notice how Haizea detected that OpenNebula had an AR request, and then scheduled it to start 30 seconds in the future. In fact, Haizea takes care to wake up at that time so the VM can start at exactly that time.
132

    
133
\begin{warning}
134
If you run \texttt{onevm list}, the request will still be shown as \texttt{pending}. OpenNebula doesn't track Haizea's internal states, so it will consider the request "pending" until Haizea starts up the VM. You can check the state of Haizea leases using the \texttt{haizea-list-leases} command.
135
\end{warning}
136

    
137
\begin{warning}
138
Currently, Haizea has to poll OpenNebula every minute to ask if there are any new requests. An upcoming version of Haizea will support an event-based model where OpenNebula can send Haizea a notification as soon as a new request is received (so the user doesn't have to wait until the next time Haizea wakes up to process the request).
139
\end{warning}
140

    
141
When the VM is scheduled to start, you will see the following in the Haizea logs:
142

    
143
\begin{wideshellverbatim}
144
[2009-07-30 18:42:15.02] CLOCK   Waking up to manage resources
145
[2009-07-30 18:42:15.02] CLOCK   Wake-up time recorded as 2009-07-30 18:42:15.00
146
[2009-07-30 18:42:15.04] VMSCHED Started VMs for lease 1 on nodes [2]
147
[2009-07-30 18:42:15.09] CLOCK   Going back to sleep. 
148
                                 Waking up at 2009-07-30 18:43:00.00 
149
                                 to handle slot table event.
150
\end{wideshellverbatim}
151

    
152
Haizea has instructed OpenNebula to start the VM for the advance reservation. If you run \texttt{onevm list}, the VM will now show up as running:
153

    
154
\begin{wideshellverbatim}
155
  ID     USER     NAME STAT CPU     MEM        HOSTNAME        TIME
156
-------------------------------------------------------------------
157
  42    borja     test runn  10   65536       cluster05 00 00:00:52
158
\end{wideshellverbatim}
159

    
160
You should be able to access the VM (if you configured it with networking and SSH). However, since we requested the VM to run for just a minute, you will soon see the following in the Haizea logs:
161

    
162
\begin{wideshellverbatim}
163
[2009-07-30 18:43:00.04] CLOCK   Waking up to manage resources
164
[2009-07-30 18:43:00.04] CLOCK   Wake-up time recorded as 2009-07-30 18:43:00.00
165
[2009-07-30 18:43:00.05] VMSCHED Stopped VMs for lease 1 on nodes [2]
166
[2009-07-30 18:43:05.07] CLOCK   Going back to sleep. 
167
                                 Waking up at 2009-07-30 18:43:15.00 
168
                                 to handle slot table event.
169

    
170
[2009-07-30 18:43:15.00] CLOCK   Waking up to manage resources
171
[2009-07-30 18:43:15.00] CLOCK   Wake-up time recorded as 2009-07-30 18:43:15.00
172
[2009-07-30 18:43:15.00] VMSCHED Lease 1's VMs have shutdown.
173
[2009-07-30 18:43:15.01] CLOCK   Going back to sleep. 
174
                                 Waking up at 2009-07-30 18:44:15.00 
175
                                 to see if something interesting has happened by then.
176
\end{wideshellverbatim}
177

    
178
\section{The \texttt{HAIZEA} parameter in OpenNebula}
179

    
180
The previous section showed how you can add an \texttt{HAIZEA} parameter to your OpenNebula VM template to request a simple advance reservation. The three Haizea options (\texttt{start}, \texttt{duration}, and \texttt{preemptible}) can take other values:
181

    
182
\begin{itemize}
183
\item \texttt{start}: This option specifies when the VM will start. Valid values are:
184
\begin{itemize}
185
\item \texttt{best\_effort}: The VM will be scheduled as soon as resources are available. If resources are not available right now, the request is put on a queue and it remains there until there are sufficient resources (requests are scheduled on a first-come-first-serve basis).
186
\item \texttt{now}: The VM will be scheduled right now. If resources are not available right now, the request is rejected.
187
\item Exact ISO timestamp: i.e., \texttt{YYYY-MM-DD HH:MM:SS}. The VM must start at exactly that time. If enough resources are not available at that time, the resource is not requested.
188
\item Relative ISO timestamp: For convenience's sake (and also for testing) this provides an easy way of specifying that a VM must start "at T time after the VM is submitted". The format would be \texttt{+HH:MM:SS} (the "\texttt{+}" is not ISO, but is used by Haizea to determine that it is a relative timestamp)
189
\end{itemize}
190
\item \texttt{duration}: The duration of the lease. Possible values are:
191
\begin{itemize}
192
\item \texttt{unlimited}: The lease will run forever, until explicitly stopped
193
\item ISO-formatted time: i.e., \texttt{HH:MM:SS}
194
\end{itemize}
195
\item \texttt{preemptible}: This option can be either yes or no. %TODO: Refer to lease documentation
196
\item \texttt{group}: This option can take on any string value, and allows you to schedule several VMs as a group (or, in Haizea terminology, as a single lease with multiple nodes). All OpenNebula VM templates with the same group name will be considered part of the same lease (i.e., all the VMs will be scheduled in a all-or-nothing fashion: all VMs must be able to start/stop at the same time). Future versions of OpenNebula will automatically manage this option, so users don't have to worry about manually setting this option in multiple VM templates (which can be error-prone). 
197
\end{itemize}
198

    
199
Usually, you will want to use these options to create one of Haizea's supported lease types:
200

    
201
\subsection{Advance reservations}
202

    
203
When you need your VM available at a specific time, this is called an advance reservation, or AR. The VM we used above is an example of an AR:
204

    
205
\begin{wideshellverbatim}
206
HAIZEA = [
207
  start        = "+00:00:30",
208
  duration     = "00:01:00",
209
  preemptible  = "no"
210
]
211
\end{wideshellverbatim}
212

    
213
Of course, instead of specifying that you want your VM to start after a certain amount of time has passed (30 seconds, in this case), you can also specify an exact start time:
214

    
215
\begin{wideshellverbatim}
216
HAIZEA = [
217
  start        = "2008-11-04 11:00:00",
218
  duration     = "03:00:00",
219
  preemptible  = "no"
220
]
221
\end{wideshellverbatim}
222

    
223
NOTE: Haizea currently only supports non-preemptible ARs.
224

    
225
\subsection{Best-effort provisioning}
226

    
227
When you instruct Haizea to determine the start time on a best-effort basis, your request will be allocated resources as soon as they become available. Take into account that your request may be placed on a queue, and you'll have to wait until your turn is up. You can use the \texttt{haizea-list-leases} and \texttt{haizea-show-queue} to check on the state of your lease.
228

    
229
\begin{wideshellverbatim}
230
HAIZEA = [
231
  start        = "best_effort",
232
  duration     = "01:00:00",
233
  preemptible  = "yes"
234
]
235
\end{wideshellverbatim}
236

    
237
A best-effort VM can be preemptible or non-preemptible. If you request a non-preemptible VM, you may still have to wait in the queue until you get your resources but, once you do, no one can take them from you.
238

    
239
\subsection{Immediate provisioning}
240

    
241
Sometimes, you need a VM right now or not at all. In that case, you can set the starting time to \texttt{now}.
242

    
243
\begin{wideshellverbatim}
244
HAIZEA = [
245
  start        = "now",
246
  duration     = "unlimited",
247
  preemptible  = "no"
248
]
249
\end{wideshellverbatim}
250

    
251
\section{Additional OpenNebula configuration options}
252

    
253
When running Haizea with OpenNebula, you must specify at least the \texttt{host} option in the \texttt{[opennebula]} section of the configuration file. However, there are additional options in other sections that you can tweak:
254

    
255
\subsection{Wakeup interval}
256

    
257
This is the interval, in seconds, at which Haizea will wake up to process pending requests in OpenNebula. The default is 60 seconds.
258

    
259
\begin{wideshellverbatim}
260
[scheduling]
261
...
262
wakeup-interval: 60
263
...
264
\end{wideshellverbatim}
265

    
266
\subsection{Suspend/resume rate interval}
267

    
268
This option provides Haizea with an estimate of how long it takes for OpenNebula to suspend or resume a virtual machine. This is estimated in MB per second, and is largely dependent on the disk read/write transfer speeds on your system (so, if a VM has 1024 MB of memory, and the suspend rate is estimated to be 64MB/s, Haizea will estimate that suspension will take 16 seconds). If you do not specify a value, Haizea will conservatively assume a rate of 32MB/s. A good estimate will allow Haizea to more correctly schedule resources, but an incorrect estimate will not result in an error (although a warning will be noted in the logs).
269

    
270
\begin{wideshellverbatim}
271
[scheduling]
272
...
273
suspend-rate: 32
274
resume-rate: 32
275
...
276
\end{wideshellverbatim}
277

    
278
Additionally, since OpenNebula currently only supports suspending to a global filesystem (i.e., the RAM file created when suspending a VM is saved to a global filesystem, such as an NFS drive), you will need to specify that suspensions and resumptions must be globally exclusive (to make sure that no more than one RAM file is being saved to the global filesystem at any one time). You can control this using the \texttt{suspendresume-exclusion} option in the \texttt{[scheduling]} section:
279

    
280
\begin{wideshellverbatim}
281
[scheduling]
282
...
283
suspendresume-exclusion: global
284
...
285
\end{wideshellverbatim}
286

    
287
This option is set to \texttt{global} in the sample OpenNebula configuration file, but defaults to \texttt{local} when not specified.
288

    
289
\subsection{Non-schedulable interval}
290

    
291
The minimum amount of time that must pass between when a request is scheduled to when it can actually start (i.e., this makes sure that the scheduling function doesn't make reservations with starting times that will be in the past by the time the scheduling function ends). The default (10 seconds) should be good for most configurations, but may need to be increased if you're dealing with exceptionally high loads.
292

    
293
\begin{wideshellverbatim}
294
[scheduling]
295
...
296
non-schedulable-interval: 10
297
...
298
\end{wideshellverbatim}
299

    
300
\section{Known issues and limitations}
301

    
302
The following are known issues and limitations when using Haizea with OpenNebula:
303

    
304
\begin{itemize}
305
\item As pointed out in this guide, Haizea has to poll OpenNebula every minute to ask if there are any new requests.  Although OpenNebula 1.4 added a ``hook mechanism'' that allows actions to be carried out when certain events happen (such as sending Haizea notifications of a VM that has died, a suspend operation that finished before expected, etc.), Haizea currently does not use this hook mechanism.
306
\item Haizea currently cannot do any image deployment with OpenNebula, and VM images are assumed to be predeployed on the physical nodes, or available on a shared NFS filesystem. Although OpenNebula includes support for interfacing with a \emph{transfer manager} to handle various VM deployment scenarios, Haizea currently does not access this functionality.
307
\item Haizea cannot enact cold migrations in OpenNebula (i.e., migrating a suspended VM to a different node if resources become available earlier on a different node than the one where the VM was suspended on). Haizea actually has all the scheduling code for this, and only the enactment "glue" is missing.
308
\end{itemize}