Versions available for this page: CUBRID 8.4.3 | CUBRID 9.0.0 |
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.
[nodeA]$ cubrid service stop
…
[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
[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
#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
[nodeB]$ cd $CUBRID_DATABASES/testdb
[nodeB]$ mkdir log
[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
[nodeB]$ cubrid restoredb -B bk demodb
[nodeA]$ cubrid heartbeat start
[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
[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