Statistics
| Branch: | Tag: | Revision:

root / README.deploy @ 91563fdc

History | View | Annotate | Download (16 kB)

1
README.deploy -- Instructions for a basic deployment of Synnefo v0.5.1
2

    
3
This document describes the basic steps to obtain a basic, working Synnefo
4
deployment. It begins by examining the different node roles, then moves to the
5
installation and setup of distinct software components.
6

    
7
It is current as of Synnefo v0.5.1.
8

    
9

    
10
Node types
11
===========
12

    
13
Nodes in a Synnefo deployment belong in one of the following types:
14

    
15
 * DB:
16
   A node [or more than one nodes, if using an HA configuration], running a DB
17
   engine supported by the Django ORM layer. The DB is the single source of
18
   truth for the servicing of API requests by Synnefo.
19
   Services: PostgreSQL / MySQL
20

    
21
 * APISERVER:
22
   A node running the implementation of the OpenStack API, in Django. Any number
23
   of APISERVERs can be used, in a load-balancing configuration, without any
24
   special consideration. Access to a common DB ensures consistency.
25
   Services: Web server, vncauthproxy
26

    
27
 * QUEUE:
28
   A node running the RabbitMQ software, which provides AMQP functionality. More
29
   than one QUEUE nodes may be deployed, in an HA configuration. Such
30
   deployments require shared storage, provided e.g., by DRBD.
31
   Services: RabbitMQ [rabbitmq-server]
32

    
33
 * LOGIC:
34
   A node running the business logic of Synnefo, in Django. It dequeues
35
   messages from QUEUE nodes, and provides the context in which business logic
36
   functions run. It uses Django ORM to connect to the common DB and update the
37
   state of the system, based on notifications received from the rest of the
38
   infrastructure, over AMQP.
39
   Services: the Synnefo logic dispatcher [/logic/dispatcher.py]
40

    
41
 * GANETI-MASTER and GANETI-NODE:
42
   A single GANETI-MASTER and a large number of GANETI-NODEs constitute the
43
   Ganeti backend for Synnefo, which undertakes all VM management functions.
44
   Any APISERVER can issue commands to the GANETI-MASTER, over RAPI, to effect
45
   changes in the state of the VMs. The GANETI-MASTER runs the Ganeti request
46
   queue.
47
   Services:
48
     only on GANETI-MASTER:
49
       the Synnefo Ganeti monitoring daemon [/ganeti/snf-ganeti-eventd]
50
       the Synnefo Ganeti hook [/ganeti/snf-ganeti-hook.py].
51
     on each GANETI_NODE:
52
       a deployment-specific KVM ifup script
53
       properly configured NFDHCPD
54

    
55

    
56
Installation Process
57
=====================
58

    
59
This section describes the installation process of the various node roles in a
60
Synnefo deployment.
61

    
62

    
63
0. Allocation of physical nodes:
64
   Determine the role of every physical node in your deployment.
65

    
66

    
67
1. Ganeti installation:
68
   Synnefo requires a working Ganeti installation at the backend. Installation
69
   of Ganeti is not covered by this document, please refer to
70
   http://docs.ganeti.org/ganeti/current/html for all the gory details. A
71
   successful Ganeti installation concludes with a working GANETI-MASTER and a
72
   number of GANETI-NODEs.
73

    
74

    
75
2. RabbitMQ installation:
76
   RabbitMQ is used as a generic message broker for the system. It should be
77
   installed on two seperate QUEUE nodes (VMs should be enough for the moment)
78
   in a high availability configuration as described here:
79

    
80
     http://www.rabbitmq.com/pacemaker.html
81

    
82
   After installation, create a user and set its permissions
83
     rabbitmqctl add_user okeanos 0k3@n0s
84
     rabbitmqctl set_permissions -p / okeanos  "^.*" ".*" ".*"
85

    
86
   The values set for the user and password must be mirrored in the
87
   RABBIT_* variables in settings.py (see step 6)
88

    
89

    
90
3. Web server installation:
91
   A Web Server (e.g., Apache) needs to be installed on the APISERVERs,
92
   and be configured to run the Synnefo Django project appropriately. Selection
93
   and configuration of a Web server is outside the scope of this document.
94

    
95
   For testing or development purposes, Django's own development server,
