]> git.evergreen-ils.org Git - OpenSRF.git/blob - README
LP#1612771: Perl max_chunk_size additions
[OpenSRF.git] / README
1 Installing OpenSRF
2 ==================
3
4 Preamble: referenced user accounts
5 ----------------------------------
6
7 In subsequent sections, we will refer to a number of different accounts, as
8 follows:
9
10   * Linux user accounts:
11     ** The *user* Linux account is the account that you use to log onto the
12        Linux system as a regular user.
13     ** The *root* Linux account is an account that has system administrator
14        privileges. On Debian and Fedora you can switch to this account from
15        your *user* account by issuing the `su -` command and entering the
16        password for the *root* account when prompted. On Ubuntu you can switch
17        to this account from your *user* account using the `sudo su -` command
18        and entering the password for your *user* account when prompted.
19     ** The *opensrf* Linux account is an account that you will create as part
20        of installing OpenSRF. You can switch to this account from the *root*
21        account by issuing the `su - opensrf` command.
22
23 Installing prerequisites
24 ------------------------
25
26 OpenSRF has a number of prerequisite packages that must be installed
27 before you can successfully configure, compile, and install OpenSRF.
28 On Debian and Ubuntu, the easiest way to install these prerequisites
29 is to use the Makefile.install prerequisite installer.
30
31 Issue the following commands as the *root* Linux account to install 
32 prerequisites using the Makefile.install prerequisite installer, substituting 
33 your operating system identifier for <osname> below:
34
35 [source, bash]
36 ---------------------------------------------------------------------------
37 apt-get install make
38 make -f src/extras/Makefile.install <osname>
39 ---------------------------------------------------------------------------
40
41 Well-tested values for <osname> include:
42
43   * `debian-jessie` for Debian 8.0
44   * `debian-wheezy` for Debian 7.0
45   * `ubuntu-trusty` for Ubuntu 14.04
46   * `ubuntu-xenial` for Ubuntu 16.04
47   * `fedora` for Fedora 17 and later
48
49 Patches and suggestions for improvement from users of these distributions,
50 or others, are welcome!
51
52 When the prerequisite installer reaches the Perl module stage, you may 
53 be prompted for configuration of Comprehensive Perl Archive Network (CPAN)
54 on your server. You can generally accept the defaults by pressing <return>
55 for all of the prompts, except for the country configuration.
56
57 Preamble: Developer instructions
58 --------------------------------
59
60 [NOTE]
61 Skip this section if you are using an official release tarball downloaded
62 from http://evergreen-ils.org/downloads
63
64 Developers working directly with the source code from the Git repository,
65 rather than an official release tarball, must install some extra packages
66 and perform one step before they can proceed with the `./configure` step.
67
68 As the *root* Linux account, install the following packages:
69
70   * autoconf
71   * automake
72   * libtool
73
74 As the *user* Linux account, issue the following command in the OpenSRF
75 source directory to generate the configure script and Makefiles:
76
77 [source, bash]
78 ------------------------------------------------------------------------------
79 autoreconf -i
80 ------------------------------------------------------------------------------
81
82 Configuration and compilation instructions
83 ------------------------------------------
84
85 Use the `configure` command to configure OpenSRF, and the `make` command to
86 build OpenSRF. The default installation prefix (PREFIX) for OpenSRF is
87 `/opensrf/`.
88
89 If you are building OpenSRF for Evergreen, issue the following commands as
90 the *user* Linux account to configure and build OpenSRF:
91
92 [source, bash]
93 ---------------------------------------------------------------------------
94 ./configure --prefix=/openils --sysconfdir=/openils/conf
95 make
96 ---------------------------------------------------------------------------
97
98 By default, OpenSRF includes C, Perl, and JavaScript support.
99 You can add the `--enable-python` option to the configure command
100 to build Python support and `--enable-java` for Java support.
101
102 Installation instructions
103 -------------------------
104
105 1. Once you have configured and compiled OpenSRF, issue the following
106    command as the *root* Linux account to install OpenSRF:
107 +
108 [source, bash]
109 ---------------------------------------------------------------------------
110 make install
111 ---------------------------------------------------------------------------
112
113 Create and set up the opensrf Unix user environment
114 ---------------------------------------------------
115
116 This user is used to start and stop all OpenSRF processes, and must own all
117 files contained in the PREFIX directory hierarchy. Issue the following
118 commands as the *root* Linux account to create the `opensrf` user and set up
119 its environment, substituting <PREFIX> with the value you passed to `--prefix`
120 in your configure command:
121
122 .Creating the `opensrf` user
123 [source, bash]
124 ---------------------------------------------------------------------------
125 useradd -m -s /bin/bash opensrf
126 echo "export PATH=\$PATH:/<PREFIX>/bin" >> /home/opensrf/.bashrc
127 passwd opensrf
128 chown -R opensrf:opensrf /<PREFIX>
129 ---------------------------------------------------------------------------
130
131 Define your public and private OpenSRF domains
132 ----------------------------------------------
133
134 For security purposes, OpenSRF uses Jabber domains to separate services
135 into public and private realms. Throughout these instructions, we will use
136 the example domains `public.localhost` and `private.localhost`. 
137
138 On a single-server system, the easiest way to define public and private
139 domains is to define separate hostnames by adding entries to the `/etc/hosts`
140 file. Here are entries that you could add to a stock `/etc/hosts` file for our
141 example domains:
142
143 .Example added entries for `/etc/hosts`
144 [source, bash]
145 ---------------------------------------------------------------------------
146 127.0.1.2       public.localhost        public
147 127.0.1.3       private.localhost       private
148 ---------------------------------------------------------------------------
149
150 Adjust the system dynamic library path
151 --------------------------------------
152
153 Add `<PREFIX>/lib/` to the system's dynamic library path, and then run
154 `ldconfig` as the *root* Linux account.
155
156 On Debian, Ubuntu, and Fedora systems, run the following commands as the *root*
157 Linux account:
158
159 .Adjusting the system dynamic library path
160 [source, bash]
161 ---------------------------------------------------------------------------
162 echo <PREFIX>/lib > /etc/ld.so.conf.d/opensrf.conf
163 ldconfig
164 ---------------------------------------------------------------------------
165
166 On most other systems, you can add these entries to `/etc/ld.so.conf`, or
167 create a file within the `/etc/ld.so.conf.d/` directory, and then run
168 `ldconfig` as the *root* Linux account.
169
170 Configure the ejabberd server
171 -----------------------------
172
173 OpenSRF requires an XMPP (Jabber) server. For performance reasons, ejabberd is
174 the Jabber server of choice for the OpenSRF project. In most cases, you only
175 have to make a few changes to the default configuration file to make ejabberd
176 work for OpenSRF. 
177
178 1. Stop ejabberd before making any changes to its configuration by issuing the
179    following command as the *root* Linux account:
180 +
181 .(Debian / Ubuntu Trusty) Stopping ejabberd
182 [source, bash]
183 ---------------------------------------------------------------------------
184 /etc/init.d/ejabberd stop
185 ---------------------------------------------------------------------------
186 +
187 .(Fedora / Ubuntu Xenial) Stopping ejabberd
188 [source, bash]
189 ---------------------------------------------------------------------------
190 systemctl stop ejabberd.service
191 ---------------------------------------------------------------------------
192 +
193 2. Edit the ejabberd config file.
194 +
195 (Debian Wheezy / Ubuntu Trusty) Ejabberd 2.x.x::
196 Open `/etc/ejabberd/ejabberd.cfg` and make the following
197 changes:
198   a. Define your public and private domains in the `hosts` directive. For
199    example:
200 +
201 [source, bash]
202 ---------------------------------------------------------------------------
203 {hosts, ["localhost", "private.localhost", "public.localhost"]}.
204 ---------------------------------------------------------------------------
205 +
206   b. Change all `max_stanza_size` values to 2000000
207   c. Change all `maxrate` values to 500000
208   d. Increase the `max_user_sessions` value to 10000
209   e. Comment out the `mod_offline` directive
210 +
211 (Debian Jessie) Ejabberd 13.x and 14.x::
212 Open `/etc/ejabberd/ejabberd.yml` and make the following
213 changes:
214   a. Define your public and private domains in the `hosts` directive. For
215    example:
216 +
217 [source, bash]
218 ---------------------------------------------------------------------------
219 hosts:
220   - "localhost"
221   - "private.localhost"
222   - "public.localhost"
223 ---------------------------------------------------------------------------
224 +
225   b. Change all `max_stanza_size` values to 2000000
226   c. Change `shaper:` `normal` and `fast` values to 500000
227   d. Increase the `max_user_sessions:` `all:` value to 10000
228   e. Comment out the `mod_offline` directive
229 +
230 -----------------------
231 ##mod_offline:
232     ##access_max_user_messages: max_user_offline_messages
233 -----------------------
234 +
235 (Ubuntu Xenial) Ejabberd 16.x::
236 Open `/etc/ejabberd/ejabberd.yml` and make the following
237 changes:
238   a. Define your public and private domains in the `hosts` directive. For
239    example:
240 +
241 [source, bash]
242 ---------------------------------------------------------------------------
243 hosts:
244   - "localhost"
245   - "private.localhost"
246   - "public.localhost"
247 ---------------------------------------------------------------------------
248 +
249   b. Change all `max_stanza_size` values to 2000000
250   c. Change `auth_password_format` to plain
251   d. Change `shaper:` `normal` and `fast` values to 500000
252   e. Increase the `max_user_sessions:` `all:` value to 10000
253   f. Comment out the `mod_offline` directive
254 +
255 -----------------------
256 ##mod_offline:
257     ##access_max_user_messages: max_user_offline_messages
258 -----------------------
259 +
260 3. Restart the ejabberd server to make the changes take effect:
261 +
262 .(Debian / Ubuntu Trusty) Starting ejabberd
263 [source, bash]
264 ---------------------------------------------------------------------------
265 /etc/init.d/ejabberd start
266 ---------------------------------------------------------------------------
267 +
268 .(Fedora / Ubuntu Xenial) Starting ejabberd
269 [source, bash]
270 ---------------------------------------------------------------------------
271 systemctl start ejabberd.service
272 ---------------------------------------------------------------------------
273
274 Create the OpenSRF Jabber users
275 -------------------------------
276
277 On each domain, you need two Jabber users to manage the OpenSRF communications:
278
279   * a `router` user, to whom all requests to connect to an OpenSRF service
280     will be routed; this Jabber user must be named `router`
281   * an `opensrf` user, which clients use to connect to OpenSRF services; this
282     user can be named anything you like
283
284 Create the Jabber users by issuing the following commands as the *root* Linux
285 account. Substitute `<password>` for your chosen passwords for each user
286 respectively:
287
288 .Creating the OpenSRF Jabber users
289 [source, bash]
290 ---------------------------------------------------------------------------
291 ejabberdctl register router private.localhost <password>
292 ejabberdctl register opensrf private.localhost <password>
293 ejabberdctl register router public.localhost <password>
294 ejabberdctl register opensrf public.localhost <password>
295 ---------------------------------------------------------------------------
296
297 Update the OpenSRF configuration files
298 --------------------------------------
299
300 About the OpenSRF configuration files
301 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
302 There are several configuration files that you must update to make OpenSRF
303 work. SYSCONFDIR is `/opensrf/etc` by default, or the value that you passed to
304 `--sysconfdir` during the configuration phase.
305
306   * `SYSCONFDIR/opensrf.xml` - this file lists the services that this
307     OpenSRF installation supports; if you create a new OpenSRF service,
308     you need to add it to this file.
309       ** The `<hosts>` element at the bottom of the file lists the services
310          that should be started for each hostname. You can force the system
311          to use `localhost`, so in most cases you will leave this section
312          as-is.
313     
314   * `SYSCONFDIR/opensrf_core.xml` - this file lists the Jabber connection
315     information that will be used for the system, as well as determining
316     logging verbosity and defining which services will be exposed on the
317     HTTP gateway.
318
319   * `~/.srfsh.xml` - this file gives a Linux account the ability to use
320     the `srfsh` interpreter to communicate with OpenSRF services.
321
322 Updating the OpenSRF configuration files
323 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
324   1. As the *opensrf* Linux account, copy the example configuration files
325      to create your locally customizable OpenSRF configuration files:
326 +
327 .Copying the example OpenSRF configuration files
328 [source, bash]
329 ---------------------------------------------------------------------------
330 cd SYSCONFDIR
331 cp opensrf_core.xml.example opensrf_core.xml
332 cp opensrf.xml.example opensrf.xml
333 ---------------------------------------------------------------------------
334 +
335   2. Edit the `SYSCONFDIR/opensrf_core.xml` file to update the four username
336      / password pairs to match the Jabber user accounts you just created:
337
338     a. `<config><opensrf>` = use the private Jabber `opensrf` user
339     b. `<config><gateway>` = use the public Jabber `opensrf` user
340     c. `<config><routers><router>` = use the public Jabber `router` user
341     d. `<config><routers><router>` = use the private Jabber `router` user
342   3. Create a `.srfsh.xml` file in the home directory of each user
343      that you want to use `srfsh` to communicate with OpenSRF services. For
344      example, to enable the *opensrf* Linux account to use `srfsh`:
345     a. `cp SYSCONFDIR/srfsh.xml.example ~/.srfsh.xml`
346     b. Open `~/.srfsh.xml` in your text editor of choice and update the
347        password to match the password you set for the Jabber `opensrf` user
348        at the `private.localhost` domain.
349
350 Starting and stopping OpenSRF services
351 --------------------------------------
352
353 To start all OpenSRF services with a hostname of `localhost`, issue the
354 following command as the *opensrf* Linux account:
355
356 [source, bash]
357 ---------------------------------------------------------------------------
358 osrf_control --localhost --start-all
359 ---------------------------------------------------------------------------
360
361 To stop all OpenSRF services with a hostname of `localhost`, issue the
362 following command as the *opensrf* Linux account:
363
364 [source, bash]
365 ---------------------------------------------------------------------------
366 osrf_control --localhost --stop-all
367 ---------------------------------------------------------------------------
368
369 Testing the default OpenSRF services
370 ------------------------------------
371
372 By default, OpenSRF ships with an `opensrf.math` service that performs basic
373 calculations involving two integers. Once you have started the OpenSRF
374 services, test the services as follows:
375
376 1. Start the `srfsh` interactive OpenSRF shell by issuing the following
377    command as the *opensrf* Linux account:
378 +
379 .Starting the `srfsh` interactive OpenSRF shell
380 [source, bash]
381 ---------------------------------------------------------------------------
382 srfsh
383 ---------------------------------------------------------------------------
384 +
385 2. Issue the following request to test the `opensrf.math` service:
386 +
387 [source, bash]
388 ---------------------------------------------------------------------------
389 srfsh# request opensrf.math add 2,2
390 ---------------------------------------------------------------------------
391 +
392 You should receive the value `4`.
393
394 Optional: Websockets installation instructions
395 ----------------------------------------------
396 Websockets are new to OpenSRF 2.4+ and are required for operating the new web-based
397 staff client for Evergreen.  Complete the following steps as the *root* Linux 
398 account:
399
400 1. Install git if not already present:
401 +
402 [source, bash]
403 ---------------------------------------------------------------------------
404 apt-get install git-core
405 ---------------------------------------------------------------------------
406 +
407 2. Install the apache-websocket module:
408 +
409 [source, bash]
410 ---------------------------------------------------------------------------
411 # Use a temporary directory
412 cd /tmp
413 git clone https://github.com/disconnect/apache-websocket
414 cd apache-websocket
415 apxs2 -i -a -c mod_websocket.c
416 ---------------------------------------------------------------------------
417 +
418 3. Create the websocket Apache instance (more information about this in 
419    `/usr/share/doc/apache2/README.multiple-instances`)
420 +
421 .(Debian)
422 [source, bash]
423 ---------------------------------------------------------------------------
424 sh /usr/share/doc/apache2.2-common/examples/setup-instance websockets
425 ---------------------------------------------------------------------------
426 +
427 .(Ubuntu Trusty / Xenial)
428 [source, bash]
429 ---------------------------------------------------------------------------
430 sh /usr/share/doc/apache2/examples/setup-instance websockets
431 ---------------------------------------------------------------------------
432 +
433 4. Remove from the main apache instance
434 +
435 [source, bash]
436 ---------------------------------------------------------------------------
437 a2dismod websocket
438 ---------------------------------------------------------------------------
439 +
440 5. Copy into place the config files
441 +
442 .(Debian)
443 [source, bash]
444 ---------------------------------------------------------------------------
445 cp examples/apache2/websockets/apache2.conf /etc/apache2-websockets/
446 ---------------------------------------------------------------------------
447 +
448 .(Ubuntu Trusty / Xenial)
449 [source, bash]
450 ---------------------------------------------------------------------------
451 cp examples/apache_24/websockets/apache2.conf /etc/apache2-websockets/
452 ---------------------------------------------------------------------------
453 +
454 6. OPTIONAL: add these configuration variables to `/etc/apache2-websockets/envvars`
455    and adjust as needed.
456 +
457 [source, bash]
458 ---------------------------------------------------------------------------
459 export OSRF_WEBSOCKET_IDLE_TIMEOUT=120
460 export OSRF_WEBSOCKET_IDLE_CHECK_INTERVAL=5
461 export OSRF_WEBSOCKET_CONFIG_FILE=/openils/conf/opensrf_core.xml
462 export OSRF_WEBSOCKET_CONFIG_CTXT=gateway
463 export OSRF_WEBSOCKET_MAX_REQUEST_WAIT_TIME=600
464 ---------------------------------------------------------------------------
465 +
466   * `IDLE_TIMEOUT` specifies how long we will allow a client to stay connected
467     while idle.  A longer timeout means less network traffic (from fewer
468     websocket CONNECT calls), but it also means more Apache processes are
469     tied up doing nothing.
470   * `IDLE_CHECK_INTERVAL` specifies how often we wake to check the idle status
471     of the connected client.
472   * `MAX_REQUEST_WAIT_TIME` is the maximum amount of time the gateway will
473     wait before declaring a client as idle when there is a long-running
474     outstanding request, yet no other activity is occurring.  This is
475     primarily a fail-safe to allow idle timeouts when one or more requests
476     died on the server, and thus no response was ever delivered to the gateway.
477   * `CONFIG_FILE / CTXT` are the standard opensrf core config options.
478
479 7. Before you can start websockets, you must install a valid SSL certificate 
480    in `/etc/apache2/ssl/`.  It is possible, but not recommended, to generate a 
481    self-signed SSL certificate.  For example, if you need to test with a self-signed 
482    certicate on Chrome or Chromimum browsers, one workaround is to start the browser 
483    with `--ignore-certificate-errors`.
484
485 8. After OpenSRF is up and running (or after any re-install),
486    fire up the secondary Apache instance. Errors will appear in
487    `/var/log/apache2-websockets/error.log`. Start apache2-websockets with:
488 +
489 [source, bash]
490 ---------------------------------------------------------------------------
491 /etc/init.d/apache2-websockets start
492 ---------------------------------------------------------------------------
493
494 Troubleshooting note for Python users
495 -------------------------------------
496
497 If you are running a Python client and trying to connect to OpenSRF running on
498 localhost rather than a hostname that can be resolved via DNS, you will
499 probably receive exceptions about `dns.resolver.NXDOMAIN`. If this happens,
500 you need to install the `dnsmasq` package, configure it to serve up a DNS
501 entry for localhost, and point your local DNS resolver to `dnsmasq`. For example,
502 on Ubuntu you can issue the following commands as the *root* Linux account:
503
504 .(Debian / Ubuntu) Installing and starting `dnsmasq`
505 [source, bash]
506 ---------------------------------------------------------------------------
507 aptitude install dnsmasq
508 /etc/init.d/dnsmasq restart
509 ---------------------------------------------------------------------------
510
511 Then edit `/etc/resolv.conf` and ensure that `nameserver 127.0.0.1` is the
512 first entry in the file.
513
514 Getting help
515 ------------
516
517 Need help installing or using OpenSRF? Join the mailing lists at
518 http://evergreen-ils.org/communicate/mailing-lists/ or contact us 
519 on the Freenode IRC network on the #evergreen channel.