Statistics
| Branch: | Tag: | Revision:

root / docs / quick-install-admin-guide.rst @ a96ec00f

History | View | Annotate | Download (20.3 kB)

1
.. _quick-install-admin-guide:
2

    
3
Administrator's Quick Installation Guide
4
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5

    
6
This is the Administrator's quick installation guide.
7

    
8
It describes how to install the whole synnefo stack on two (2) physical nodes,
9
with minimum configuration. It installs synnefo from Debian packages, and
10
assumes the nodes run Debian Squeeze. After successful installation, you will
11
have the following services running:
12

    
13
 * Identity Management (Astakos)
14
 * File Storage Service (Pithos+)
15
 * Compute Service (Cyclades)
16
 * Image Registry Service (Plankton)
17

    
18
and a single unified Web UI to manage them all.
19

    
20
The Volume Storage Service (Archipelago) and the Billing Service (Aquarium) are
21
not released yet.
22

    
23
If you just want to install the File Storage Service (Pithos+), follow the guide
24
and just stop after the "Testing of Pithos+" section.
25

    
26

    
27
Installation of Synnefo / Introduction
28
======================================
29

    
30
We will install the services with the above list's order. Cyclades and Plankton
31
will be installed in a single step (at the end), because at the moment they are
32
contained in the same software component. Furthermore, we will install all
33
services in the first physical node, except Pithos+ which will be installed in
34
the second, due to a conflict between the snf-pithos-app and snf-cyclades-app
35
component (scheduled to be fixed in the next version).
36

    
37
For the rest of the documentation we will refer to the first physical node as
38
"node1" and the second as "node2". We will also assume that their domain names
39
are "node1.example.com" and "node2.example.com" and their IPs are "4.3.2.1" and
40
"4.3.2.2" respectively.
41

    
42

    
43
General Prerequisites
44
=====================
45

    
46
These are the general synnefo prerequisites, that you need on node1 and node2
47
and are related to all the services (Astakos, Pithos+, Cyclades, Plankton).
48

    
49
To be able to download all synnefo components you need to add the following
50
lines in your ``/etc/apt/sources.list`` file:
51

    
52
| ``deb http://apt.dev.grnet.gr squeeze main``
53
| ``deb-src http://apt.dev.grnet.gr squeeze main``
54

    
55
| ``deb http://apt.noc.grnet.gr experimental main``
56
| ``deb-src http://apt.noc.grnet.gr experimental main``
57

    
58
| ``deb http://apt.noc.grnet.gr squeeze backports``
59
| ``deb-src http://apt.noc.grnet.gr squeeze backports``
60

    
61
You also need a shared directory visible by both nodes. Pithos+ will save all
62
data inside this directory. By 'all data', we mean files, images, and pithos
63
specific mapping data. If you plan to upload more than one basic image, this
64
directory should have at least 50GB of free space. During this guide, we will
65
assume that node1 acts as an NFS server and serves the directory ``/srv/pithos``
66
to node2. Node2 has this directory mounted under ``/srv/pithos``, too.
67

    
68
Before starting the synnefo installation, you will need basic third party
69
software to be installed and configured on the physical nodes. We will describe
70
each node's general prerequisites separately. Any additional configuration,
71
specific to a synnefo service for each node, will be described at the service's
72
section.
73

    
74
Node1
75
-----
76

    
77
General Synnefo dependencies
78
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79

    
80
 * apache (http server)
81
 * gunicorn (WSGI http server)
82
 * postgresql (database)
83
 * rabbitmq (message queue)
84

    
85
You can install the above by running:
86

    
87
.. code-block:: console
88

    
89
   # apt-get install apache2 gunicorn postgresql
90

    
91
Make sure you have installed gunicorn >= v0.12.2. On node1, we will create our
92
databases, so you will also need the python-psycopg2 package:
93

    
94
.. code-block:: console
95

    
96
   # apt-get install python-psycopg2
