![]() |
The product list data is updated in headquarters in Toronto. This company used to send weekly CDs containing its complete list of products and their prices to its divisions and all the branches.
In this chapter we will see how Company XYZ can benefit from Empress
Replication to distribute the product list more efficiently.
3.1.2 Format of each Scenario
Each replication scenario starts with a graphical representation. The operational assumption is that the tables of each side live in separate databases on separate hosts. A description of the scenario and its operations are given. Each separate Operation is assigned a unique number. When applicable, a hyperlink to a detail explanation of the steps of each operation is provided.
General format of the operations are:
The practical SQL commands and utility usage that can be performed for each operation are given after each command. For each scenario, a link to the script is given in [Scenario Scripts]. A brief explanation of the terms used in this chapter and throughout the rest of the manual is given in [Glossary].
The assumptions for the examples of this chapter are as follows:
In any Replication Relation, RMT side is shown with M and RRT side with R.
Product List in Location "xxx" is in a table called xxxPList, in a database called xxxDB in a host named xxxHost.
$xxxHost are variables set to the physical location (Host Address, or IP address) of their corresponding hosts.
$xxxDB are variables set to the physical database name (including actual Path to the database) of their corresponding databases.
TorontoPList, the table containing the original source data is defined as follows:
*** Table: TorontoPList *** Attributes: prod_id integer Not Null prod_name character(50,1) Not Null prod_price float(5) prod_lang character(20,1) Indices: PRIMARY KEY BTREE ON (prod_id) Lock Level: RECORD
Lines that start with "xxx%" can be executed as operating system commands. For example
TorontoHost% OS_Command
Lines that start with "xxxDB>" can be executed as SQL commands in xxxDB database. For example
TorontoDB> SQL_command;
$xxx_RM_info is a variable that contains information to access a Replication Master Table xxxPList. This RMT Side access information is a combination of :
'replication master server':'database name with full path':'RMT'
$Toronto_RM_info='TorontoRepServer':'/usr/empress/TorontoDB':'TorontoPList'
$xxx_RR_info is a variable that contains information to access a Replication Replicate Table xxxPList. This RRT Side access information is a combination of :
'host':'database name with full path':'RRT'
$Brooklyn_RR_info='BrooklynHost':'/usr/empress/BrooklynDB':'BrooklynDB'
![]() |
This is the simplest form of a Replication. This configuration deals with a master table TorontoPList and a replicate table NewYorkPList.
Operations OpA1, OpA2, and OpA3 can be performed to define a Master Table and start a Replication Master Server to serve this Master Table.
TorontoDB: OpA1.
Define master table (TorontoPList)
TorontoDB> ALTER TABLE TorontoPList CHANGE TABLE TYPE TO MASTER;
TorontoHost: OpA2.
Configure Network Server on RMT Side (TorontoRepServer)
Explanation of OpA2:
Configure a Replication Master Server TorontoRepServer in TorontoHost. This is configuring the environment variables and configuration files to be used by the Replication Master Server.
MSNETSERVER ... NAME=TorontoRepServer TYPE=replication_master HOST=localhost PORT_ADMIN=12340 PORT_SERVICE=12345 ADMINISTRATOR=${USER} ... MSNETSERVEREND
TorontoHost: OpA3.
Start Replication Master Server (TorontoRepServer)
TorontoHost% empsvadm TorontoRepServer start
Operations OpA4, OpA5 and OpA6 are used to authorize table NewYorkPList as candidate RRT of TorontoPList, and to create replicate table NewYorkPList as an RRT of TorontoPList.
TorontoDB: OpA4.
Create Replication Replicate
(NewYorkPList, TorontoPList)
TorontoDB> CREATE REPLICATION REPLICATE $NewYork_RR_info ON TorontoPList;
NewYorkHost: OpA5.
Configure Network Server on RRT Side (NewYorkPList)
Explanation of OpA5:
Configure Network Server on the RRT (client) side NewYorkPList.
This configuration makes connection to Replication Master Server in
TorontoHost possible. This connection is required so that RMT
TorontoPList and RRT NewYorkPList would be able to exchange
data.
MSNETSERVER ... NAME=TorontoRepServer TYPE=replication_master HOST=TorontoHost.XYZ.com PORT_ADMIN=12340 PORT_SERVICE=12345 ADMINISTRATOR=${USER} ... MSNETSERVEREND
NewYorkDB: OpA6.
Create Replicate Table (NewYorkPList,
TorontoPList)
NewYorkDB> CREATE REPLICATE TABLE NewYorkPList FROM $Toronto_RM_info
NewYorkHost: OpA7.
Perform a Synchronization (NewYorkPList)
NewYorkHost% emprepsync NewYorkDB NewYorkPList
NewYorkDB: OpA8.
View Replication Table and Synchronization Status
(NewYorkPList)
NewYorkDB> DISPLAY TABLE NewYorkPList ALL; NewYorkDB> SELECT * FROM NewYorkPList;
TorontoHost: OpA9.
Stop Replication Master Server (TorontoRepServer)
TorontoHost% empsvadm TorontoRepServer stop
![]() |
Note that in this scenario, NewYorkPList being RRT or RMT depends on the Replication Relationship which it participates in. In replication relation with TorontoPList, NewYorkPList is an RRT, and in relationship with BrooklynPList, NewYorkPList is the RMT. So there is no "absolute" RMT or RRT in Empress Replication concepts.
The operations OpB1, OpB2, OpB3, OpB4, OpB5 and OpB6 can be executed to define TorontoPList as Master Table, start a Replication Master Server to serve TorontoPList, and create NewYorkPList as its RRT.
TorontoDB: OpB1.
Define master table (TorontoPList)
TorontoDB> ALTER TABLE TorontoPList CHANGE TABLE TYPE TO MASTER;
TorontoHost: OpB2.
Configure Network Server on RMT Side (TorontoRepServer)
Create $HOME/.empress/netserver.cfg file as follows:
MSNETSERVER NAME=TorontoRepServer TYPE=replication_master HOST=localhost PORT_ADMIN=12340 PORT_SERVICE=12345 ADMINISTRATOR=${USER} MSNETSERVEREND
TorontoHost: OpB3.
Start Replication Master Server TorontoRepServer)
TorontoHost% empsvadm TorontoRepServer start
TorontoDB: OpB4.
Create Replication Replicate
(NewYorkPList, TorontoPList)
TorontoDB> CREATE REPLICATION REPLICATE ${NewYork_RR_info} ON TorontoPList;
NewYorkHost: OpB5.
Configure Network Server on RRT Side (NewYorkPList)
Create $HOME/.empress/netserver.cfg file as follows:
MSNETSERVER NAME=TorontoRepServer TYPE=replication_master HOST=TorontoHost.XYZ.com PORT_ADMIN=12340 PORT_SERVICE=12345 ADMINISTRATOR=${USER} MSNETSERVEREND
NewYorkDB: OpB6.
Create Replicate Table and Load Data (NewYorkPList,
TorontoPList)
NewYorkDB> CREATE AND INSERT INTO REPLICATE TABLE NewYorkPList FROM $Toronto_RM_info
NewYorkHost: OpB7.
Configure Network Server on RMT Side (NewYorkRepServer)
Explanation of OpB7:
Append the following block to the end of the already existing Network
Server Configuration File (netserver.cfg). This is for
configuring a new Replication Master Server called
NewYorkRepServer. Note that the NAME, PORT_ADMIN and
PORT_SERVICE are different from the block belonging to
TorontoRepServer.
MSNETSERVER NAME=NewYorkRepServer TYPE=replication_master HOST=localhost PORT_ADMIN=12350 PORT_SERVICE=12355 ADMINISTRATOR=${USER} MSNETSERVEREND
NewYorkHost: OpB8.
Start Replication Master Server (NewYorkRepServer)
NewYorkHost% empsvadm NewYorkRepServer start
NewYorkDB: OpB9.
Create Replication Replicate
(BrooklynPList, NewYorkPList)
NewYorkDB> CREATE REPLICATION REPLICATE $Brooklyn_RR_info ON NewYorkPList;
BrooklynHost: OpB10.
Configure Network Server on RRT Side (BrooklynPList)
Configure the synchronization utility for BrooklynPList in BrooklynHost.
This allows BrooklynPList to perform synchronization with its
RMT NewYorkPList.
In a Network Configuration Block for Replication Master Server set name of the Replication Master Server (to "NewYorkRepServer" in this case). In the same configuration Block, set host address of the Replication Master Server (in this example, set it to the actual internet address of the host containing "NewYorkRepServer", which would be something like "NewYorkHost.XYZ.com"). Create the file $HOME/.empress/netserver.cfg to look as follows:
MSNETSERVER NAME=NewYorkRepServer TYPE=replication_master HOST=NewYorkHost.XYZ.com PORT_ADMIN=12350 PORT_SERVICE=12355 ADMINISTRATOR=${USER} MSNETSERVEREND
BrooklynDB: OpB11.
Create Replicate Table and Load Data (BrooklynPList,
NewYorkPList)
BrooklynDB> CREATE AND INSERT INTO REPLICATE TABLE BrooklynPList FROM ${NewYork_RM_info};
![]() |
After adding Toronto as an alternative Source of data for the Brooklyn branch,
the computer in Brooklyn can choose among the two sources and select the
available one with the smallest Replication Master Order.
Choosing a different RMT from the previous chosen RMT is called RMT Switch. The selection of the appropriate source of data is done automatically by synchronization utility. However, the administrator of Brooklyn branch can manually alter the list of candidate RMTs, to affect the automatic RMT Selection. The manual alteration of the list of candidate RMTs is described in Scenarios D and E.
3.4.2 Steps for Creating the Scenario
The script of commands to set up this scenario and to later undo the effects of it are given in
[Scripts: Scenario C].
This scenario adds TorontoPList as an alternative RMT for BrooklynPList. BrooklynPList is an RRT of NewYorkPList, which is itself an RRT of TorontoPList. This scenario allows BrooklynPList to perform synchronization with TorontoPList whenever NewYorkPList is not accessible, or when the administrator of BrooklynPList wants to do so.
The relation between BrooklynPList and NewYorkPList is shown with "0". This number is indicates the Replication Master Order of NewYorkPList as RMT for BrooklynPList. This relation is created before the relation between BrooklynPList and TorontoPList, which is shown with "1". This means that synchronization of BrooklynPList is first tried to be done with NewYorkPList. If a connection between synchronization utility accessing BrooklynPList and the Replication Master Server accessing NewYorkPList can not be established, then synchronization utility will look for the RMT with a higher Replication Master Order for BrooklynPList, which is TorontoPList.
Execute the operations of Scenario B to create the same configuration. Execute OpC1 to authorize BrooklynPList to be an RRT of TorontoPList.
TorontoDB: OpC1.
Create Replication Replicate
(BrooklynPList, TorontoPList)
TorontoDB> CREATE REPLICATION REPLICATE $Brooklyn_RR_info ON TorontoPList;
BrooklynHost: OpC2.
Configure Network Server on RRT Side (BrooklynPList)
Explanation of OpC2:
Append the following block to the end of the already existing Network
Server Configuration File (netserver.cfg). This is for the
Synchronization Utility residing at BrooklynHost to recognize a
TorontoRepServer as a Replication Master Server.
Note that the NAME, PORT_ADMIN and
PORT_SERVICE are different from the block belonging to
NewYorkRepServer.
MSNETSERVER NAME=TorontoRepServer TYPE=replication_master HOST=TorontoHost.XYZ.com PORT_ADMIN=12340 PORT_SERVICE=12345 ADMINISTRATOR=${USER} MSNETSERVEREND
BrooklynDB: OpC3.
Create Replication Master (TorontoPList, BrooklynPList)
BrooklynDB> CREATE REPLICATION MASTER $Toronto_RM_info ON BrooklynPList;
BrooklynDB: OpC4.
View Replication Table and Synchronization Status
(BrooklynPList)
BrooklynDB> DISPLAY TABLE BrooklynPList ALL;
![]() |
The script of commands to set up this scenario and to later undo its effects are given in [Scripts: Scenario D]. This scenario, has the same configuration as Scenario C, only that TorontoPList has a smaller order number than NewYorkPList as an RMT for BrooklynPList. So, the synchronization for BrooklynPList is first tried to connect to be done with TorontoPList. If a connection between RRT side in BrooklnHost and RMT side in TorontoHost can not be established, the synchronization utility will check for validity of NewYorkPList for performing the synchronization.
Execute the same operations as in Scenario C to have the same model.
Execute OpD1 to change the Replication Master Order for BrooklynPList.
BrooklynDB: OpD1.
Change the Replication Master Order
(BrooklynPList, NewYorkPList, order)
BrooklynDB> ALTER TABLE BrooklynPListCHANGE REPLICATION MASTER ORDER $NewYork_RM_info 4, $Toronto_RM_info 3;
![]() |
The script of commands to set up this scenario and to later undo its effects are given in [Scripts: Scenario E]. In this scenario, the TorontoPList is disabled from being a replication master for BrooklynPList. It means that even if the replication relation between TorontoPList and BrooklynPList exist, synchronization utility on BrooklynHost does not consider TorontoPList as an RMT for BrooklynPList when doing synchronization for BrooklynPList, regardless of the Replication Master Order of TorontoPList.
Perform the operation OpE1 to disable TorontoPList from being an RMT of BrooklynPList.
BrooklynDB: OpE1.
Disable the Replication Master (BrooklynPList, TorontoPList)
BrooklynDB> ALTER TABLE BrooklynPList DISABLE REPLICATION MASTER $Toronto_RM_info ;
BrooklynDB: OpE2.
Enable the Replication Master (BrooklynPList, TorontoPList)
BrooklynDB> ALTER TABLE BrooklynPList ENABLE REPLICATION MASTER $Toronto_RM_info ;
![]() |
The script of commands to set up this scenario and to later undo its effects are given in [Scripts: Scenario F]. In this scenario NewYorkPList from NewYorkDB will be the new Master Table for the replication world which TorontoPList, NewYorkPList and BrooklynPList belong to. When NewYorkPList becomes a Master Table, it is not a read-only table anymore, so the users of NewYorkPList can modify the table. BrooklynPList is a Replicate of NewYorkPList and performs the synchronization with this table.
Perform operations in [Scenario B] to create the same scenario. Then perform operation OpF1 to change the table type of NewYorkPList, from REPLICATE to MASTER. This operation is usually needed when TorontoPList is not physically available, or a connection to TorontoHost can not be established from the RRT side where NewYorkPList resides.
NewYorkDB: OpF1. Define master table (NewYorkPList)
NewYorkDB> ALTER TABLE NewYorkPList CHANGE TABLE TYPE TO MASTER;
Before changing the type of NewYorkPList to a replicate table, it is a good practice to change the original master table into an RRT of the current Master Table NewYorkPList, then synchronize it with NewYorkPList, so that TorontoPList would be up-to-date before becoming the current master table. Perform the following operations to synchronize TorontoPList with NewYorkPList.
NewYorkDB: OpF2. Create Replication Replicate
(TorontoPList, NewYorkPList)
NewYorkDB> CREATE REPLICATION REPLICATE $Toronto_RR_Info ON NewYorkPList;
TorontoDB: OpF3. Create Replication Master (TorontoPList, BrooklynPList)
TorontoDB> CREATE REPLICATION MASTER $NewYork_RM_info ON TorontoPList;
TorontoDB: OpF4.
Change Table type to Replicate (TorontoPList)
TorontoDB> ALTER TABLE TorontoPList CHANGE TABLE TYPE TO REPLICATE;
TorontoHost: OpF5. Perform a Synchronization (TorontoPList)
TorontoHost% emprepsync TorontoDB TorontoPList
TorontoDB: OpF6. Change Table Type to Master(TorontoPList)
TorontoDB> ALTER TABLE TorontoPList CHANGE TABLE TYPE TO MASTER;
NewYorkDB: OpF7.
Change Table type to Replicate (NewYorkPList)
NewYorkDB> ALTER TABLE NewYorkPList CHANGE TABLE TYPE TO REPLICATE;
![]() |
The script of commands to set up Subset Replication scenario are given in [Scripts: Scenario G]. In this example, a certain subset of the rows of TorontoPList are replicated to NewYorkPList, and a certain subset of the rows of TorontoPList are replicated to TokyoPList during synchronization. Subset replication, replicates rows from the master table that satisfy a predetermined condition. The subset condition is a restricted SQL Where Clause, called Subset Replication Search Condition (SRSC).
A Master Table whose subset of rows will be replicated, must have a primary key defined for it. The master table will specify the list of its attributes that will participate in selecting the rows of a subset replication. This attribute list is called Subset Attribute List (SAL). Operation OpG1. establishes a Master Table along with specifying the SAL. Perform operations OpG2. and OpG3. to start a Replication Master Server for TorontoPList.
TorontoDB: OpG1.
Establish Master Table with Subset attribute List
(TorontoPList, SAL)
TorontoDB> ALTER TABLE TorontoPList CHANGE TABLE TYPE TO MASTER FOR SUBSET ON (prod_lang);
TorontoHost: OpG2.
Configure Network Server on RMT Side (TorontoRepServer)
Create $HOME/.empress/netserver.cfg file as follows:
MSNETSERVER NAME=TorontoRepServer TYPE=replication_master HOST=localhost PORT_ADMIN=12340 PORT_SERVICE=12345 ADMINISTRATOR=${USER} MSNETSERVEREND
TorontoHost: OpG3.
Start Replication Master Server (TorontoRepServer)
TorontoHost% empsvadm TorontoRepServer start
TorontoDB: OpG4.
Create Replication Replicate with Selected Rows
(TorontoPList, NewYorkPList, "SRSC_english_products")
TorontoDB> CREATE REPLICATION REPLICATE ${NewYork_RR_info} ON TorontoPList WHERE prod_lang = 'english';
TorontoDB: OpG5.
Create Replication Replicate with Selected Rows
(TorontoPList, TokyoPList, "SRSC_japanese_products")
TorontoDB> CREATE REPLICATION REPLICATE $Tokyo_RR_info ON TorontoPList WHERE prod_lang = 'japanese';
NewYorkHost: OpG6.
Configure Network Server on RRT Side (NewYorkPList)
Create $HOME/.empress/netserver.cfg file as follows:
MSNETSERVER NAME=TorontoRepServer TYPE=replication_master HOST=TorontoHost.XYZ.com PORT_ADMIN=12340 PORT_SERVICE=12345 MSNETSERVEREND
NewYorkDB: OpG7. Create Replicate Table (NewYorkPList, TorontoPList)
NewYorkDB> CREATE AND INSERT INTO REPLICATE TABLE NewYorkPList FROM $Toronto_RM_info ;
TokyoHost: OpG8.
Configure Network Server on RRT Side (TokyoPList)
Create $HOME/.empress/netserver.cfg file as follows:
MSNETSERVER NAME=TorontoRepServer TYPE=replication_master HOST=TorontoHost.XYZ.com PORT_ADMIN=12340 PORT_SERVICE=12345 MSNETSERVEREND
TokyoDB: OpG9. Create Replicate Table (TokyoPList, TorontoPList)
TokyoDB> CREATE AND INSERT INTO REPLICATE TABLE TokyoPList FROM $Toronto_RM_info ;
NewYorkHost: OpG10. Perform a Synchronization (NewYorkPList)
NewYorkHost% emprepsync NewYorkDB NewYorkPList
TokyoHost: OpG11. Perform a Synchronization (TokyoPList)
TokyoHost% emprepsync TokyoDB TokyoPList