96
   `./manage.py runserver' can be used.
97

    
98

    
99
4. Installation of the Synnefo Django project:
100
   As of v0.5 the Synnefo Django project needs to be installed on nodes
101
   of type APISERVER, LOGIC and on the GANETI-MASTER, with a properly
102
   configured settings.py. In later revisions, the specific parts of the Django
103
   project which need to run on each node type will be identified.
104

    
105
   Synnefo is written in Python 2.6 and depends on the following Python modules:
106
   [package versions confirmed to be compatible are in braces]
107

    
108
    * django 1.2 [Django==1.2.4]
109
    * simplejson [simplejson==2.1.3]
110
    * pycurl [pycurl==7.19.0]
111
    * python-dateutil  [python-dateutil==1.4.1]
112
      WARNING: version python-dateutil==2.0 downloaded by pip known *not* to
113
               work with Python 2.6
114
    * python-ipy [IPy==0.72]
115
    * south [south==0.7.1]
116
      WARNING: might not work with Debian squeeze's default south-0.7-1 package.
117
    * amqplib [amqplib==0.6.1]
118
    * lockfile [lockfile==0.8]
119
    * python-daemon [python-daemon==1.5.5]
120

    
121
   also, depending on the database engine of choice, on one of the following:
122
    * MySQL-python [MySQL-python==1.2.3]
123
    * psycopg2 [psycopg2==2.4]
124

    
125
   if the invitations application is deployed, the following dependencies should
126
   be installed:
127
    * pycrypto==2.1.0
128

    
129
   To run the user interface tests, selenium must be installed
130
    * selenium [?]
131

    
132
   The easiest method for installation of the Django project is to setup a
133
   working environment through virtualenv. Alternatively, you can use your
134
   system's package manager to install the dependencies (e.g. Macports has them
135
   all).
136

    
137
   * On Snow Leopard and linux (64-bit), you have to set the following
138
     environment variable for pip to compile the dependencies correctly.
139

    
140
  	   $ export ARCHFLAGS="-arch x86_64"
141

    
142
   * On Ubuntu, a few more packages must be installed before installing the
143
     prerequisite Python libraries
144

    
145
	   $ sudo aptitude install libcurl3-gnutls libcurl3-gnutls-dev uuid-dev
146

    
147
   Checkout the code and install the Python prerequisites. This assumes that
148
   python is already installed on the host.
149

    
150
    $ sudo easy_install virtualenv
151
    $ git clone https://user@code.grnet.gr/git/synnefo synnefo
152
    $ virtualenv --python=python2.6 synnefo --no-site-packages
153
    ...
154
    $ cd synnefo
155
    $ ./bin/pip install <list_of_dependencies>
156

    
157
    [WARNING]: The software must be checked out in a directory named synnefo,
158
    otherwise python imports will not work. Therefore, do not change the
159
    or rename the checkout path.
160

    
161
5. Database installation:
162
   A database supported by the Django ORM layer must be installed on nodes
163
   of type DB. The choices are: SQLIte, MySQL, PostgreSQL.
164

    
165
   * SQLite:
166
     The python sqlite driver is available by default with Python so no
167
     additional configuration is required. Also, most self-respecting systems
168
     have the sqlite library installed by default.
169

    
170
   * MySQL:
171
      MySQL must be installed first:
172

    
173
      * Ubuntu - Debian
174
	      $ sudo apt-get install libmysqlclient-dev
175

    
176
      * MacPorts
177
	      $ sudo port install mysql5
178

    
179
      Install the MySQL python library on servers running the Django project:
180

    
181
	    $ bin/pip install MySQL-python
182

    
183
      Note: On MacOSX with Mysql install from MacPorts the above command will
184
            fail complaining that it cannot find the mysql_config command. Do
185
            the following and restart the installation
186
	        $ echo "mysql_config = /opt/local/bin/mysql_config5" >> \
187
                                         ./build/MySQL-python/site.cfg
188

    
189
      Configure a MySQL db/account for synnefo
190
	    $ mysql -u root -p
191

    
192
    	mysql> create database synnefo;
193
	    mysql> show databases;
194
	    mysql> GRANT ALL on synnefo.* TO username IDENTIFIED BY 'password';
195

    
196
   * PostgreSQL
197
     You need to install the PostgreSQL binaries:
198
     * Ubuntu - Debian
199
	     $ sudo apt-get install postgresql-8.4 libpq-dev
200

    
201
     * MacPorts
202
	     $ sudo port install postgresql84
203

    
204
     Install the postgres Python library
205
	    $ bin/pip install psycopg2
206

    
207
     Configure a postgres db/account for synnefo:
208

    
209
     Become the postgres user, connect to PostgreSQL:
210
       $ sudo su - postgres
211
       $ psql
212
	
213
	 Run the following commands:
214
	   DROP DATABASE synnefo;
215
	   DROP USER username;
216
	   CREATE USER username WITH PASSWORD 'password';
217
	   CREATE DATABASE synnefo;
218
	   GRANT ALL PRIVILEGES ON DATABASE synnefo TO username;
219
	   ALTER DATABASE synnefo OWNER TO username;
220
	   ALTER USER username CREATEDB;
221

    
222
     The last line enables the newly created user to create own databases. This
223
     is needed for Django to create and drop the test_synnefo database for unit
224
     testing.
225

    
226

    
227
6. Setting up the Django project:
228
   The settings.py file for Django may be derived by concatenating the
229
   settings.py.dist file contained in the Synnefo distribution with a file
230
   containing custom modifications, which shall override all settings deviating
231
   from the supplied settings.py.dist. This is recommended to minimize the load
232
   of reconstructing settings.py from scratch, since each release currently
233
   brings heavy changes to settings.py.dist.
234

    
235
   Add the following to your custom settings.py, depending on your choice
236
   of DB:
237
   * SQLite
238

    
239
	 PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
240

    
241
	 DATABASES = {
242
	     'default': {
243
		     'ENGINE': 'django.db.backends.sqlite3',
244
		     'NAME': PROJECT_PATH + 'synnefo.db' # WARN: This must be an absolute path
245
	     }
246
	 }
247

    
248
   * MySQL
249

    
250
 	 DATABASES = {
251
	     'default': {
252
             'ENGINE': 'django.db.backends.mysql',
253
             'NAME': 'synnefo',
254
             'USER': 'USERNAME',
255
             'PASSWORD': 'PASSWORD',
256
             'HOST': 'HOST',
257
             'PORT': 'PORT',
258
             'OPTIONS': {
259
                 'init_command': 'SET storage_engine=INNODB',
260
             }
261
	    }
262
	}
263

    
264
   * PostgreSQL
265

    
266
     DATABASES = {
267
	     'default': {
268
             'ENGINE': 'django.db.backends.postgresql_psycopg2',
269
             'NAME': 'DATABASE',
270
             'USER': 'USERNAME',
271
             'PASSWORD': 'PASSWORD',
272
             'HOST': 'HOST',
273
             'PORT': 'PORT',
274
	     }
275
     }
276

    
277
    Try it out. The following command will attempt to connect to the DB and
278
    print out DDL statements. It should not fail.
279

    
280
	$ ./bin/python manage.py sql db
281

    
282

    
283
7. Initialization of Synnefo DB:
284
   You need to initialize the Synnefo DB and load fixtures
285
   db/fixtures/{flavors,images}.json, which make the API usable by end users by
286
   defining a sample set of hardware configurations (flavors) and OS images.
287

    
288
     $ ./bin/python manage.py syncdb
289
     $ ./bin/python manage.py migrate db
290
     $ ./bin/python manage.py loaddata db/fixtures/flavors.json
291
     $ ./bin/python manage.py loaddata db/fixtures/images.json
292

    
293

    
294
8. Finalization of settings.py:
295
   Set the BACKEND_PREFIX_ID variable to some unique prefix, e.g. your commit
296
   username in settings.py. Several functional conventions within the system
297
   require this variable to include a dash at its end (e.g. snf-)
298

    
299
   Fix the AMQP-specific settings based on the selected BACKEND_PREFIX_ID.
300
   The fix_amqp_settings() function is called once at the end of
301
   settings.py.dist, you must call it again if you change BACKEND_PREFIX_ID at
302
   some later point.
303

    
304

    
305
9. Installation of the Ganeti monitoring daemon, /ganeti/snf-ganeti-eventd:
306
   The Ganeti monitoring daemon must run on GANETI-MASTER.
307
   The Ganeti monitoring daemon has no dependency on Django.
308
   
309
   Override all relevant settings in settings.d/99-snf-ganeti-eventd.conf,
310
   GANETI_* variables.
311
   Then, make sure PYTHONPATH contains the parent of the Django project,
312
   and start the server on the Ganeti master as root.
313

    
314
     root:~# export PYTHONPATH=$PYTHONPATH:/opt
315
     root:~# /opt/synnefo/ganeti/snf-ganeti-eventd.py
316

    
317
   TBD: how to handle master migration.
318

    
319

    
320
10. Installation of the Synnefo dispatcher, /logic/dispatcher.py:
321
    The logic dispatcher is part of the Synnefo Django project and must run
322
    on LOGIC nodes.
323

    
324
    The dispatcher retrieves messages from the queue and calls the appropriate
325
    handler function as defined in the queue configuration in `setttings.py'.