97

    
98
Database setup
99
~~~~~~~~~~~~~~
100

    
101
On node1, we create a database called ``snf_apps``, that will host all django
102
apps related tables. We also create the user ``synnefo`` and grant him all
103
privileges on the database. We do this by running:
104

    
105
.. code-block:: console
106

    
107
   root@node1:~ # su - postgres
108
   postgres@node1:~ $ psql
109
   postgres=# CREATE DATABASE snf_apps WITH ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' TEMPLATE=template0;
110
   postgres=# CREATE USER synnefo WITH PASSWORD 'example_passw0rd';
111
   postgres=# GRANT ALL PRIVILEGES ON DATABASE snf_apps TO synnefo;
112

    
113
We also create the database ``snf_pithos`` needed by the pithos+ backend and
114
grant the ``synnefo`` user all privileges on the database. This database could
115
be created on node2 instead, but we do it on node1 for simplicity. We will
116
create all needed databases on node1 and then node2 will connect to them.
117

    
118
.. code-block:: console
119

    
120
   postgres=# CREATE DATABASE snf_pithos WITH ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C'
121
   postgres=# GRANT ALL PRIVILEGES ON DATABASE snf_pithos TO synnefo;
122

    
123
Configure the database to listen to all network interfaces. You can do this by
124
editting the file ``/etc/postgresql/8.4/main/postgresql.conf`` and change
125
``listen_addresses`` to ``'*'`` :
126

    
127
.. code-block:: console
128

    
129
   listen_addresses = '*'
130

    
131
Furthermore, edit ``/etc/postgresql/8.4/main/pg_hba.conf`` to allow node1 and
132
node2 to connect to the database. Add the following lines under ``#IPv4 local
133
connections:`` :
134

    
135
.. code-block:: console
136

    
137
   host		all	all	4.3.2.1/32	md5
138
   host		all	all	4.3.2.2/32	md5
139

    
140
Make sure to substitute "4.3.2.1" and "4.3.2.2" with node1's and node2's
141
actual IPs. Now, restart the server to apply the changes:
142

    
143
.. code-block:: console
144

    
145
   # /etc/init.d/postgresql restart
146

    
147
Gunicorn setup
148
~~~~~~~~~~~~~~
149

    
150
Create the file ``synnefo`` under ``/etc/gunicorn.d/`` containing the following:
151

    
152
.. code-block:: console
153

    
154
   CONFIG = {
155
    'mode': 'django',
156
    'environment': {
157
      'DJANGO_SETTINGS_MODULE': 'synnefo.settings',
158
    },
159
    'working_dir': '/etc/synnefo',
160
    'user': 'www-data',
161
    'group': 'www-data',
162
    'args': (
163
      '--bind=127.0.0.1:8080',
164
      '--workers=4',
165
      '--log-level=debug',
166
    ),
167
   }
168

    
169
!!! Warning: Do NOT start the server yet, because it won't find the
170
``synnefo.settings`` module. We will start the server after successful
171
installation of astakos. If the server is running:
172

    
173
.. code-block:: console
174

    
175
   # /etc/init.d/gunicorn stop
176

    
177
Apache2 setup
178
~~~~~~~~~~~~~
179

    
180
Create the file ``synnefo`` under ``/etc/apache2/sites-available/`` containing
181
the following:
182

    
183
.. code-block:: console
184

    
185
   <VirtualHost *:80>
186
     ServerName node1.example.com
187

    
188
     RewriteEngine On
189
     RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
190
   </VirtualHost>
191

    
192
Create the file ``synnefo-ssl`` under ``/etc/apache2/sites-available/``
193
containing the following:
194

    
195
.. code-block:: console
196

    
197
   <IfModule mod_ssl.c>
198
   <VirtualHost _default_:443>
199
     ServerName node1.example.com
200

    
201
     Alias /static "/usr/share/synnefo/static"
202

    
203
   #  SetEnv no-gzip
204
   #  SetEnv dont-vary
205

    
206
     RequestHeader set X-Forwarded-Protocol "https"
207

    
208
     <Proxy * >
209
       Order allow,deny
210
       Allow from all
211
     </Proxy>
212

    
213
     SetEnv                proxy-sendchunked
214
     SSLProxyEngine        off
