Configuring the master database for the evaluation setup includes the following steps: creating a catalog using the system stored procedure SYNC_SETUP_CATALOG, creating a table to be replicated, and creating a publication that defines the replicated data set in the master.
The SQL statements that are needed to configure the master database are provided in the master1.sql sample script below.
Fast path: If you are using the working directories and sample scripts in the samples\replication\ directory, go the solidDB® installation root directory and issue the following command:
▪-O eval.outis an optional parameter that defines the output file for results.
▪"tcp 1315"is the network protocol and address of the master server. You may have to customize this part of the command.
▪dbaand dba_passwordare username and password respectively.
▪master1.sqlis the executed SQL script.
You can view the results in eval.out with any text editor.
Note When you execute advanced replication scripts, you must set the autocommit mode OFF. In solidDB® SQL Editor (solsql), the autocommit mode is set OFF by default.
Sample script: master1.sql
--******************************************** -- master1.sql -- Execute this script in the MASTER database. -- Initializes the master with node name MASTER. -- Creates a table and publication. --******************************************** -- Create the catalog named "sync_demo_catalog". -- Give this node the name "master_node". -- Register this node as a master, and not as a replica. CALL SYNC_SETUP_CATALOG ( ’sync_demo_catalog’, ’master_node’, 1, 0); COMMIT WORK;
-- Set the catalog to be the current catalog. SET CATALOG sync_demo_catalog; COMMIT WORK;
-- Create the table that will be synchronized. CREATE TABLE SYNCDEMO ( REPLICAID INTEGER NOT NULL, ID INTEGER NOT NULL, STATUS INTEGER NOT NULL, INTDATA INTEGER, TEXTDATA CHAR(30), UPDATETIME TIMESTAMP, PRIMARY KEY (REPLICAID, ID, STATUS) ); --Enable syncronization history for the table ALTER TABLE SYNCDEMO SET SYNCHISTORY; COMMIT WORK;
-- Create a publication that publishes all data of the SYNCDEMO table. -- Note: CREATE PUBLICATION commands must be inside double quotation marks.
"CREATE PUBLICATION PUB_DEMO BEGIN RESULT SET FOR SYNCDEMO BEGIN SELECT * FROM SYNCDEMO ; END END"; COMMIT WORK;
The PUB_DEMO publication contains all the rows in the syncdemo table. Refreshes from this publication will be incremental because the SYNCHISTORY property is set for this table in both the master and replica databases. See solidDB® SQL Guide for more information about the SYNC_SETUP_CATALOG stored procedure.