regenerate
[myplc.git] / doc / myplc.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
4   <!ENTITY Variables SYSTEM "variables.xml">
5 ]>
6 <article>
7   <articleinfo>
8     <title>MyPLC User's Guide</title>
9
10     <author>
11       <firstname>Mark Huang</firstname>
12     </author>
13
14     <affiliation>
15       <orgname>Princeton University</orgname>
16     </affiliation>
17
18     <abstract>
19       <para>This document describes the design, installation, and
20       administration of MyPLC, a complete PlanetLab Central (PLC)
21       portable installation contained within a
22       <command>chroot</command> jail. This document assumes advanced
23       knowledge of the PlanetLab architecture and Linux system
24       administration.</para>
25     </abstract>
26
27     <revhistory>
28       <revision>
29         <revnumber>1.0</revnumber>
30
31         <date>April 7, 2006</date>
32
33         <authorinitials>MLH</authorinitials>
34
35         <revdescription>
36           <para>Initial draft.</para>
37         </revdescription>
38       </revision>
39     </revhistory>
40   </articleinfo>
41
42   <section>
43     <title>Overview</title>
44
45     <para>MyPLC is a complete PlanetLab Central (PLC) portable
46     installation contained within a <command>chroot</command>
47     jail. The default installation consists of a web server, an
48     XML-RPC API server, a boot server, and a database server: the core
49     components of PLC. The installation is customized through an
50     easy-to-use graphical interface. All PLC services are started up
51     and shut down through a single script installed on the host
52     system. The usually complex process of installing and
53     administering the PlanetLab backend is reduced by containing PLC
54     services within a virtual filesystem. By packaging it in such a
55     manner, MyPLC may also be run on any modern Linux distribution,
56     and could conceivably even run in a PlanetLab slice.</para>
57
58     <figure id="Architecture">
59       <title>MyPLC architecture</title>
60       <mediaobject>
61         <imageobject>
62           <imagedata fileref="architecture.eps" format="EPS" align="center" scale="50" />
63         </imageobject>
64         <imageobject>
65           <imagedata fileref="architecture.png" format="PNG" align="center" scale="50" />
66         </imageobject>
67         <textobject>
68           <phrase>MyPLC architecture</phrase>
69         </textobject>
70         <caption>
71           <para>MyPLC should be viewed as a single application that
72           provides multiple functions and can run on any host
73           system.</para>
74         </caption>
75       </mediaobject>
76     </figure>
77   </section>
78
79   <section>
80     <title>Installation</title>
81
82     <para>Though internally composed of commodity software
83     subpackages, MyPLC should be treated as a monolithic software
84     application. MyPLC is distributed as single RPM package that has
85     no external dependencies, allowing it to be installed on
86     practically any Linux 2.6 based distribution:</para>
87
88     <example>
89       <title>Installing MyPLC.</title>
90
91         <programlisting><![CDATA[# If your distribution supports RPM
92 rpm -U myplc-0.3-1.planetlab.i386.rpm
93
94 # If your distribution does not support RPM
95 cd /
96 rpm2cpio myplc-0.3-1.planetlab.i386.rpm | cpio -diu]]></programlisting>
97     </example>
98
99     <para>MyPLC installs the following files and directories:</para>
100
101     <itemizedlist>
102
103       <listitem><para><filename>/plc/root.img</filename>: The main
104       root filesystem of the MyPLC application. This file is an
105       uncompressed ext3 filesystem that is loopback mounted on
106       <filename>/plc/root</filename> when MyPLC starts. The
107       filesystem, even when mounted, should be treated an opaque
108       binary that can and will be replaced in its entirety by any
109       upgrade of MyPLC.</para></listitem>
110
111       <listitem><para><filename>/plc/root</filename>: The mount point
112       for <filename>/plc/root.img</filename>. Once the root filesystem
113       is mounted, all MyPLC services run in a
114       <command>chroot</command> jail based in this
115       directory.</para></listitem>
116
117       <listitem>
118         <para><filename>/plc/data</filename>: The directory where user
119         data and generated files are stored. This directory is bind
120         mounted into the <command>chroot</command> jail on
121         <filename>/data</filename>. Files in this directory are marked
122         with <command>%config(noreplace)</command> in the RPM. That
123         is, during an upgrade of MyPLC, if a file has not changed
124         since the last installation or upgrade of MyPLC, it is subject
125         to upgrade and replacement. If the file has chanegd, the new
126         version of the file will be created with a
127         <filename>.rpmnew</filename> extension. Symlinks within the
128         MyPLC root filesystem ensure that the following directories
129         (relative to <filename>/plc/root</filename>) are stored
130         outside the MyPLC filesystem image:</para>
131
132         <itemizedlist>
133           <listitem><para><filename>/etc/planetlab</filename>: This
134           directory contains the configuration files, keys, and
135           certificates that define your MyPLC
136           installation.</para></listitem>
137
138           <listitem><para><filename>/var/lib/pgsql</filename>: This
139           directory contains PostgreSQL database
140           files.</para></listitem>
141
142           <listitem><para><filename>/var/www/html/alpina-logs</filename>: This
143           directory contains node installation logs.</para></listitem>
144
145           <listitem><para><filename>/var/www/html/boot</filename>: This
146           directory contains the Boot Manager, customized for your MyPLC
147           installation, and its data files.</para></listitem>
148
149           <listitem><para><filename>/var/www/html/download</filename>: This
150           directory contains Boot CD images, customized for your MyPLC
151           installation.</para></listitem>
152
153           <listitem><para><filename>/var/www/html/install-rpms</filename>: This
154           directory is where you should install node package updates,
155           if any. By default, nodes are installed from the tarball
156           located at
157           <filename>/var/www/html/boot/PlanetLab-Bootstrap.tar.bz2</filename>,
158           which is pre-built from the latest PlanetLab Central
159           sources, and installed as part of your MyPLC
160           installation. However, nodes will attempt to install any
161           newer RPMs located in
162           <filename>/var/www/html/install-rpms/planetlab</filename>,
163           after initial installation and periodically thereafter. You
164           must run <command>yum-arch</command> and
165           <command>createrepo</command> to update the
166           <command>yum</command> caches in this directory after
167           installing a new RPM. PlanetLab Central cannot support any
168           changes to this directory.</para></listitem>
169
170           <listitem><para><filename>/var/www/html/xml</filename>: This
171           directory contains various XML files that the Slice Creation
172           Service uses to determine the state of slices. These XML
173           files are refreshed periodically by <command>cron</command>
174           jobs running in the MyPLC root.</para></listitem>
175         </itemizedlist>
176       </listitem>
177
178       <listitem>
179         <para><filename>/etc/init.d/plc</filename>: This file
180         is a System V init script installed on your host filesystem,
181         that allows you to start up and shut down MyPLC with a single
182         command. On a Red Hat or Fedora host system, it is customary to
183         use the <command>service</command> command to invoke System V
184         init scripts:</para>
185
186         <example id="StartingAndStoppingMyPLC">
187           <title>Starting and stopping MyPLC.</title>
188
189           <programlisting><![CDATA[# Starting MyPLC
190 service plc start
191
192 # Stopping MyPLC
193 service plc stop]]></programlisting>
194         </example>
195
196         <para>Like all other registered System V init services, MyPLC is
197         started and shut down automatically when your host system boots
198         and powers off. You may disable automatic startup by invoking
199         the <command>chkconfig</command> command on a Red Hat or Fedora
200         host system:</para>
201
202         <example>
203           <title>Disabling automatic startup of MyPLC.</title>
204
205           <programlisting><![CDATA[# Disable automatic startup
206 chkconfig plc off
207
208 # Enable automatic startup
209 chkconfig plc on]]></programlisting>
210         </example>
211       </listitem>
212
213       <listitem><para><filename>/etc/sysconfig/plc</filename>: This
214       file is a shell script fragment that defines the variables
215       <envar>PLC_ROOT</envar> and <envar>PLC_DATA</envar>. By default,
216       the values of these variables are <filename>/plc/root</filename>
217       and <filename>/plc/data</filename>, respectively. If you wish,
218       you may move your MyPLC installation to another location on your
219       host filesystem and edit the values of these variables
220       appropriately, but you will break the RPM upgrade
221       process. PlanetLab Central cannot support any changes to this
222       file.</para></listitem>
223
224       <listitem><para><filename>/etc/planetlab</filename>: This
225       symlink to <filename>/plc/data/etc/planetlab</filename> is
226       installed on the host system for convenience.</para></listitem>
227     </itemizedlist>
228   </section>
229
230   <section>
231     <title>Quickstart</title>
232
233     <para>Once installed, start MyPLC (see <xref
234     linkend="StartingAndStoppingMyPLC" />). MyPLC must be started as
235     root. Observe the output of this command for any failures. If no
236     failures occur, you should see output similar to the
237     following:</para>
238
239     <example>
240       <title>A successful MyPLC startup.</title>
241
242       <programlisting><![CDATA[Mounting PLC:                                              [  OK  ]
243 PLC: Generating network files:                             [  OK  ]
244 PLC: Starting system logger:                               [  OK  ]
245 PLC: Starting database server:                             [  OK  ]
246 PLC: Generating SSL certificates:                          [  OK  ]
247 PLC: Generating SSH keys:                                  [  OK  ]
248 PLC: Starting web server:                                  [  OK  ]
249 PLC: Bootstrapping the database:                           [  OK  ]
250 PLC: Starting DNS server:                                  [  OK  ]
251 PLC: Starting crond:                                       [  OK  ]
252 PLC: Rebuilding Boot CD:                                   [  OK  ]
253 PLC: Rebuilding Boot Manager:                              [  OK  ]
254 PLC: Signing node packages:                                [  OK  ]
255 ]]></programlisting>
256     </example>
257
258     <para>If <filename>/plc/root</filename> is mounted successfully, a
259     complete log file of the startup process may be found at
260     <filename>/plc/root/var/log/boot.log</filename>. Possible reasons
261     for failure of each step include:</para>
262
263     <itemizedlist>
264       <listitem><para><literal>Mounting PLC</literal>: If this step
265       fails, first ensure that you started MyPLC as root. Check
266       <filename>/etc/sysconfig/plc</filename> to ensure that
267       <envar>PLC_ROOT</envar> and <envar>PLC_DATA</envar> refer to the
268       right locations. You may also have too many existing loopback
269       mounts, or your kernel may not support loopback mounting, bind
270       mounting, or the ext3 filesystem. Try freeing at least one
271       loopback device, or re-compiling your kernel to support loopback
272       mounting, bind mounting, and the ext3 filesystem. SELinux may
273       also be enabled. If you install MyPLC on Fedora Core 4 or 5, use
274       the <application>Security Level Configuration</application>
275       utility to configure SELinux to be
276       <literal>Permissive</literal>.</para></listitem>
277
278       <listitem><para><literal>Starting database server</literal>: If
279       this step fails, check
280       <filename>/plc/root/var/log/pgsql</filename> and
281       <filename>/plc/root/var/log/boot.log</filename>. The most common
282       reason for failure is that the default PostgreSQL port, TCP port
283       5432, is already in use. Check that you are not running a
284       PostgreSQL server on the host system.</para></listitem>
285
286       <listitem><para><literal>Starting web server</literal>: If this
287       step fails, check
288       <filename>/plc/root/var/log/httpd/error_log</filename> and
289       <filename>/plc/root/var/log/boot.log</filename> for obvious
290       errors. The most common reason for failure is that the default
291       web ports, TCP ports 80 and 443, are already in use. Check that
292       you are not running a web server on the host
293       system.</para></listitem>
294
295       <listitem><para><literal>Bootstrapping the database</literal>:
296       If this step fails, it is likely that the previous step
297       (<literal>Starting web server</literal>) also failed. Another
298       reason that it could fail is if <envar>PLC_API_HOST</envar> (see
299       <xref linkend="ChangingTheConfiguration" />) does not resolve to
300       the host on which the API server has been enabled. By default,
301       all services, including the API server, are enabled and run on
302       the same host, so check that <envar>PLC_API_HOST</envar> is
303       either <filename>localhost</filename> or resolves to a local IP
304       address.</para></listitem>
305
306       <listitem><para><literal>Starting crond</literal>: If this step
307       fails, it is likely that the previous steps (<literal>Starting
308       web server</literal> and <literal>Bootstrapping the
309       database</literal>) also failed. If not, check
310       <filename>/plc/root/var/log/boot.log</filename> for obvious
311       errors. This step starts the <command>cron</command> service and
312       generates the initial set of XML files that the Slice Creation
313       Service uses to determine slice state.</para></listitem>
314     </itemizedlist>
315
316     <para>If no failures occur, then MyPLC should be active with a
317     default configuration. Open a web browser on the host system and
318     visit <literal>http://localhost/</literal>, which should bring you
319     to the front page of your PLC installation. The password of the
320     default administrator account
321     <literal>root@localhost.localdomain</literal> (set by
322     <envar>PLC_ROOT_USER</envar>) is <literal>root</literal> (set by
323     <envar>PLC_ROOT_PASSWORD</envar>).</para>
324
325     <section id="ChangingTheConfiguration">
326       <title>Changing the configuration</title>
327
328       <para>After verifying that MyPLC is working correctly, shut it
329       down and begin changing some of the default variable
330       values. Shut down MyPLC with <command>service plc stop</command>
331       (see <xref linkend="StartingAndStoppingMyPLC" />). With a text
332       editor, open the file
333       <filename>/etc/planetlab/plc_config.xml</filename>. This file is
334       a self-documenting configuration file written in XML. Variables
335       are divided into categories. Variable identifiers must be
336       alphanumeric, plus underscore. A variable is referred to
337       canonically as the uppercase concatenation of its category
338       identifier, an underscore, and its variable identifier. Thus, a
339       variable with an <literal>id</literal> of
340       <literal>slice_prefix</literal> in the <literal>plc</literal>
341       category is referred to canonically as
342       <envar>PLC_SLICE_PREFIX</envar>.</para>
343
344       <para>The reason for this convention is that during MyPLC
345       startup, <filename>plc_config.xml</filename> is translated into
346       several different languages&mdash;shell, PHP, and
347       Python&mdash;so that scripts written in each of these languages
348       can refer to the same underlying configuration. Most MyPLC
349       scripts are written in shell, so the convention for shell
350       variables predominates.</para>
351
352       <para>The variables that you should change immediately are:</para>
353
354       <itemizedlist>
355         <listitem><para><envar>PLC_NAME</envar>: Change this to the
356         name of your PLC installation.</para></listitem>
357         <listitem><para><envar>PLC_ROOT_PASSWORD</envar>: Change this
358         to a more secure password.</para></listitem>
359
360         <listitem><para><envar>PLC_MAIL_SUPPORT_ADDRESS</envar>:
361         Change this to the e-mail address at which you would like to
362         receive support requests.</para></listitem>
363
364         <listitem><para><envar>PLC_DB_HOST</envar>,
365         <envar>PLC_DB_IP</envar>, <envar>PLC_API_HOST</envar>,
366         <envar>PLC_API_IP</envar>, <envar>PLC_WWW_HOST</envar>,
367         <envar>PLC_WWW_IP</envar>, <envar>PLC_BOOT_HOST</envar>,
368         <envar>PLC_BOOT_IP</envar>: Change all of these to the
369         preferred FQDN and external IP address of your host
370         system.</para></listitem>
371       </itemizedlist>
372
373       <para>After changing these variables, save the file, then
374       restart MyPLC with <command>service plc start</command>. You
375       should notice that the password of the default administrator
376       account is no longer <literal>root</literal>, and that the
377       default site name includes the name of your PLC installation
378       instead of PlanetLab.</para>
379     </section>
380
381     <section>
382       <title>Installing nodes</title>
383
384       <para>Install your first node by clicking <literal>Add
385       Node</literal> under the <literal>Nodes</literal> tab. Fill in
386       all the appropriate details, then click
387       <literal>Add</literal>. Download the node's configuration file
388       by clicking <literal>Download configuration file</literal> on
389       the <emphasis role="bold">Node Details</emphasis> page for the
390       node. Save it to a floppy disk or USB key as detailed in <xref
391       linkend="TechsGuide" />.</para>
392
393       <para>Follow the rest of the instructions in <xref
394       linkend="TechsGuide" /> for creating a Boot CD and installing
395       the node, except download the Boot CD image from the
396       <filename>/download</filename> directory of your PLC
397       installation, not from PlanetLab Central. The images located
398       here are customized for your installation. If you change the
399       hostname of your boot server (<envar>PLC_BOOT_HOST</envar>), or
400       if the SSL certificate of your boot server expires, MyPLC will
401       regenerate it and rebuild the Boot CD with the new
402       certificate. If this occurs, you must replace all Boot CDs
403       created before the certificate was regenerated.</para>
404
405       <para>The installation process for a node has significantly
406       improved since PlanetLab 3.3. It should now take only a few
407       seconds for a new node to become ready to create slices.</para>
408     </section>
409
410     <section>
411       <title>Administering nodes</title>
412
413       <para>You may administer nodes as <literal>root</literal> by
414       using the SSH key stored in
415       <filename>/etc/planetlab/root_ssh_key.rsa</filename>.</para>
416
417       <example>
418         <title>Accessing nodes via SSH. Replace
419         <literal>node</literal> with the hostname of the node.</title>
420
421         <programlisting>ssh -i /etc/planetlab/root_ssh_key.rsa root@node</programlisting>
422       </example>
423
424       <para>Besides the standard Linux log files located in
425       <filename>/var/log</filename>, several other files can give you
426       clues about any problems with active processes:</para>
427
428       <itemizedlist>
429         <listitem><para><filename>/var/log/pl_nm</filename>: The log
430         file for the Node Manager.</para></listitem>
431
432         <listitem><para><filename>/vservers/pl_conf/var/log/pl_conf</filename>:
433         The log file for the Slice Creation Service.</para></listitem>
434
435         <listitem><para><filename>/var/log/propd</filename>: The log
436         file for Proper, the service which allows certain slices to
437         perform certain privileged operations in the root
438         context.</para></listitem>
439
440         <listitem><para><filename>/vservers/pl_netflow/var/log/netflow.log</filename>:
441         The log file for PlanetFlow, the network traffic auditing
442         service.</para></listitem>
443       </itemizedlist>
444     </section>
445
446     <section>
447       <title>Creating a slice</title>
448
449       <para>Create a slice by clicking <literal>Create Slice</literal>
450       under the <literal>Slices</literal> tab. Fill in all the
451       appropriate details, then click <literal>Create</literal>. Add
452       nodes to the slice by clicking <literal>Manage Nodes</literal>
453       on the <emphasis role="bold">Slice Details</emphasis> page for
454       the slice.</para>
455
456       <para>A <command>cron</command> job runs every five minutes and
457       updates the file
458       <filename>/plc/data/var/www/html/xml/slices-0.5.xml</filename>
459       with information about current slice state. The Slice Creation
460       Service running on every node polls this file every ten minutes
461       to determine if it needs to create or delete any slices. You may
462       accelerate this process manually if desired.</para>
463
464       <example>
465         <title>Forcing slice creation on a node.</title>
466
467         <programlisting><![CDATA[# Update slices.xml immediately
468 service plc start crond
469
470 # Kick the Slice Creation Service on a particular node.
471 ssh -i /etc/planetlab/root_ssh_key.rsa root@node \
472 vserver pl_conf exec service pl_conf restart]]></programlisting>
473       </example>
474     </section>
475   </section>
476
477   <appendix>
478     <title>Configuration variables</title>
479
480     <para>Listed below is the set of standard configuration variables
481     and their default values, defined in the template
482     <filename>/etc/planetlab/default_config.xml</filename>. Additional
483     variables and their defaults may be defined in site-specific XML
484     templates that should be placed in
485     <filename>/etc/planetlab/configs/</filename>.</para>
486
487     &Variables;
488   </appendix>
489
490   <bibliography>
491     <title>Bibliography</title>
492
493     <biblioentry id="TechsGuide">
494       <author><firstname>Mark</firstname><surname>Huang</surname></author>
495       <title><ulink
496       url="http://www.planet-lab.org/doc/TechsGuide.php">PlanetLab
497       Technical Contact's Guide</ulink></title>
498     </biblioentry>
499   </bibliography>
500 </article>