A simple Example

About this task

Let's set up a simple example of ER. We'll replicate the employees table of the "db1" database in an update-anywhere fashion between server1 and server2. (The following steps assume the DBA user account is used.)

Procedure

  1. Prepare the SQLHOSTS files
    The file for each server should contain an entry for both servers as well as two group definitions. Each group represents an ER node:
    grp1  group   -  -  i=1 server1  onsoctcp host port g=grp1
    grp2  group  -  -  i=2 server2  onsoctcp host port g=grp2
    
  2. Prepare the ER disk space
    For each server, perform the following steps:
    1. Edit the ONCONFIG to contain a smart blob space:
      CDR_QDATA_SBSPACE sbs1
    2. Start the server
    3. Create a chunk for that smartblob space and add the space to the server. For example, on UNIX:
      touch /onedb/chunks/sbs1_chunk1 chmod 660 /onedb/chunks/sbs1_chunk1
      onspaces -c -S sbs1 -p /onedb/chunks/sbs1_chunk1 -s 100000 -o 0
      
  3. Add the nodes to a new ER domain
    On server1, execute the following command:
    cdr define server --init grp1

    On server2, execute the following command:

    cdr define server --sync=grp1 --init grp2

    These commands create an ER domain of two root nodes.

  4. Prepare the table to replicate

    On both server1 and server2, run the following SQL statements:

    CREATE DATABSE db1 WITH LOG;
    CREATE TABLE employees(id int primary key, ...);
    
  5. Create the replicate
    On server1, execute:
    cdr define replicate --conflict=always r_employees \
    "db1@grp1:informix.employees"  "select * from employees" \
    "db1@grp2:informix.employees"  "select * from employees"
    
  6. Start the replicate

    On either server, run:

    cdr start replicate r_employees

    Now you're replicating data! An insert, update, or delete to a row on either server1 or server2 will soon appear on the other server.