This tutorial will make use of the pre-defined DSNs repdb1_1121 and repdb2_1121 shipped with TimesTen 11.2.1. The hostnames of the two machines in the examples are stacb12 and stach17. repdb1_1121 is the active database on stacb12, and repdb2_1121 on stach17 is the standby database.
In order to set up an active standby database, you need to first create an active master database. This database must include a user with the ADMIN privilege, and an application user with some tables to demonstrate data replication.
2. Create a Database User to Administer the Replication Operations
a. Log in to server 1 (stacb12) as the instance administrator and define a DSN for the active master database. In this example we will use a pre-defined DSN repdb1_1121
Refer to the section Setting up Data Source Name if you need information on how to define your own DSNs.b. Create and connect to the database repdb1_1121 using ttIsql ttisql repdb1_1121 If necessary, refer to the section Creating a TimesTen Database for more information.
a. Create a database user and assign it the role of the database and replication administrator. This user is responsible for setting up and managing the active standby pair.
In ttIsql, create an administrator and grant this user admin privilege. In the example, the user adm is the administrator
create user adm identified by adm;
grant admin to adm;b. Create an application user and tables in the database. In our example, we will create an application user called appuser and this user will own the customers and orders tables. create user appuser identified by appuser;
grant create session, create table to appuser;c. Log in as the user appuser in ttIsql. Execute the following SQL statements, or run the script create_appuser_obj.sql located in the quickstart/sample_scripts/replication directory, to create the 2 tables in the appuser schema. connect "dsn=repdb1_1121;uid=appuser"; run "quickstart/sample_scripts/replication/create_appuser_obj.sql" create table customers (
cust_number number,
first_name varchar2(12) not null,
last_name varchar2(12) not null,
address varchar2(100) not null,
primary key (cust_number));insert into customers values (3700,'Peter','Burchard','882 Osborne Avenue, Boston, MA 02122');
insert into customers values (1121,'Saul','Mendoza','721 Stardust Street, Mountain View, CA 94043');create table orders (
order_number number not null,
cust_number number not null,
prod_number char(10) not null,
order_date date not null,
primary key (order_number),
foreign key (cust_number) references customers (cust_number));insert into ORDERS values (6853036,3700,'0028616731',to_date('2008-04-05','yyyy-mm-dd'));
insert into ORDERS values (6853041,3700,'0198612710',to_date('2009-01-12','yyyy-mm-dd'));
insert into ORDERS values (6853169,1121,'0003750299',to_date('2008-08-01','yyyy-mm-dd'));
insert into ORDERS values (6853174,1121,'0789428741',to_date('2008-10-25','yyyy-mm-dd'));
insert into ORDERS values (6853179,1121,'0198612583',to_date('2009-02-02','yyyy-mm-dd'));d. Use the tables command in ttIsql to confirm that the tables have been created. tables;
After setting up an initial database, you can now define the configuration of the active standby pair and assign to the current database the active state.
Home | Site Map | Contact Us | Copyright © 2011 |