215
     ProxyErrorOverride    off
216

    
217
     ProxyPass        /static !
218
     ProxyPass        / http://localhost:8080/ retry=0
219
     ProxyPassReverse / http://localhost:8080/
220

    
221
     RewriteEngine On
222
     RewriteRule ^/login(.*) /im/login/redirect$1 [PT,NE]
223

    
224
     SSLEngine on
225
     SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
226
     SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
227
   </VirtualHost>
228
   </IfModule>
229

    
230
Now enable sites and modules by running:
231

    
232
.. code-block:: console
233

    
234
   # a2enmod ssl
235
   # a2enmod rewrite
236
   # a2dissite default
237
   # a2ensite synnefo
238
   # a2ensite synnefo-ssl
239
   # a2enmod headers
240
   # a2enmod proxy_http
241

    
242
!!! Warning: Do NOT start/restart the server yet. If the server is running:
243

    
244
.. code-block:: console
245

    
246
   # /etc/init.d/apache2 stop
247

    
248
Pithos+ data directory setup
249
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
250

    
251
As mentioned in the General Prerequisites section, there is a directory called
252
``/srv/pithos`` visible by both nodes. We create and setup the ``data``
253
directory inside it:
254

    
255
.. code-block:: console
256

    
257
   # cd /srv/pithos
258
   # mkdir data
259
   # chown www-data:www-data data
260
   # chmod g+ws data
261

    
262
You are now ready with all general prerequisites concerning node1. Let's go to
263
node2.
264

    
265
Node2
266
-----
267

    
268
General Synnefo dependencies
269
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270

    
271
 * apache (http server)
272
 * gunicorn (WSGI http server)
273
 * postgresql (database)
274
 * rabbitmq (message queue)
275

    
276
You can install the above by running:
277

    
278
.. code-block:: console
279

    
280
   # apt-get install apache2 gunicorn postgresql
281

    
282
Make sure you have installed the same package versions as in node1. Node2 will
283
connect to the databases on node1, so you will also need the python-psycopg2
284
package:
285

    
286
.. code-block:: console
287

    
288
   # apt-get install python-psycopg2
289

    
290
Database setup
291
~~~~~~~~~~~~~~
292

    
293
All databases have been created and setup on node1, so we do not need to take
294
any action here. From node2, we will just connect to them. When you get familiar
295
with the software you may choose to run different databases on different nodes,
296
for performance/scalability/redundancy reasons, but those kind of setups are out
297
of the purpose of this guide.
298

    
299
Gunicorn setup
300
~~~~~~~~~~~~~~
301

    
302
Create the file ``synnefo`` under ``/etc/gunicorn.d/`` containing the following
303
(same contents as in node1; you can just copy/paste the file):
304

    
305
.. code-block:: console
306

    
307
   CONFIG = {
308
    'mode': 'django',
309
    'environment': {
310
      'DJANGO_SETTINGS_MODULE': 'synnefo.settings',
311
    },
312
    'working_dir': '/etc/synnefo',
313
    'user': 'www-data',
314
    'group': 'www-data',
315
    'args': (
316
      '--bind=127.0.0.1:8080',
317
      '--workers=4',
318
      '--log-level=debug',
319
    ),
320
   }
321

    
322
!!! Warning: Do NOT start the server yet, because it won't find the
323
``synnefo.settings`` module. We will start the server after successful
324
installation of astakos. If the server is running:
325

    
326
.. code-block:: console
327

    
328
   # /etc/init.d/gunicorn stop
329

    
330
Apache2 setup
331
~~~~~~~~~~~~~
332

    
333
Create the file ``synnefo`` under ``/etc/apache2/sites-available/`` containing
334
the following:
335

    
336
.. code-block:: console
337

    
338
   <VirtualHost *:80>
339
     ServerName node2.example.com
340

    
341
     RewriteEngine On
342
     RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
343
   </VirtualHost>
344

    
345
Create the file ``synnefo-ssl`` under ``/etc/apache2/sites-available/``
346
containing the following:
347

    
348
.. code-block:: console
349

    
350
   <IfModule mod_ssl.c>
