[11323] | 1 | Installation of Kofa on Linux production system |
---|
| 2 | ############################################### |
---|
[10120] | 3 | |
---|
[11323] | 4 | .. note:: `waeup.kofa` and its custom packages |
---|
| 5 | might not work with Python > 2.7 |
---|
| 6 | currently. Use of Python 2.7 is recommended. |
---|
| 7 | The installation is described for Linux-based computers. |
---|
[10120] | 8 | |
---|
[11323] | 9 | Part 1: Deploying Kofa as a single Zope client install |
---|
| 10 | ****************************************************** |
---|
[10120] | 11 | |
---|
[11323] | 12 | Prerequisites |
---|
| 13 | ============= |
---|
| 14 | |
---|
| 15 | The Kofa packages are based on `Grok`_, which is a Python |
---|
| 16 | framework for agile webapplication development. Grok itself is based |
---|
| 17 | on `Zope`_. |
---|
| 18 | |
---|
| 19 | .. _Grok: http://grok.zope.org/ |
---|
| 20 | |
---|
| 21 | .. _Zope: http://www.zope.org/ |
---|
| 22 | |
---|
| 23 | Both, Grok and Zope, are written in Python (with parts written in |
---|
| 24 | C). You therefore need `Python`_ installed. |
---|
| 25 | |
---|
| 26 | .. _Python: http://www.python.org/ |
---|
| 27 | |
---|
| 28 | Note, that you also need the Python header files and a compiler to |
---|
| 29 | compile the parts written in C. |
---|
| 30 | |
---|
| 31 | To deploy Kofa most easily, we use `zc.buildout`_ |
---|
| 32 | |
---|
| 33 | .. _zc.buildout: http://cheeseshop.python.org/pypi/zc.buildout |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | Preparing the system |
---|
| 37 | ==================== |
---|
| 38 | |
---|
| 39 | To create a working copy of Kofa we recommend use of |
---|
| 40 | `virtualenv`. You, however, need also some basic libraries, a C |
---|
| 41 | compiler and some things more. |
---|
| 42 | |
---|
| 43 | What you need (Debian/Ubuntu package names in brackets): |
---|
| 44 | |
---|
| 45 | * Python 2.7 (python2.7) |
---|
| 46 | |
---|
| 47 | * Python 2.7 development files (python2.7-dev) |
---|
| 48 | |
---|
| 49 | * A C-Compiler (gcc) |
---|
| 50 | |
---|
| 51 | * The C library development files (libc6-dev) |
---|
| 52 | |
---|
| 53 | * A subversion client (svn) |
---|
| 54 | |
---|
| 55 | * enscript (enscript) [optional] |
---|
| 56 | |
---|
| 57 | This is only needed if you want test coverage reports. |
---|
| 58 | |
---|
| 59 | All these packages can be installed on Debian systems like this:: |
---|
| 60 | |
---|
| 61 | # apt-get install python2.7 python2.7-dev python2.7-dbg \ |
---|
| 62 | gcc libc6-dev svn enscript |
---|
| 63 | |
---|
| 64 | Afterwards you should be able to enter:: |
---|
| 65 | |
---|
| 66 | $ python2.7 |
---|
| 67 | |
---|
| 68 | at the commandline and get a Python prompt. Quit the interpreter |
---|
| 69 | pressing <CTRL-D>. |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | Installing `virtualenv` |
---|
| 73 | ======================= |
---|
| 74 | |
---|
| 75 | We recommend use of `virtualenv` to create Python sandboxes where you |
---|
| 76 | can run your code without touching any other installations. |
---|
| 77 | |
---|
| 78 | If you don't already have ``easy_install`` available, you can find the |
---|
| 79 | script to set it up on the `PEAK EasyInstall page`_. |
---|
| 80 | |
---|
| 81 | .. _`PEAK EasyInstall page`: http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install |
---|
| 82 | |
---|
| 83 | You need to download `ez_setup.py`_. Then, you run it like this to |
---|
| 84 | install ``easy_install`` into your system Python:: |
---|
| 85 | |
---|
| 86 | $ sudo python2.7 ez_setup.py |
---|
| 87 | |
---|
| 88 | .. _`ez_setup.py`: http://peak.telecommunity.com/dist/ez_setup.py |
---|
| 89 | |
---|
| 90 | This will make ``easy_install`` available to you. |
---|
| 91 | |
---|
| 92 | .. note:: Sometimes you have ``easy_install`` installed but you need a |
---|
| 93 | newer version of the underlying setuptools infrastructure to |
---|
| 94 | make Grok work. You can upgrade setuptools with:: |
---|
| 95 | |
---|
| 96 | $ sudo easy_install -U setuptools |
---|
| 97 | |
---|
| 98 | Now you can install `virtualenv` by doing (as root):: |
---|
| 99 | |
---|
| 100 | # easy_install-2.7 virtualenv |
---|
| 101 | |
---|
| 102 | This step will fetch all needed sources from the internet and install |
---|
| 103 | `virtualenv` locally in your Python2.7 installation. |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | Creating a sandbox |
---|
| 107 | ================== |
---|
| 108 | |
---|
| 109 | This step is only necessary (and recommended) if you installed |
---|
| 110 | `virtualenv` before. |
---|
| 111 | |
---|
| 112 | As a normal user you now can create a sandbox for your upcoming work |
---|
| 113 | by:: |
---|
| 114 | |
---|
| 115 | $ virtualenv --no-site-packages mysandbox |
---|
| 116 | |
---|
| 117 | where ``mysandbox`` is a directory in the filesystem where your |
---|
| 118 | sandbox will be created. `virtualenv` will also create this directory |
---|
| 119 | for you. |
---|
| 120 | |
---|
| 121 | By passing the ``no-site-packages`` switch we tell `virtualenv` to |
---|
| 122 | provide us a clean environment without any extra-packages installed |
---|
| 123 | systemwide. |
---|
| 124 | |
---|
| 125 | You now can activate the sandbox by doing:: |
---|
| 126 | |
---|
| 127 | $ source mysandbox/bin/activate |
---|
| 128 | |
---|
| 129 | You will notice that the input prompt changes. |
---|
| 130 | |
---|
| 131 | To deactivate the sandbox at any time, enter:: |
---|
| 132 | |
---|
| 133 | (sandbox27)$ deactivate |
---|
| 134 | |
---|
| 135 | and the prompt will be the same as before the activation. |
---|
| 136 | |
---|
| 137 | For the following steps make sure the sandbox is active. |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | Creating a working place |
---|
| 141 | ======================== |
---|
| 142 | |
---|
| 143 | In the sandbox we now create our real working |
---|
| 144 | environment. To do this, we change to the sandbox and checkout the |
---|
| 145 | sources of Kofa from the subversion server:: |
---|
| 146 | |
---|
| 147 | (sandbox27)$ cd mysandbox/ |
---|
| 148 | (sandbox27)$ svn co https://svn.waeup.org/repos/main/waeup.kofa/trunk kofa-trunk |
---|
| 149 | |
---|
| 150 | where ``kofa-trunk`` is only a name we've chosen here to make clear |
---|
| 151 | where the sources come from. In this case we are installing the Kofa base |
---|
| 152 | package. |
---|
| 153 | |
---|
| 154 | The command should fetch the Kofa base package sources for you and |
---|
| 155 | put it in the directory ``kofa-trunk/``. |
---|
| 156 | |
---|
| 157 | Now enter the new directory:: |
---|
| 158 | |
---|
| 159 | (sandbox27)$ cd kofa-trunk |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | Preparing the build |
---|
| 163 | =================== |
---|
| 164 | |
---|
| 165 | In the sources directory (``kofa-trunk/``) you have to prepare the |
---|
| 166 | project to fetch needed components (eggs), compile C-code parts, |
---|
| 167 | etc. This steip will not touch any external projects:: |
---|
| 168 | |
---|
| 169 | (sandbox27)$ python bootstrap.py |
---|
| 170 | |
---|
| 171 | This will generate some directories and the ``buildout`` script in |
---|
| 172 | ``bin/`` for us. This step must be executed only once for each |
---|
| 173 | instance. |
---|
| 174 | |
---|
| 175 | You can now deactivate the sandbox:: |
---|
| 176 | |
---|
| 177 | (sandbox27)$ deactivate |
---|
| 178 | |
---|
| 179 | Now we can do the real build by triggering:: |
---|
| 180 | |
---|
| 181 | $ bin/buildout |
---|
| 182 | |
---|
| 183 | If this is your first install of some Grok-related project, this step |
---|
| 184 | will need some time as lots of sources have to be fetched, many |
---|
| 185 | components must be compiled, etc. |
---|
| 186 | |
---|
| 187 | This step must be redone whenever you change something in |
---|
| 188 | ``buildout.cfg`` or ``setup.py``. |
---|
| 189 | |
---|
| 190 | Note that if you have more than one sandbox for a Zope-based web |
---|
| 191 | application, it will probably make sense to share the eggs between the |
---|
| 192 | different sandboxes. You can tell ``zc.buildout`` to use a central |
---|
| 193 | eggs directory by creating ``~/.buildout/default.cfg`` with the |
---|
| 194 | following contents:: |
---|
| 195 | |
---|
| 196 | [buildout] |
---|
| 197 | eggs-directory = /home/bruno/buildout-eggs |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | Start the instance |
---|
| 201 | ================== |
---|
| 202 | |
---|
| 203 | You should be able now to start the created instance by doing:: |
---|
| 204 | |
---|
| 205 | $ bin/zopectl fg |
---|
| 206 | |
---|
| 207 | Alternatively you can do: |
---|
| 208 | |
---|
| 209 | $ bin/paster serve parts/etc/deploy.ini |
---|
| 210 | |
---|
| 211 | The port numbers where Kofa is running on your server are defined in |
---|
| 212 | buildout.cfg under [kofa_params]. |
---|
| 213 | |
---|
| 214 | If you now point a browser to the right port on your server, for example :: |
---|
| 215 | |
---|
| 216 | localhost:8080 |
---|
| 217 | |
---|
| 218 | you should get a login pop-up, where you can login as superuser with |
---|
| 219 | ``grok`` and ``grok`` as username/password (Kofa base package only!). |
---|
| 220 | |
---|
| 221 | You can stop the instance by pressing <CTRL-C>. |
---|
| 222 | |
---|
| 223 | If you are connected and logged in, |
---|
| 224 | you should be able to add the grok-based applications |
---|
| 225 | (such as ``University``) from the menu. |
---|
| 226 | |
---|
| 227 | Add an instance of ``University`` and click on the link next to the |
---|
| 228 | then visible entry in the list of installed applications. |
---|
| 229 | |
---|
| 230 | Running the tests |
---|
| 231 | ================= |
---|
| 232 | |
---|
| 233 | The tests are easily run by executing the test runner that's |
---|
| 234 | installed in the ``bin`` directory:: |
---|
| 235 | |
---|
| 236 | $ bin/test |
---|
| 237 | |
---|
| 238 | |
---|
| 239 | Part 2: Deploying Kofa as ZEO install |
---|
| 240 | ************************************* |
---|
| 241 | |
---|
| 242 | Each ZEO install consists of at least one ZEO server and normally two |
---|
| 243 | or more ZEO clients. While the ZEO server is meant to manage the ZODB |
---|
| 244 | database for clients, the clients connect to the outside world, listen |
---|
| 245 | for request and do the real dataprocessing. |
---|
| 246 | |
---|
| 247 | We prepared a `buildout` configuration that sets up one server |
---|
| 248 | configuration and two client configs. This configuration is in |
---|
| 249 | ``buildout-zeo.cfg``. |
---|
| 250 | |
---|
| 251 | Generating the ZEO setup |
---|
| 252 | ======================== |
---|
| 253 | |
---|
| 254 | To install Kofa ZEO-based you can run `buildout` with the given |
---|
| 255 | (or your own) configuration file like this:: |
---|
| 256 | |
---|
| 257 | $ ./bin/buildout -c buildout-zeo.cfg |
---|
| 258 | |
---|
| 259 | This should generate all scripts necessary to run servers, clients, |
---|
| 260 | etc. |
---|
| 261 | |
---|
| 262 | Starting ZEO servers and clients |
---|
| 263 | ================================ |
---|
| 264 | |
---|
| 265 | First start the server:: |
---|
| 266 | |
---|
| 267 | $ ./bin/zeo_server start |
---|
| 268 | |
---|
| 269 | Clients can be started by doing:: |
---|
| 270 | |
---|
| 271 | $ ./bin/zeo_client1 start |
---|
| 272 | $ ./bin/zeo_client2 start |
---|
| 273 | |
---|
| 274 | This will start both clients in daemon mode. |
---|
| 275 | |
---|
| 276 | Instead of ``start`` you can, as usually, start an instance in |
---|
| 277 | foreground (``fg``), etc. You know the drill. |
---|
| 278 | |
---|
| 279 | |
---|
| 280 | Manually starting ZEO clients |
---|
| 281 | ============================= |
---|
| 282 | |
---|
| 283 | This is normally not neccessary. |
---|
| 284 | |
---|
| 285 | ``zeo_clientN`` scripts are basically wrappers around calls to |
---|
| 286 | ``bin/paster``. You can bypass this wrapper and start a client |
---|
| 287 | 'manually' like this:: |
---|
| 288 | |
---|
| 289 | $ ./bin/paster serve --pid-file var/zeo1.pid --daemon \ |
---|
| 290 | pars/etc/zeo1.ini |
---|
| 291 | |
---|
| 292 | It is important to give a pid-file as paster otherwise can not start |
---|
| 293 | different clients (they would all refer to the same pid file |
---|
| 294 | `paster.pid` and refuse to start after the first client was started). |
---|
| 295 | |
---|
| 296 | |
---|
| 297 | Setup (paramters, ports, etc.) |
---|
| 298 | ============================== |
---|
| 299 | |
---|
| 300 | By default the server will listen on port 8100 for requests from |
---|
| 301 | localhost (not: from the outside world). |
---|
| 302 | |
---|
| 303 | You can change ZEO server settings in the ``[zeo_server]`` section |
---|
| 304 | of ``buildout-zeo.conf``. Run `buildout` afterwards. |
---|
| 305 | |
---|
| 306 | The clients will listen on port 8081 and 8082. You can change settings |
---|
| 307 | in ``etc/zeo1.ini.in`` and ``etc/zeo2.ini.in`` respectively. Run |
---|
| 308 | buildout after any change. |
---|
| 309 | |
---|
| 310 | If you want to change the paster wrapper for any zeo client, you can |
---|
| 311 | edit ``etc/zeo1.conf`` and/or ``etc/zeo2.conf``. Run buildout |
---|
| 312 | afterwards. |
---|
| 313 | |
---|
| 314 | |
---|
| 315 | Creating new clients |
---|
| 316 | ==================== |
---|
| 317 | |
---|
| 318 | You want more clients to be created by buildout? Easy. Three steps are |
---|
| 319 | neccessary. |
---|
| 320 | |
---|
| 321 | 1. Create config files in etc/ |
---|
| 322 | ------------------------------ |
---|
| 323 | |
---|
| 324 | Each client needs two configuration files: |
---|
| 325 | |
---|
| 326 | - ``etc/zeoN.conf`` |
---|
| 327 | configuring the paster wrapper |
---|
| 328 | |
---|
| 329 | - ``etc/zeoN.ini`` |
---|
| 330 | configuring the runtime config, ports, etc. |
---|
| 331 | |
---|
| 332 | Just copy over these files from the already existing zeo1/zeo2 files |
---|
| 333 | and replace ``zeo1`` or ``zeo2`` with your new name. |
---|
| 334 | |
---|
| 335 | 2. Update buildout-zeo.cfg |
---|
| 336 | -------------------------- |
---|
| 337 | |
---|
| 338 | Here, inside ``buildourt-zeo.cfg`` also three steps are needed. |
---|
| 339 | |
---|
| 340 | * 2.1. Create new .ini and .conf entries |
---|
| 341 | |
---|
| 342 | The .conf and .ini files in etc/ are only templates that have to be |
---|
| 343 | generated in their really used final location. In buildout-zeo.cfg |
---|
| 344 | you can care for this by creating a new ``[zeoN_ini]`` and |
---|
| 345 | ``[zeoN_conf]`` option (replacing ``N`` with a number, of course). |
---|
| 346 | |
---|
| 347 | Just copy over existing entries and replace the mentions of ``zeo1`` |
---|
| 348 | or ``zeo2`` by your ``zeoN``. |
---|
| 349 | |
---|
| 350 | * 2.2. Create a new ``zeo_clientN`` entry |
---|
| 351 | |
---|
| 352 | Then you have to create an entry that will generate the |
---|
| 353 | ``zeo_clientN`` script. Again, just copy over an existing |
---|
| 354 | ``[zeo_client1]`` entry and replace ``1`` withg your client number. |
---|
| 355 | |
---|
| 356 | * 2.3. Register the new sections in ``[buildout]`` section |
---|
| 357 | |
---|
| 358 | When done with the above: add the new section in ``[buildout]``:: |
---|
| 359 | |
---|
| 360 | [buildout] |
---|
| 361 | ... |
---|
| 362 | <old entries...> |
---|
| 363 | ... |
---|
| 364 | zope_conf_zeo_5 |
---|
| 365 | zeo5_ini |
---|
| 366 | zeo_client5 |
---|
| 367 | |
---|
| 368 | depending on how you named your new sections. |
---|
| 369 | |
---|
| 370 | 3. Rerun ``buildout`` |
---|
| 371 | --------------------- |
---|
| 372 | |
---|
| 373 | When adding or removing client/server instances, make sure to stop all |
---|
| 374 | running servers/clients before rerunning buildout. |
---|
| 375 | |
---|
| 376 | To activate the new setup, rerun buildout:: |
---|
| 377 | |
---|
| 378 | $ bin/buildout -c buildout-zeo.cfg |
---|
| 379 | |
---|
| 380 | This should generate any new clients and remove older ones or just |
---|
| 381 | update configuration files. |
---|
| 382 | |
---|
| 383 | |
---|
| 384 | Considerations |
---|
| 385 | ============== |
---|
| 386 | |
---|
| 387 | There are some things in the current buildout-zeo.cfg we might do not |
---|
| 388 | want. It extends the regular ``buildout.cfg`` so that we do not have |
---|
| 389 | to repeat most sections but the ``parts`` in ``[buildout]`` have to be |
---|
| 390 | listed. |
---|
| 391 | |
---|
| 392 | We need, however, not everything with a ZEO-deploy that is listed in a |
---|
| 393 | default buildout. We might do not need docs, no profiling, etc. Also a |
---|
| 394 | regular non-ZEO kofactl might not make to much sense. Therefore all |
---|
| 395 | this might be subject to changes. |
---|