Configuración de Koha en un Ambiente Virtual + usando este como un entorno de desarrollo

From Koha Wiki
Jump to navigation Jump to search

Este texto fue originalmente publicado en el blog de Reed de Wade. Damos las gracias a él por haber aceptado compartir esto. Boos van a pedirme por mi pobreza en la artesanía wiki. agradecimientos a Brooke por aportar esto ha la wiki. Se convertirá en la ubicación autorizada de este documento ahora.

Esto describe una de las formas de configurar Koha en una máquina virtual y cómo configurarla para su uso como un entorno de desarrollo. Las máquinas virtuales se utilizan para crear un entorno que es repetible y bien definido. Asume un conocimiento práctico de los sistemas Linux, aunque mi intención es describir las cosas con suficiente detalle por lo que no mucha experiencia se debe exigir.

He repetido este proceso un par de veces por lo que debe funcionar por lo menos en el trabajo -- pero estaría agradecido por comentarios, correcciones y mejoras.

Esto tiene como objetivo el desarrollo y el uso experimental. Puede o no puede trabajar para un entorno de producción en función de sus necesidades y su situación.

Esto está escrito en dos mensajes, el primero que aquí se obtiene una instalación de trabajo Koha. Koha_Dev_Env_Setup te prepara para hacer un poco de desarrollo en contra de ella.

KohaDesktopDev.png

Yo uso Nginx como motor de enrutamiento HTTP. Nginx es un servidor web ligero y de alto rendimiento que está cerca de mi corazón. Se utiliza para reenviar el tráfico HTTP en la()se maquina(s) Koha. Es opcional si sólo necesita conectarse desde su equipo de escritorio.

Mi maquina de desarrollo de escritorio está ejecutando una versión reciente de Ubuntu y muchas de las instrucciones que ofrezco aquí son específicos para ese entorno. Estoy usando QEMU/KVM para la máquina virtual, pero este sistema funciona muy bien con VirtualBox también. (Desde que tatuaban el gran logo de Oracle en la parte superior de VirtualBox he puesto atencion en estar lejos de usarlo tanto como sea posible.)

Para evitar confusiones, voy a utilizar el promt escritorio$ en los ejemplos siguientes para cosas que usted debe escribir desde la maquina de escrotprop para desarrollo y kohabox$ para la máquina virtual en ejecución Koha.

Paso 1: Crear una Maquina Virtual