351
   <VirtualHost _default_:443>
352
     ServerName node2.example.com
353

    
354
     Alias /static "/usr/share/synnefo/static"
355

    
356
     SetEnv no-gzip
357
     SetEnv dont-vary
358

    
359
     RequestHeader set X-Forwarded-Protocol "https"
360

    
361
     <Proxy * >
362
       Order allow,deny
363
       Allow from all
364
     </Proxy>
365

    
366
     SetEnv                proxy-sendchunked
367
     SSLProxyEngine        off
368
     ProxyErrorOverride    off
369

    
370
     ProxyPass        /static !
371
     ProxyPass        / http://localhost:8080/ retry=0
372
     ProxyPassReverse / http://localhost:8080/
373

    
374
     SSLEngine on
375
     SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
376
     SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
377
   </VirtualHost>
378
   </IfModule>
379

    
380
As in node1, enable sites and modules by running:
381

    
382
.. code-block:: console
383

    
384
   # a2enmod ssl
385
   # a2enmod rewrite
386
   # a2dissite default
387
   # a2ensite synnefo
388
   # a2ensite synnefo-ssl
389
   # a2enmod headers
390
   # a2enmod proxy_http
391

    
392
!!! Warning: Do NOT start/restart the server yet. If the server is running:
393

    
394
.. code-block:: console
395

    
396
   # /etc/init.d/apache2 stop
397

    
398
We are now ready with all general prerequisites for node2. Now that we have
399
finished with all general prerequisites for both nodes, we can start installing
400
the services. First, let's install Astakos on node1.
401

    
402

    
403
Installation of Astakos on node1
404
================================
405

    
406
To install astakos, grab the package from our repository (make sure  you made
407
the additions needed in your ``/etc/apt/sources.list`` file, as described
408
previously), by running:
409

    
410
.. code-block:: console
411

    
412
   # apt-get install snf-astakos-app
413

    
414
After successful installation of snf-astakos-app, make sure that also
415
snf-webproject has been installed (marked as "Recommended" package). By default
416
Debian installs "Recommended" packages, but if you have changed your
417
configuration and the package didn't install automatically, you should
418
explicitly install it manually running:
419

    
420
.. code-block:: console
421

    
422
   # apt-get install snf-webproject
423

    
424
The reason snf-webproject is "Recommended" and not a hard dependency, is to give
425
the experienced administrator the ability to install synnefo in a custom made
426
django project. This corner case concerns only very advanced users that know
427
what they are doing and want to experiment with synnefo.
428

    
429

    
430
Configuration of Astakos
431
========================
432

    
433
Conf Files
434
----------
435

    
436
After astakos is successfully installed, you will find the directory
437
``/etc/synnefo`` and some configuration files inside it. The files contain
438
commented configuration options, which are the default options. While installing
439
new snf-* components, new configuration files will appear inside the directory.
440
In this guide (and for all services), we will edit only the minimum necessary
441
configuration options, to reflect our setup. Everything else will remain as is.
442

    
443
After getting familiar with synnefo, you will be able to customize the software
444
as you wish and fits your needs. Many options are available, to empower the
445
administrator with extensively customizable setups.
446

    
447
For the snf-webproject component (installed as an astakos dependency), we
448
need the following:
449

    
450
Edit ``/etc/synnefo/10-snf-webproject-database.conf``. You will need to
451
uncomment and edit the ``DATABASES`` block to reflect our database:
452

    
453
.. code-block:: console
454

    
455
   DATABASES = {
456
    'default': {
457
        # 'postgresql_psycopg2', 'postgresql','mysql', 'sqlite3' or 'oracle'
458
        'ENGINE': 'postgresql_psycopg2',
459
         # ATTENTION: This *must* be the absolute path if using sqlite3.
460
         # See: http://docs.djangoproject.com/en/dev/ref/settings/#name
461
        'NAME': 'snf_apps',
462
        'USER': 'synnefo',                      # Not used with sqlite3.
463
        'PASSWORD': 'examle_passw0rd',          # Not used with sqlite3.
464
        # Set to empty string for localhost. Not used with sqlite3.
465
        'HOST': '4.3.2.1',
466
        # Set to empty string for default. Not used with sqlite3.
467
        'PORT': '5432',
468
    }
469
   }
