BSD_Migration

Last modified by kayasaman on 2020/01/28 14:36

Introduction

This guide is dedicated to migrating the Xwiki architecture into different environments. All migration techniques should be quite similar however, I will be assuming Postgresql will be used as the backend database and Tomcat6 is used as the Java container.

Database Migration

First let's look at migrating the backend database over to the new environment. 

Note

This environment could be a new OS, a FreeBSD Jail, a Solaris Zone or Container.

Start by dumping the original database into a file:

su - pgsql

cd /root

pg_dump mydb > db.out

db.out is the name of the 'dumped' DB. This could be given a more valid name like xwiki.dump to make understanding of what it is easier.

On the new machine login as the Postgresql user, usually psql however, in my case since I'm using FreeBSD it will be pgsql. Then initialize the Postgresql DB:

#su -l pgsql

#initdb -D /usr/local/pgsql/data

Note

In Linux the location maybe something like: /var/postgres/data

From there start the postgresql service, create the xwiki role, and create a new 'blank' DB:

#/usr/local/etc/rc.d/postgresql start

#psql postgres

postgres=#CREATE ROLE xwiki WITH PASSWORD 'xwiki' LOGIN; 

postgres=#CREATE DATABASE dbname OWNER xwiki

Note

Assuming a plain migration and not using the old DB as a template use the original name for dbname. However, if creating a new instance then any given name will do as long as it makes sence to the FQDN such as wiki or www.

An alternative method to create the database is:

#su - pgsql
#createdb dbname

Now load the 'dumped' DB file into Postgresql:

psql -d database -f db.out

Then edit the /usr/local/pgsql/data/pg_hba.conf file and add:

host    dbname         rolename      IPv4 /32      trust

Where:

dbanme - is the given database name
rolename - is xwiki (if using default)
IPv4/32 - is the IPv4 address for the host going to connect to the database instance

The next step is to edit the /usr/local/pgsql/data/postgresql.conf and add: 

listen_addresses = '*'

Restart the postgres service: 

/usr/local/etc/rc.d/postgresql restart

Java Application Migration

This is the easy part in any case. Using Tomcat copy the webapp xwiki from $TOMCAT/webapps to: 

/usr/local/apache-tomcat-6.0/webapps/

on the new machine (the path will be different for different OS's). 

Then edit the hibernate.cfg.xml file: 

/usr/local/apache-tomcat-6.0/webapps/xwiki/WEB_INF/hibernate.cfg.xml 

to the new db name: 

<property name="connection.url">jdbc:postgresql://localhost:5432/db</property>

Note

If applicable! As a straight move would not ccnstitute this....

Start the tomcat service: 

/usr/local/etc/rc.d/tomcat6 start

Errors and Bloopers

If you forget to add password and login to the role in postgres then do:

#su - pgsql
#psql dbname
xwiki=#ALTER ROLE role PASSWORD 'password' LOGIN;

If postgresql fails to start claiming 'no space left' do:

ipcs

Message Queues:
T           ID          KEY MODE        OWNER    GROUP   

Shared Memory:
T           ID          KEY MODE        OWNER    GROUP   
m       196608            0 --rw------- pgsql    pgsql   
m      3997697      5432001 --rw------- pgsql    pgsql   

Semaphores:
T           ID          KEY MODE        OWNER    GROUP   
s      2883584      5432001 --rw------- pgsql    pgsql   
s      2949121      5432002 --rw------- pgsql    pgsql   
s       393218      5432003 --rw------- pgsql    pgsql

Look for the Postgres Semaphore numbers, then do:

ipcrm -s Semaphore_number

Note

This will remove the Semaphore ID's to 'free' space and make it able to continue using Postgres.

Last but not least a check which should be done under ANY condition:-

Use: 

$ psql -h <ip_addr> -U xwiki -d <db_name> 

to check that login is working for Postgresql. It is quite a common 'Blooper' that catches people out; the Xwiki process not being able to login to the DB and giving a System 500 error code message.

Get Connected