Example of rolling out schema changes in a grid
You can roll out schema changes to replicated tables through a grid without shutting down your applications.
Suppose that you have a grid replicate set named gridset that contains 12 replicates, each of which represents a different table. You want to alter the data types of columns in five tables. The grid contains four servers.
To roll out schema changes without application downtime:
- Change any connections from the original application to the replication server named cdr1 to connect to the replication server named cdr2.
- On the cdr1 server, connect to the stores_demo database,
connect to the grid, and alter the five tables:
dbaccess stores_demo - EXECUTE PROCEDURE ifx_grid_connect('grid1', 'gridset', 4); SET LOCK MODE TO WAIT 120; ALTER TABLE customer ADD prefix (char15); ALTER TABLE items MODIFY order_num (bigint); ALTER TABLE stock MODIFY description (lvarchar); ALTER TABLE cust_calls ADD call_descr2 (lvarchar); ALTER TABLE manufact MODIFY manu_name (char32);
The ifx_grid_connect() procedure changes the tables on cdr1 but delays the propagation of the changes to the other replication servers.
- Update the application to reflect the new schema for the five tables and connect to the server cdr1.
- Close the connections from the original application.
- On the server cdr1, propagate schema changes to the other
replication servers by running the following statement:
EXECUTE FUNCTION ifx_grid_release('grid1', 'gridset');
- On the server cdr1, create a derived replicate set named alterSet that
contains the altered tables by running the following command:
cdr define replicateset --needRemaster=gridset alterSet
- From the server cdr1, remaster the altered tables on all
replication servers by running the following command:
cdr remaster replicateset --master=cdr1 alterSet
- From the server cdr1, synchronize the data on all replication
servers by running the following command:
cdr check replicateset --replset=alterSet --repair --master=cdr1 --all
- On the server cdr1, drop the derived replicate set by running
the following command:
cdr delete replicateset alterSet