470

    
471
Edit ``/etc/synnefo/10-snf-webproject-deploy.conf``. Uncomment and edit
472
``SECRET_KEY``. This is a django specific setting which is used to provide a
473
seed in secret-key hashing algorithms. Set this to a random string of your
474
choise and keep it private:
475

    
476
.. code-block:: console
477

    
478
   SECRET_KEY = 'sy6)mw6a7x%n)-example_secret_key#zzk4jo6f2=uqu!1o%)'
479

    
480
For astakos specific configuration, edit the following options in
481
``/etc/synnefo/20-snf-astakos-setting.conf`` :
482

    
483
.. code-block:: console
484

    
485
   ASTAKOS_IM_MODULES = ['local']
486

    
487
   ASTAKOS_COOKIE_DOMAIN = '.example.com'
488

    
489
   ASTAKOS_BASEURL = 'https://node1.example.com'
490

    
491
   ASTAKOS_SITENAME = '~okeanos demo example'
492

    
493
   ASTAKOS_CLOUD_SERVICES = (
494
           { 'url':'https://node1.example.com/im/', 'name':'~okeanos home', 'id':'cloud', 'icon':'home-icon.png' },
495
           { 'url':'https://node1.example.com/ui/', 'name':'cyclades', 'id':'cyclades' },
496
           { 'url':'https://node2.example.com/ui/', 'name':'pithos+', 'id':'pithos' })
497

    
498
   ASTAKOS_RECAPTCHA_PUBLIC_KEY = 'example_recaptcha_public_key!@#$%^&*('
499
   ASTAKOS_RECAPTCHA_PRIVATE_KEY = 'example_recaptcha_private_key!@#$%^&*('
500

    
501
   ASTAKOS_RECAPTCHA_USE_SSL = True
502

    
503
``ASTAKOS_IM_MODULES`` refers to the astakos login methods. For now only local
504
is supported. The ``ASTAKOS_COOKIE_DOMAIN`` should be the base url of our
505
domain (for all services). ``ASTAKOS_BASEURL`` is the astakos home page.
506
``ASTAKOS_CLOUD_SERVICES`` contains all services visible to and served by
507
astakos. The first element of the dictionary is used to point to a generic
508
landing page for your services (cyclades, pithos). If you don't have such a
509
page it can be omitted. The second and third element point to our services
510
themselves (the apps) and should be set as above.
511

    
512
For the ``ASTAKOS_RECAPTCHA_PUBLIC_KEY`` and ``ASTAKOS_RECAPTCHA_PRIVATE_KEY``
513
go to https://www.google.com/recaptcha/admin/create and create your own pair.
514

    
515
Servers Initialization
516
----------------------
517

    
518
After configuration is done, we initialize the servers on node1:
519

    
520
.. code-block:: console
521

    
522
   root@node1:~ # /etc/init.d/gunicorn restart
523
   root@node1:~ # /etc/init.d/apache2 restart
524

    
525
Database Initialization
526
-----------------------
527

    
528
Then, we initialize the database by running:
529

    
530
.. code-block:: console
531

    
532
   # snf-manage syncdb
533

    
534
At this example we don't need to create a django superuser, so we select
535
``[no]`` to the question. After a successful sync, we run the migration needed
536
for astakos:
537

    
538
.. code-block:: console
539

    
540
   # snf-manage migrate im
541

    
542
You have now finished the Astakos setup. Let's test it now.
543

    
544

    
545
Testing of Astakos
546
==================
547

    
548
Open your favorite browser and go to:
549

    
550
``http://node1.example.com/im``
551

    
552
If this redirects you to ``https://node1.example.com/im`` and you can see
553
the "welcome" door of Astakos, then you have successfully setup Astakos.
554

    
555
Let's create our first user. At the homepage click the "CREATE ACCOUNT" button
556
and fill all your data at the sign up form. Then click "SUBMIT". You should now
557
see a green box on the top, which informs you that you made a successful request
558
and the request has been sent to the administrators. So far so good.
559

    
560
Now we need to activate that user. Return to a command prompt at node1 and run:
561

    
562
.. code-block:: console
563

    
564
   root@node1:~ # snf-manage listusers