326
    The default configuration should work directly without any modifications.
327

    
328
    For the time being The dispatcher must be run by hand:
329
      $ ./bin/python ./logic/dispatcher.py
330

    
331
    The dispatcher should run in at least 2 instances to ensure high
332
    (actually, increased) availability.
333

    
334

    
335
11. Installation of the Synnefo Ganeti hook:
336
    The bash wrapper ganeti/snf-ganeti-hook is the generic launcher for
337
    Synnefo hooks in Ganeti. It resides in the ganeti/ directory under the
338
    root of the Synnefo Django project.
339

    
340
    The hook needs to be enabled for phases post-{add,modify,reboot,start,stop}
341
    by *symlinking* in
342
    /etc/ganeti/hooks/instance-{add,modify,reboot,start,stop}-post.d on
343
    GANETI-MASTER, e.g.:
344

    
345
    root@ganeti-master:/etc/ganeti/hooks/instance-start-post.d# ls -l
346
    lrwxrwxrwx 1 root root 45 May   3 13:45 00-snf-ganeti-hook -> /home/devel/synnefo/ganeti/snf-ganeti-hook
347

    
348
    IMPORTANT: The link name may only contain "upper and lower case, digits,
349
    underscores and hyphens. In other words, the regexp ^[a-zA-Z0-9_-]+$."