Install QEMU/KVM and the Virtual Machine Manager. You can do this using the Ubuntu Package Manager. Select: virt-manager and qemu-kvm (I think that's all you need—let me know if not so I can update these instructions), then 'apply' to install. I had a problem with running this right after installation so a reboot at this point is probably a good idea.

Download the installation cdrom image (iso file) from which your new virtual machine will be built. I'm using Debian 6 (squeeze) which at this moment is still officially in testing. Go to http://www.debian.org/devel/debian-installer/ and get the i386 netinst CD image. Save it someplace on your machine.

Now, start up Virtual Machine Manager. Once you've installed it this will probably be under the System Tools menu on your desktop.

Ssvmm.png

Create a new machine and name it kohabox.

Ssvmm2.png

Select the Debian CD image you just downloaded as the install media.

Ssvmm3.png

Ssvmm4.png

The Debian installation screen will appear. Select 'graphical install' and answer most of the questions using the defaults (except where it makes sense to diverge like when selecting your country and time zone). For the hostname, use kohabox. Set the passwords to something you will remember. When asked to create a new user, use the same user name you use on your desktop machine.

Debianswirly.png

At the 'Partition disks' step there is a 'Write changes to disk?' question. The default is No for safety but that's not useful, answer Yes there.

When you get to the 'Software selection' page, add SSH server, unset Graphical desktop environment.

Deb2.png

If you run into problems or enter the wrong things or forgot the passwords you gave it just shut off the virtual machine, delete it and start over. That's part of the fun of virtual machines.

Paso: Direccion IP estatica para su nueva maquina

(Esta seccion es especificia para QEMU/KVM.)

Your machine will have been assigned an IP address via the QEMU/KVM DHCP service. It would be nice if that address is one that never changes. One way to do that is to configure the DHCP service to always give the same address to that host.

Kvm.png

Shut down your virtual machine and then:

   desktop$ sudo virsh net-edit default

change the section that looks like--

   <dhcp>
       <range start="192.168.122.2" end="192.168.122.254" />
   </dhcp>

to--

   <dhcp>
       <range start="192.168.122.2" end="192.168.122.100" />
       <host mac="52:54:00:e4:af:84" name="kohabox" ip="192.168.122.101" />
   </host>

with 52:54:00:e4:af:84 being the MAC address which was generated for the network device on you new machine.

Now, activate the new configuration:

   desktop$ sudo virsh net-destroy default
   desktop$ sudo virsh net-start default


Then, add an entry to /etc/hosts like this (and skipping ahead, we're adding a kohaadmin and koha entry to be used later):

   desktop$ sudo vi /etc/hosts

adding

   192.168.122.101 kohabox koha kohaadmin


Start up kohabox and confirm it is now using the 192.168.122.101 address.

Confirm you can ssh to it from your desktop:

   desktop$ ssh kohabox


(NB: I've tested this a few times and normally it just works. I did have one case where it's needed a restart or two before the new address took for some reason.)

Step: sudo and desktop hosts entry

sudo doesn't seem to be installed on the virtual machine, so do that:

   kohabox$ su -
   Password:
   root@kohabox# apt-get install sudo
   root@kohabox# vi /etc/group

and add your user to the sudo group

   root@kohabox# vi /etc/hosts

and add an entry for the desktop host

   192.168.122.1 desktop

You may need to log out completely from the virtual machine then back in for the new group membership to take effect (or at least open a new shell).

Paso: Instalar Koha

We're going to simplify our lives in a big way now by installing Koha from packages. This will install the dependent packages for us and just makes sure our pipes are really clean before we start tampering with it for our development work.

You should review http://wiki.koha-community.org/wiki/Debian before starting.

   kohabox$ sudo vi /etc/apt/sources.list

adding this line

   deb http://debian.koha-community.org/koha squeeze-dev main

then

   kohabox$ wget -O- http://debian.koha-community.org/koha/gpg.asc | sudo apt-key add -
   kohabox$ sudo apt-get update
   kohabox$ sudo apt-get install koha-common mysql-server

That last step will take a while. Take the time to spare a loving thought for Lars Wirzenius who organised the package build and Robin Sheat who now maintains it (and even one for our employer, Catalyst, which funded that work).

When done, create (or replace) /etc/koha/koha-sites.conf.

   kohabox$ sudo vi /etc/koha/koha-sites.conf
   DOMAIN=""
   INTRAPORT="80"
   INTRAPREFIX=""
   INTRASUFFIX="admin"
   DEFAULTSQL="/usr/share/koha/defaults.sql.gz"


You may want to review /usr/share/doc/koha-common/README.Debian to understand where config files are landing.

The koha-common package sets up a system for creating multiple Koha instances on a single machine. It's just as useful for creating a single one which we will name “koha”.

   kohabox$ sudo a2enmod rewrite
   kohabox$ sudo a2dissite 000-default
   kohabox$ sudo koha-create --create-db koha


Once those are done you should be able to see something at http://kohaadmin/ and http://koha/ from your desktop machine. The admin user will be koha_koha, find the password by looking in /etc/koha/sites/koha/koha-conf.xml

Paso: Configurar su Instancia Koha

Kohawebinstall.png

Go to http://kohaadmin/ and login in as user koha_koha. Step through the web installer selecting default values except:

MARC flavour, no default given, use Marc21.

On the “MARC Frameworks: MARC21” setting page, set the 3 Optional items:

  • marc21_default_matching_rules
  • marc21_fastadd_framework
  • marc21_simple_bib_frameworks

In the bottom Optional section enable:

  • auth_val
  • parameters
  • sample_itemtypes
  • sample_z3950_servers options

You may choose to select others but it can be educational and tidier not to. For the following example to work correctly you should at least set those I've listed. Leaving one or two out can give you a configuration which could be confusing/frustrating for someone new to Koha. (I'd be happy for someone with more knowledge of this to suggest a better starting configuration or a pointer to better information here--thanks.)

For the indexing engine, go ahead and select Zebra. It's a commonly used complicating factor so you'll want it if you plan to do any useful development work. Plus it's already going to be configured for from the package installation.

Ok, you're done. You should now have a working but not very interesting Koha installation.

Paso: Agregar un libro (para no bibliotecarios)

Yo asumo que eres un desarrollador de software pero no un bibliotecario. Also, that you don't really have a library other than a stack of books in your home. Adding a book sounds simple enough but it's important to know that you must first create a catalogue entry for the publication then, separately, create a record representing the physical instance of the book. Getting right with that was a key ah-ha moment for me anyway.

Quick detour, before adding books you'll want turn on bar code auto assigning. Go to System preferences and find autoBarcode under the Cataloguing section. Set it to something other than 'not generated automatically'.

Second detour, you need to create a library for your book record to have a home. Do this from the “basic parameters” configuration page.

Ok, so, imagine you have a book in your hand and you've got the ISBN which is printed on it somewhere.

Oneofreedsbooks.jpg


In the Koha staff interface, select 'Add MARC Record' (under Cataloguing on the home page). Then hit the button marked “z39.50 Search”. A new window pops up with various search options. You'll also notice a list of search targets. These were added during the configuration step. Each is a publicly accessible searchable collection of catalogue records. At the moment you have none and need to copy one for each book you want to catalogue.

Enter 1400079764 for the ISBN and hit the Search button. You should get at least one result. Select “import”. The search window will close and the MARC Record page will be filled in with a catalogue entry for the book.

Select Save. You may get a pop up message saying some required field (CONTROL NUMBER IDENTIFIER) is not filled in. You will also see that it's got a candidate value now filled in for you. Hit Save again and you should be good.

You will now see an item record entry titled “Items for The Anchor book of modern Arabic fiction / (Record #1)”. Selecting the date and bar code fields will cause them to be filled in with useful values. Feel free to set and others or not then hit “Add Item”.

Sweet, you now have a book in your library.

Visit http://koha/ and search on part of the title “arabic”... well that's odd, no results (maybe)...

This is because the Zebra search indexer has not run. This is run from cron every 5 minutes. So, just wait a bit then try again.

Paso: Configurar Nginx

You can safely skip this step. Routing traffic through Nginx allows clients from outside your desktop machine to connect to your Koha machine. It also allows you a central place to manage HTTP traffic to your virtual machines.

   desktop$ sudo apt-get install nginx

Now create a configuration for request forwarding.

Create a new file called /etc/nginx/sites-enabled/forwards and put this in it:

   server {
       listen 80;
       server_name koha kohaadmin;
       location / {
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_pass http://kohabox/;
      }
   }


Edit your desktop /etc/hosts file changing:

   192.168.122.101 kohabox koha kohaadmin

to

   192.168.122.101 kohabox
   127.0.0.1 koha kohaadmin


Ahora re-iniciar (o iniciar) nginx:

   desktop$ sudo /etc/init.d/nginx restart

With a web browser, visit http://kohaadmin/ and http://koha/ again. You should see no difference.

[ I need to add an example here of how you would get to Koha from a 3rd machine to make this actually useful. This will be a bit complex because to depends a lot on the local network environment so need to lay out a few scenarios. -reed ]