565

    
566
This command should show you a list with only one user; the one we just created.
567
This user should have an id with a value of ``1``. It should also have an
568
"active" status with the value of ``0`` (inactive). Now run:
569

    
570
.. code-block:: console
571

    
572
   root@node1:~ # snf-manage modifyuser --set-active 1
573

    
574
This modifies the active value to ``1``, and actually activates the user.
575
When running in production, the activation is done automatically with different
576
types of moderation, that Astakos supports. You can see the moderation methods
577
(by invitation, whitelists, matching regexp, etc.) at the Astakos specific
578
documentation.
579

    
580
Now let's go back to the homepage. Open ``http://node1.example.com/im`` with
581
your browser again. Try to sign in using your new credentials. If the astakos
582
menu appears and you can see your profile, then you have successfully setup
583
Astakos.
584

    
585
Let's continue to install Pithos+ now.
586

    
587

    
588
Installation of Pithos+ on node2
589
================================
590

    
591
To install pithos+, grab the package from our repository (make sure  you made
592
the additions needed in your ``/etc/apt/sources.list`` file, as described
593
previously), by running:
594

    
595
.. code-block:: console
596

    
597
   # apt-get install snf-pithos-app
598

    
599
After successful installation of snf-pithos-app, make sure that also
600
snf-webproject has been installed (marked as "Recommended" package). Refer to
601
the "Installation of Astakos on node1" section, if you don't remember why this
602
should happen. 
603

    
604

    
605
Configuration of Pithos+
606
========================
607

    
608
Conf Files
609
----------
610

    
611
After pithos+ is successfully installed, you will find the directory
612
``/etc/synnefo`` and some configuration files inside it, as you did in node1
613
after installation of astakos. Here, you will not have to change anything that
614
has to do with snf-common or snf-webproject. Everything is set at node1. You
615
only need to change settings that have to do with pithos. Specifically:
616

    
617
Edit ``/etc/synnefo/20-snf-pithos-app-settings.conf``. There you need to set
618
only the two options:
619

    
620
.. code-block:: console
621

    
622
   PITHOS_BACKEND_DB_CONNECTION = 'postgresql://synnefo:example_passw0rd@node1.example.com:5432/snf_pithos'
623

    
624
   PITHOS_BACKEND_BLOCK_PATH = '/srv/pithos/data'
625

    
626
The ``PITHOS_BACKEND_DB_CONNECTION`` option tells to the pithos+ backend where
627
to find its database. Above we tell pithos+ that its database is ``snf_pithos``
628
at node1 and to connect as user ``synnefo`` with password ``example_passw0rd``.
629
All those settings where setup during node1's "Database setup" section.
630

    
631
The ``PITHOS_BACKEND_BLOCK_PATH`` option tells to the pithos+ backend where to
632
store its data. Above we tell pithos+ to store its data under
633
``/srv/pithos/data``, which is visible by both nodes. We have already setup this
634
directory at node1's "Pithos+ data directory setup" section.
635

    
636
Servers Initialization
637
----------------------
638

    
639
After configuration is done, we initialize the servers on node2:
640

    
641
.. code-block:: console
642

    
643
   root@node2:~ # /etc/init.d/gunicorn restart
644
   root@node2:~ # /etc/init.d/apache2 restart
645

    
646

    
647
You have now finished the Pithos+ setup. Let's test it now.
648

    
649

    
650
Testing of Pithos+
651
==================
652

    
653

    
654
Installation of Cyclades (and Plankton) on node1
655
================================================
656

    
657

    
658
Configuration of Cyclades (and Plankton)
659
========================================
660

    
661

    
662
Testing of Cyclades (and Plankton)
663
==================================
664

    
665

    
666
General Testing
667
===============
668

    
669

    
670
Notes
671
=====