350
    See:
351
     http://docs.ganeti.org/ganeti/master/html/hooks.html?highlight=hooks#naming
352

    
353
    You need to set SYNNEFO_PROJECT_DIR in ganeti/snf-ganeti-hook. The bash
354
    script modifies PYTHONPATH accordingly, before passing control to the
355
    relevant Python code.
356

    
357

    
358
12. Installation of the VNC authentication proxy, vncauthproxy:
359
    To support OOB console access to the VMs over VNC, the vncauthproxy
360
    daemon must be running on every node of type APISERVER.
361

    
362
    Download and install vncauthproxy from its own repository,
363
    at https://code.grnet.gr/git/vncauthproxy (known good commit: 1c241b27b81).
364

    
365
    Create /var/log/vncauthproxy and set its permissions appropriately.
366

    
367

    
368
13. Installation of the customized Ganeti Instance Image for image deployment:
369
    For Synnefo to be able to launch VMs from specified Images, you need
370
    the gnt-instance-image OS Provider installed on the Ganeti backend.
371

    
372
    Download and install gnt-instance-image in all Ganeti nodes from its own
373
    repository, at https://code.grnet.gr/git/gnt-instance-image. It's
374
    recommended to use the win-support branch (last tested commit for Synnefo
375
    v0.5 is cb9587b68bb1e2d8ce14c351244a279b0e3eb963).
376

    
377
    After installing gnt-instance-image do the following:
378
    1. root@ganeti-master$ cd /path-to-repo
379
       root@ganeti-master$ cp ./defaults /etc/default/ganeti-instance-image
380
    2. Uncomment the following in /etc/default/ganeti-instance-image:
381
         SWAP=no
382
         ARCH="x86_64"
383
    3. In /etc/ganeti/instance-image/hooks, make sure the hooks you want to
384
       run during instance creation process have execute permission.
385
       For linux you will need at lease `grub' and `root_passwd' to make the
386
       instance usable:
387
         chmod +x /etc/ganeti/instance-image/hooks/linux/{grub,root_passwd}
388
       For security reasons make sure `ssh' hook is also enabled.
389
       For windows you will need `mbr' and `admin_passwd':
390
         chmod +x /etc/ganeti/instance-image/hooks/windows/{mbr,admin_passwd}
391
       For both architectures it is also highly recommended to enable
392
       `hostname' hook too:
393
         chmod +x /et/ganeti/instance-image/hooks/{linux,windows}/hostname
394

    
395
    Your Custom Images should be stored in a dump format under
396
    /var/cache/ganeti-instance-image and their filenames should have the
397
    following format:
398
      {backend_id}-x86_64-root.dump
399
    e.g., debian-6.0.1a-x86_64-root.dump (backend_id = "debian-6.0.1a")
400

    
401
14. Setup Synnefo-specific networking on the Ganeti backend:
402
    This part is deployment-specific and must be customized based on the
403
    specific needs of the system administrators.
404

    
405
    A reference installation will use a Synnefo-specific KVM ifup script,
406
    NFDHCPD and pre-provisioned Linux bridges to support public and private
407
    network functionality. For this:
408

    
409
    Grab NFDHCPD from its own repository (https://code.grnet.gr/git/nfdhcpd),
410
    install it, modify /etc/nfdhcpd/nfdhcpd.conf to reflect your network
411
    configuration.
412

    
413
    Install a custom KVM ifup script for use by Ganeti, as
414
    /etc/ganeti/kvm-vif-bridge, on GANETI-NODEs. A sample implementation is
415
    provided under /contrib/ganeti-hooks. Set NFDHCPD_STATE_DIR to point
416
    to NFDHCPD's state directory, usually /var/lib/nfdhcpd.
417

    
418

    
419
15. Create log file directories for Synnefo components, set appropriate
420
    permissions. By default logic/dispatcher.py and ganeti/snf-ganeti-eventd.py
421
    use /var/log/synnefo.
422

    
423

    
424
16. (Hopefully) Done
425