Data Synchronization experience of DB2 (1)

Source: Internet
Author: User

Planning Scheme

Assume that you will use an application that generates the report. This application requires data in the DEPARTMENT table of the SAMPLE database. Instead of copying data directly from the source table, you want to copy the changes to the target table that can only be read by the report-generating application. To facilitate management, you need to save the target table and the source table on the same machine. It can also be other databases on the network where the local machine has been imported.

Data Replication solution implementation steps

Before getting started
1. First, confirm that db2 has been installed on the machine on which the replication plan is to be implemented, and an instance has been created.
2. determine the source database and target database to be copied by the user. The database can be on the same machine or on the network and must be catalogued locally.
3. Make sure that you have access to the source and target databases. Assume that the source database is the sample database, and the target database is the copydb database.
4. Create a copydb database on your machine.

Plan this solution
1. Copy Source
You already know that the replication source is the schema. DEPARTMENT table in the sample database. Before setting your environment, you must decide what content you want to copy from the table; you decide to register all columns and reserve all columns.
2. Replication target
You decided to copy the target copydb database, which was created before the start. Currently, there are no target tables in the database. You want the Replication Center to create the target table according to your specifications. This automatic generation of the target table is preferred because it ensures that it is correctly mapped to the replication source. You can also use an existing target table. However, this scheme assumes that the target table does not exist.
3. Copy Option
For the purpose of this scheme, you decide to store CD tables, target tables, and replication control tables in their default tablespace respectively. Although the SAMPLE and COPYDB databases exist on the same machine, their tablespace is located in different containers.
Set the environment for this solution plan

Step 1: Create a control table for the Capture program

The Capture program reads the current registration information from the replication control table and stores its status in these tables. Any database that will act as the Capture control server must contain the Capture control table.
1. Open the Replication Center and expand the SQL copy folder.
2. Expand the definition folder.
3. Right-click the Capture control server folder and choose create Capture control table-> quick. Alternatively, you can choose to create a custom Capture control table.
4. In the Select Server window, select the SAMPLE database. This database will act as the Capture control server. Click OK.
5. In the "create control table-quick-Server Information" window, select the source for the supervisor to copy and capture changes to those sources. Then, click Next.
6. In the "create control table-quick-copy details" window, click Next. You do not need to change any information in this window.
7. In the "Create control table-fast-tablespace" window, enter the table space specification of TSASNCA. For example, set the buffer pool to ibmdefabp bp. For this solution, accept the default Capture Mode-ASN.
8. In the "Create control table-fast-tablespace" window, enter the table space specification for TSASNUOW.
9. Enter information about the two tablespaces in the "Create control table-fast-tablespace" window and click OK.
10. Click Close in the message dialog box. This window displays the results of generating the SQL script that will create the Capture control table. If any errors are generated, these errors are displayed in this window.
11. enter a valid user ID and password in the "run now or save SQL" window, and click OK to run the SQL script immediately.
12. In the DB2 message window, you should see a message indicating that the script has been successfully run. Click Close.
13. Expand the Capture control server folder. The SAMPLE database should be displayed in this folder.

Step 2: Enable the database for replication

The Capture program reads DB2 logs to obtain the log records including changes to the registered table. Logs must be archived so that DB2 will no longer use log files before the Capture program can read logs. For UNIX (R) and Windows environments, the default value of DB2 is cyclic logging. Therefore, you must change this setting to archive logging.

Step 3: register the replication source

After creating a Capture control table and enabling the database for replication, register the DEPARTMENT table as the replication source.

Registration steps:
1. Expand the SQL copy folder.
2. Expand the definition folder.
3. Expand the Capture control server folder.
4. Expand the SAMPLE database.
5. Expand the Capture Mode folder.
6. Expand the ASN mode.
7. Right-click the registered table folder and select registry.
8. In the "add registrable tables" window, click search all to list all tables that can be registered as the replication source in the SAMPLE database. Select the DEPARTMENT table and click OK.
9. In the Registry window, click the CD table notebook tab. Specify the following information about the CD tablespace:
O in the standard area of the tablespace, click the container Name field to specify the container name of the tcontent Department tablespace.
O in the standard area of the tablespace, change the size field to 1.
O in the standard area of the tablespace, change the Unit Field to MB.
O specify other information about the new tablespace. For example, set the buffer pool to ibmdefabp bp.
After entering the tablespace information, click OK.
10. Click Close in the message dialog box. | This window displays the result of generating an SQL script that will register the source table. If any errors are generated, these errors are displayed in this window.
11. Click OK in the "run now or save SQL" window to run the SQL script immediately.
12. In the DB2 message window, you should see a message indicating that the script has been successfully run. Click Close.
13. The DEPARTMENT table should be displayed as the registered table in the content pane of the SAMPLE database folder.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.