Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.4.3 |  CUBRID 9.0.0 | 

Scenario of Building New Slave Node

This scenario involves building a new slave node while operating a single master node, making a 1:1 master-slave scheme. Please note that only tables with a default key can be replicated. In addition, all of the volume directories of the master node and the slave node must be identical.

This scenario assumes that the database has been created using the cubrid createdb testdb -L $CUBRID_DATABASES/testdb/log command. At this time, the backup file is saved in the log directory by default if the location is not specified.

Using the above instructions, build a new slave node by following these steps, in the order specified.

  1. Stop the master node service.

    [nodeA]$ cubrid service stop

  2. Set the master node HA and the slave node HA.
    • Set the $CUBRID/conf/cubrid.conf as identical for both the master node and the slave node.
    • [common]

      service=server,broker,manager

      # Add the database name to run when starting the service

      server=testdb

      # Add when configuring the HA (Logging parameters)

      log_max_archives=100

      force_remove_log_archives=no

       

      # Add when configuring the HA (HA mode)

      ha_mode=on

    • Set the $CUBRID/conf/cubrid_ha.conf as identical for both the master node and the slave node.
    • [common]

      ha_port_id=59901

      ha_node_list=cubrid@nodeA:nodeB

      ha_db_list=testdb

      ha_copy_sync_mode=sync:sync

      ha_apply_max_mem_size=500

    • Set the $CUBRID_DATABASES/databases.txt as identical for both the master node and the slave node.
    • #db-name    vol-path        db-host     log-path     lob-base-path

      testdb       /home/cubrid/DB/testdb nodeA:nodeB   /home/cubrid/DB/testdb/log  file:/home/cubrid/DB/testdb/lob

    • Create the log directory in the slave node (only when the log directory has been specified while creating the database)
    • [nodeB]$ cd $CUBRID_DATABASES/testdb

      [nodeB]$ mkdir log

  3. Back up the database of the master node and copy the backup file to the slave node. If the location where the backup file will be saved in the master node is not specified, the location is set as the log directory of testdb by default. Copy the backup file to the same location in the slave node. testdb_bk0v000 is the backup volume file and testdb_bkvinf is the backup volume information file.

    [nodeA]$ cubrid backupdb -z -S testdb

    Backup Volume Label: Level: 0, Unit: 0, Database testdb, Backup Time: Thu Apr 19 16:05:18 2012

    [nodeA]$ cd $CUBRID_DATABASES/testdb/log

    [nodeA]$ scp testdb_bk*cubrid_usr@nodeB:/home/cubrid_usr/CUBRID/databases/testdb/log

    cubrid_usr@nodeB's password:

    testdb_bk0v000                            100% 6157KB   6.0MB/s   00:00

    testdb_bkvinf                             100%   66     0.1KB/s   00:00

  4. Recover the database in the slave node. At this time, the volume path of the master node must be identical to that of the slave node.

    [nodeB]$ cubrid restoredb -B bk demodb

  5. Start the master node

    [nodeA]$ cubrid heartbeat start

  6. After confirming that the master node has started, start the slave node. If nodeA is changed from to-be-master to master, it means that the master node has been successfully started.

    [nodeA]$ cubrid heartbeat status

    @ cubrid heartbeat status

     

     HA-Node Info (current nodeA, state master)

       Node nodeB (priority 2, state unknown)

       Node nodeA (priority 1, state master)

     

     HA-Process Info (master 123, state master)

     

       Applylogdb testdb@localhost:/home1/cubrid/DB/tdb01_nodeB (pid 234, state registered)

       Copylogdb testdb@nodeB:/home1/cubrid/DB/tdb01_nodeB (pid 345, state registered)

       Server tdb01 (pid 456, state registered_and_to_be_active)

     

    [nodeB]$ cubrid heartbeat start

  7. Confirm that the HA configurations of the master node and the slave node are successfully running

    [nodeA]$ csql -u dba testdb@localhost -c"create table tbl(i int primary key);insert into tbl values (1),(2),(3)"

     

    [nodeB]$ csql -u dba testdb@localhost -c"select * from tbl"

     

    === <Result of SELECT Command in Line 1> ===

     

                i

    =============

                1

                2

                3