Overview


For users who are new to replication, this document explains how to create and delete replication objects.

 

Version


Altibase version 4.3.9 or later

 

Preparation


 

Enabling the replication function


Changing REPLICATION_PORT_NO property

  1. Check if the replication port specified by the user is in use on the replication target server.

    # Example of execution when the replication port, REPLICATION_PORT_NO is set to 30300
    $ netstat -an | grep 30300 | grep LISTEN    
  2. Open the altibase.properties file, change the REPLICATION_PORT_NO value, and save it. This must be done on each of the replication target servers.

    # Example of setting REPLICATION_PORT_NO when setting the replication port to 30300
    
    $ cd $ALTIBASE_HOME/conf
    $ vi altibase.properties
    REPLICATION_PORT_NO = 30300                    
  3. Restart the Altibase server process.

    $ server restart

    In order to block access to the application during the process of creating a replication object, change the Altibase server service port and restart it.

    $ export ALTIBASE_PORT_NO=20400
    $ server restart
  4. After starting the Altibase server, check the replication port LISTEN status and property settings.

    # Example of Replication port when REPLICATION_PORT_NO is set to 30300
    $ netstat -an | grep 30300 | grep LISTEN
    tcp        0      0 0.0.0.0:30300               0.0.0.0:*                   LISTEN 
    -- # Example of Replication port when REPLICATION_PORT_NO is set to 30300
    
    iSQL> SELECT NAME, VALUE1 FROM V$PROPERTY WHERE NAME = 'REPLICATION_PORT_NO';
    NAME                            VALUE1                          
    -------------------------------------------------------------------
    REPLICATION_PORT_NO             30300                           
    1 row selected.

 

Creating replication object


 

This is an example of creating a replication object when the conditions for creating a replication object are as follows.

  • The target server for replication is two A and B servers.
  • The replication object name is created as REP1.
  • The IP address of the target server A is 192.168.1.112 and the port number is 25524.
  • The IP address of the target server B is 192.168.1.113 and the port number is 35524.

  • The target tables for replication are the SYS user's employees table and departments table.
  1. Server A: IP 192.168.1.112, replication port: 25524

    CREATE REPLICATION rep1 WITH '192.168.1.113', 35524 
    FROM sys.employees TO sys.employees,
    FROM sys.departments TO sys.departments; 
    Create success.
  2. Server B: IP 192.168.1.113, replication port: 35524

    CREATE REPLICATION rep1 WITH '192.168.1.112', 25524
    FROM sys.employees TO sys.employees,
    FROM sys.departments TO sys.departments; 
    Create success.

     

     

  3. Check whether the replication object was created

     iSQL> SELECT REPLICATION_NAME, HOST_IP, PORT_NO FROM SYSTEM_.SYS_REPL_HOSTS_;
    REPLICATION_NAME                HOST_IP                         PORT_NO     
    --------------------------------------------------------------------------------
    REP1                            192.168.1.113                   35524       
    1 row selected.
    
    iSQL> SELECT REPLICATION_NAME, LOCAL_USER_NAME, LOCAL_TABLE_NAME FROM SYSTEM_.SYS_REPL_ITEMS_;
    REPLICATION_NAME                LOCAL_USER_NAME                 LOCAL_TABLE_NAME                
    ----------------------------------------------------------------------------------------------------
    REP1                            SYS                             EMPLOYEES                       
    REP1                            SYS                             DEPARTMENTS                     
    2 rows selected.
    iSQL> SELECT REPLICATION_NAME, HOST_IP, PORT_NO FROM SYSTEM_.SYS_REPL_HOSTS_;
    REPLICATION_NAME                HOST_IP                         PORT_NO     
    --------------------------------------------------------------------------------
    REP1                            192.168.1.112                   35524       
    1 row selected.          
    
    iSQL> SELECT REPLICATION_NAME, LOCAL_USER_NAME, LOCAL_TABLE_NAME FROM SYSTEM_.SYS_REPL_ITEMS_;
    REPLICATION_NAME                LOCAL_USER_NAME                 LOCAL_TABLE_NAME                
    ----------------------------------------------------------------------------------------------------
    REP1                            SYS                             EMPLOYEES                       
    REP1                            SYS                             DEPARTMENTS                     
    2 rows selected. 

 This is an example of creating a replication object when the conditions for creating a redundant replication are as follows.

  • The target servers for replication are A, B, and C
    A is B, C and
    B is A, C and
    C synchronizes with A and B with each other.
  • The name of the replication object is determined as follows.
    -REP_A_B for servers A and B
    -REP_B_C for servers B and C
    -REP_C_A for A and C servers

  • The IP address and replication port number of each server are as follows.
    -Server A: 192.168.1.112, 30300
    -Server B: 192.168.1.113, 30300
    -Server C: 192.168.1.114, 30300

  • The target tables for replication are the SYS user's employees table and departments table.
  1. A Server : IP 192.168.1.112 , Replication port: 30300

    CREATE REPLICATION rep_a_b WITH '192.168.1.113', 30300 FROM sys.employees TO sys.employees, FROM sys.departments TO sys.departments; 
    CREATE REPLICATION rep_c_a WITH '192.168.1.114', 30300 FROM sys.employees TO sys.employees, FROM sys.departments TO sys.departments; 
  2. B Server : IP 192.168.1.113 , Replication port: 30300

    CREATE REPLICATION rep_a_b WITH '192.168.1.112', 30300 FROM sys.employees TO sys.employees, FROM sys.departments TO sys.departments; 
    CREATE REPLICATION rep_b_c WITH '192.168.1.114', 30300 FROM sys.employees TO sys.employees, FROM sys.departments TO sys.departments; 
  3. C Server : IP 192.168.1.114, Replication port: 30300

    CREATE REPLICATION rep_c_a WITH '192.168.1.112', 30300 FROM sys.employees TO sys.employees, FROM sys.departments TO sys.departments; 
    CREATE REPLICATION rep_b_c WITH '192.168.1.113', 30300 FROM sys.employees TO sys.employees, FROM sys.departments TO sys.departments; 
  4. Check whether the replication object was created

    iSQL> SELECT REPLICATION_NAME, HOST_IP, PORT_NO FROM SYSTEM_.SYS_REPL_HOSTS_;
    REPLICATION_NAME                HOST_IP                         PORT_NO     
    --------------------------------------------------------------------------------
    REP_A_B                         192.168.1.113                   30300       
    REP_C_A                         192.168.1.114                   30300       
    2 rows selected.
    
    iSQL> SELECT REPLICATION_NAME, LOCAL_USER_NAME, LOCAL_TABLE_NAME FROM SYSTEM_.SYS_REPL_ITEMS_;
    REPLICATION_NAME                LOCAL_USER_NAME                 LOCAL_TABLE_NAME                
    ----------------------------------------------------------------------------------------------------
    REP_A_B                         SYS                             EMPLOYEES                       
    REP_A_B                         SYS                             DEPARTMENTS                     
    REP_C_A                         SYS                             EMPLOYEES                       
    REP_C_A                         SYS                             DEPARTMENTS                     
    4 rows selected.
    iSQL> SELECT REPLICATION_NAME, HOST_IP, PORT_NO FROM SYSTEM_.SYS_REPL_HOSTS_;
    REPLICATION_NAME                HOST_IP                         PORT_NO     
    --------------------------------------------------------------------------------  
    REP_A_B                         192.168.1.112                   30300       
    REP_B_C                         192.168.1.114                   30300       
    2 rows selected.        
    
    iSQL> SELECT REPLICATION_NAME, LOCAL_USER_NAME, LOCAL_TABLE_NAME FROM SYSTEM_.SYS_REPL_ITEMS_;
    REPLICATION_NAME                LOCAL_USER_NAME                 LOCAL_TABLE_NAME                
    ----------------------------------------------------------------------------------------------------                   
    REP_A_B                         SYS                             EMPLOYEES                       
    REP_A_B                         SYS                             DEPARTMENTS                     
    REP_B_C                         SYS                             EMPLOYEES                       
    REP_B_C                         SYS                             DEPARTMENTS                     
    4 rows selected. 
    iSQL> SELECT REPLICATION_NAME, HOST_IP, PORT_NO FROM SYSTEM_.SYS_REPL_HOSTS_;
    REPLICATION_NAME                HOST_IP                         PORT_NO     
    --------------------------------------------------------------------------------    
    REP_B_C                         192.168.1.113                   30300       
    REP_C_A                         192.168.1.112                   30300     
    2 rows selected.        
    
    iSQL> SELECT REPLICATION_NAME, LOCAL_USER_NAME, LOCAL_TABLE_NAME FROM SYSTEM_.SYS_REPL_ITEMS_;
    REPLICATION_NAME                LOCAL_USER_NAME                 LOCAL_TABLE_NAME                
    ----------------------------------------------------------------------------------------------------                                  
    REP_B_C                         SYS                             EMPLOYEES                       
    REP_B_C                         SYS                             DEPARTMENTS  
    REP_C_A                         SYS                             EMPLOYEES                       
    REP_C_A                         SYS                             DEPARTMENTS                      
    4 rows selected.

 

Starting replication


  1. Selecting the replication start server (active server)
    The server that starts the replication and the server that runs the replication sender refers to the server where the change transaction occurs and is also called the active server.
    Among the replication target servers in a pair, the place where data change occurs is the active server, and the other server becomes the standby server.
    If a change transaction occurs on both servers and synchronizes in both directions, both servers become active servers.
  2. Start of replication
    The active server starts replication with the ALTER REPLICATION statement. replication_name is the name of the object created in the replication object creation step.

    - The replication sender thread runs on the server that executes this command, and the receiver thread is runs on the remote server paired with the server.
    iSQL> ALTER REPLICATION replication_name START;
  3. Check the status of starting/running replication
    This is a statement to check whether the replication sending thread (Sender) and receiving thread (Receiver) are running.

    iSQL> SELECT REPLICATION_NAME, DECODE(IS_STARTED, 0, 'STOPPED', 1, 'STARTED') IS_STARTED FROM SYSTEM_.SYS_REPLICATIONS_;
    REPLICATION_NAME                IS_STARTED                      
    -------------------------------------------------------------------
    REP                             STARTED                         
    1 row selected.
    
    iSQL> SELECT REP_NAME, DECODE(STATUS, 0, 'STOP', 1, 'START', STATUS) STATUS FROM V$REPSENDER;
    REP_NAME                        STATUS                          
    -------------------------------------------------------------------
    REP                             START                           
    1 row selected.
    iSQL> select REP_NAME, MY_IP, MY_PORT FROM V$REPRECEIVER;
    REP_NAME              MY_IP                 MY_PORT     
    ------------------------------------------------------------
    REP                   192.168.1.113         30300       
    1 row selected.



Deleting replication object


This section describes how to delete replication objects.

- Stop the replicaiton first.
iSQL> ALTER REPLICATION replication_name STOP;

- Delete the replication object.
iSQL> DROP REPLICATION replication_name ;

 

Error messages


Here are some of the error messages that may occur during the process of creating replication objects.

[ERR-61023 : Replication is disabled]

 

[ERR-61113 : A replicated table must have a primary key. (user_name.table_name)]

[ERR-6100D : [Sender] Failed to handshake with the peer server (Handshake Process Error)]



Reference Documents