Showing posts with label Timesten. Show all posts
Showing posts with label Timesten. Show all posts

Friday, March 4, 2016

How to backup & restore timesten


 

My environment



OLD Timesten Server
New Timesten Server
Timesten Home
/home/orattadmin/app/TimesTen/tt1121
/u01/app/TimesTen/tt1121
Host
VTGDB1.COM
VTGDB2.COM
User OS
orattadmin
orattadmin
Data source
ttvaaa
ttvaaa
Backup Dir
/home/orattadmin/backup
/u01/app/TimesTen/backup


ON OLD TIMESTEN SERVER


VTGDB1.COM
[orattadmin@VTGDB1.COM backup]$ttBackup -type fileFullEnable -dir /home/orattadmin/backup ttvaaa
[orattadmin@VTGDB1.COM backup]$cd /home/orattadmin/backup
[orattadmin@VTGDB1.COM backup]$ ls
ttvaaa.0.bac  ttvaaa.0.bac64  ttvaaa.sta

Copy all contents of /home/orattadmin/backup to NEW TIMESTEN SERVER (//u01/app/TimesTen/backup)

ON NEW TIMESTEN SERVER


VTGDB2.COM
[orattadmin@VTGDB2.COM backup]$ pwd
/u01/app/TimesTen/backup
[orattadmin@VTGDB2 backup]$ ls
ttvaaa.0.bac  ttvaaa.0.bac64  ttvaaa.sta

Insert or edit in file sys.odbc.ini on folder (/u01/app/TimesTen/tt1121/info)
VTGDB2.COM
[ODBC Data Sources]
ttvaaa=TimesTen 11.2.1 Driver
...
[ttvaaa]
Driver=/u01/app/TimesTen/tt1121/lib/libtten.so
DataStore=/u01/app/ttdata/ttvaaa
LogDir=/u01/app/ttdata
PLSQL_MEMORY_SIZE=100
PermSize=1500
TempSize=100
LogBufMB=100
PLSQL=1
#OracleNetServiceName=vas
Connections=100
DatabaseCharacterSet=WE8MSWIN1252

Restart ttDaemonAdmin
VTGDB2.COM
[orattadmin@VTGDB2.COM info]$ ttDaemonAdmin -restart
TimesTen Daemon stopped.
TimesTen Daemon startup OK.

Restore TimesTen
VTGDB2.COM

[orattadmin@VTGDB2 TimesTen]$ ttRestore -dir /u01/app/TimesTen/backup -fname ttvaaa "dsn=ttvaaa"
Restore started ...
Restore complete


Install Oracle Timesten step by step


Step 1: Create TimesTen user and groups

[root@VTGDB.COM ~]# groupadd timesten
[root@VTGDB.COM ~]# groupadd orattadmin
[root@VTGDB.COM ~]#  useradd -G orattadmin -g timesten orattadmin
[root@VTGDB.COM ~]# id orattadmin
uid=1104(orattadmin) gid=1104(timesten) groups=1104(timesten),1105(orattadmin)
[root@VTGDB.COM ~]# passwd orattadmin
Changing password for user orattadmin.
New password:
BAD PASSWORD: is too simple
Retype new password:
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.

Step 2: Create directories

[root@VTGDB.COM ~]# mkdir -p /etc/TimesTen
[root@VTGDB.COM ~]# chown -R orattadmin:timesten /etc/TimesTen
[root@VTGDB.COM ~]# mkdir -p /u01/app/TimesTen/
[root@VTGDB.COM ~]# chown -R orattadmin:timesten /u01/app/TimesTen/
[root@VTGDB.COM ~]# mkdir -p /u01/app/ttdata/
[root@VTGDB.COM ~]# chown -R orattadmin:timesten /u01/app/ttdata/
[root@VTGDB.COM ~]# chown -R orattadmin:timesten /home/orattadmin

Step 3: Starting setup Timesten Program

Then, Copy the downloaded file to /etc/Timesten
[root@VTGDB.COM TimesTen]# su - orattadmin
[orattadmin@VTGDB.COM ~]$ cd /etc/TimesTen/
[orattadmin@VTGDB.COM TimesTen]$ ls
timesten112180.linux8664.tar.gz
[orattadmin@VTGDB.COM TimesTen]$ tar -xzvf timesten112180.linux8664.tar.gz
linux8664/
linux8664/doc/
linux8664/doc/doc.zip
linux8664/3rdparty/
linux8664/3rdparty/ant-1.6.2-bin.tar.bz2
linux8664/3rdparty/jms-1_1-fr-apidocs.tar.bz2
linux8664/install.pl
linux8664/setup.sh
linux8664/uninst.sh
linux8664/README.html
linux8664/LINUX8664/
linux8664/LINUX8664/manifest
linux8664/LINUX8664/perl
linux8664/LINUX8664/bzip2
linux8664/LINUX8664/unzip
linux8664/LINUX8664/ttpatchinst
linux8664/LINUX8664/common.tar.bz2
linux8664/LINUX8664/ttserver.tar.bz2
linux8664/LINUX8664/timesten.tar.bz2
linux8664/LINUX8664/ttclient.tar.bz2
[orattadmin@VTGDB.COM TimesTen]$ cd linux8664/
[orattadmin@VTGDB.COM linux8664]$ ls
3rdparty  doc  install.pl  LINUX8664  README.html  setup.sh  uninst.sh
[orattadmin@VTGDB.COM linux8664]$ ./setup.sh

NOTE: Each TimesTen installation is identified by a unique instance name.
      The instance name must be a non-null alphanumeric string, not longer
      than 255 characters.

Please choose an instance name for this installation? [ tt1121 ]
Instance name will be 'tt1121'.
Is this correct? [ yes ]

Of the three components:

  [1] Client/Server and Data Manager
  [2] Data Manager Only
  [3] Client Only

Which would you like to install? [ 1 ]

Of the following options :

  [1] /home/orattadmin
  [2] /etc/TimesTen
  [3] Specify a location
  [q] Quit the installation

Where would you like to install the tt1121 instance of TimesTen? [ 1 ] 3
Please specify a directory to install TimesTen? [ /home/orattadmin ] /u01/app/TimesTen/
Where would you like to create the daemon home directory? [ /u01/app/TimesTen/tt1121/info ]

The daemon logs will be located in /u01/app/TimesTen/tt1121/info
Would you like to specify a different location for the daemon logs? [ no ]
Installing into /u01/app/TimesTen/tt1121 ...
Uncompressing ...

NOTE: If you are configuring TimesTen for use with Oracle Clusterware, the
      daemon port number must be the same across all TimesTen installations
      managed within the same Oracle Clusterware cluster.

NOTE: All installations that replicate to each other must use the same daemon
      port number that is set at installation time. The daemon port number can
      be verified by running 'ttVersion'.

The default port number is 53388.

Do you want to use the default port number for the TimesTen daemon? [ yes ]
The daemon will run on the default port number (53388).

NOTE: For security, we recommend that you restrict access to the
      TimesTen installation to members of a single OS group. Only members of
      that OS group will be allowed to perform direct mode connections to
      TimesTen, and only members of that OS group will be allowed to perform
      operations that access TimesTen data stores, TimesTen files and shared
      memory. The OS group defaults to the primary group of the instance
      administrator. You can default to this group, choose another OS group
      or you can make this instance world-accessible. If you choose to make
      this instance world-accessible, all database files and shared memory
      are readable and writable by all users.

Restrict access to the the TimesTen installation to the group 'timesten'? [ yes ]

NOTE: Enabling PL/SQL will increase the size of some TimesTen libraries.

Would you like to enable PL/SQL for this instance? [ yes ]

In order to use the 'In-Memory Database Cache' feature in any databases
created within this installation, you must set a value for the TNS_ADMIN
environment variable. It can be left blank, and a value can be supplied later
using /bin/ttModInstall.

Please enter a value for TNS_ADMIN (s=skip)? [  ] /u01/app/TimesTen/tt1121/network/admin

TNS_ADMIN will be set to /u01/app/TimesTen/tt1121/network/admin
You can change TNS_ADMIN later by running /bin/ttmodinstall.



NOTE: It appears that you are running version 4.1 of the g++
      compiler. TimesTen ships with multiple sets of client libraries and server
      binaries : one built for compatibility with g++ 3.4.6 and one with
      g++ 4.1.0. The installer has created links to the 4.1.0 library in the
      /lib directory and to the 4.1.0 server binary in the
      /bin directory. If you want to use a different compiler,
      please modify the links to point to the desired library and server binary.

Installing server components ...
What is the TCP/IP port number that you want the TimesTen Server to listen on? [ 53389 ]
Do you want to install QuickStart and the TimesTen Documentation? [ no ]
Would you like to install the documentation (without QuickStart)? [ yes ]
Where would you like to create the doc directory (s=skip)? [ /u01/app/TimesTen/tt1121/doc ]
The TimesTen documentation has been installed in /u01/app/TimesTen/tt1121/doc.
Installing client components ...

Would you like to use TimesTen Replication with Oracle Clusterware? [ no ]

NOTE: The TimesTen daemon startup/shutdown scripts have not been installed.

Run the 'setuproot' script :
            cd /u01/app/TimesTen/tt1121/bin
            ./setuproot -install
This will move the TimesTen startup script into its appropriate location.

The startup script is currently located here :
  '/u01/app/TimesTen/tt1121/startup/tt_tt1121'.

The 11.2.1.8 Release Notes are located here :
  '/u01/app/TimesTen/tt1121/README.html'

Starting the daemon ...
TimesTen Daemon startup OK.
End of TimesTen installation.

Step 4: Run the script by root user

Run scripts:
[root@VTGDB.COM  app]# cd /u01/app/TimesTen/tt1121/bin
[root@VTGDB.COM  bin]# ./setuproot -install
Would you like to install the TimesTen daemon startup scripts into /etc/init.d? [ yes ]
Copying /u01/app/TimesTen/tt1121/startup/tt_tt1121 to /etc/init.d

Successfully installed the following scripts :
/etc/init.d/tt_tt1121
/etc/rc.d/rc0.d/K45tt_tt1121
/etc/rc.d/rc1.d/K45tt_tt1121
/etc/rc.d/rc2.d/S90tt_tt1121
/etc/rc.d/rc3.d/S90tt_tt1121
/etc/rc.d/rc5.d/S90tt_tt1121
/etc/rc.d/rc6.d/K45tt_tt1121

Setting environment for TimesTen

Step 5: Setting environment for TimesTen
[orattadmin@VTGDB.COM ~]$ vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
            . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
# Set environment for Timesten
export TIMESTEN_HOME=/u01/app/TimesTen/tt1121
export TNS_ADMIN=$TIMESTEN_HOME/network/admin
export PATH=$PATH:$TIMESTEN_HOME/bin
source $TIMESTEN_HOME/bin/ttenv.sh

[orattadmin@VTGDB.COM ~]$ .  .bash_profile
NOTE: TNS_ADMIN is already set in environment - /u01/app/TimesTen/tt1121/network/admin

LD_LIBRARY_PATH set to /u01/app/TimesTen/tt1121/lib:/u01/app/TimesTen/tt1121/ttoracle_home/instantclient_11_1

PATH set to /u01/app/TimesTen/tt1121/bin:/u01/app/TimesTen/tt1121/quickstart/sample_code/oci:/u01/app/TimesTen/tt1121/quickstart/sample_code/odbc:/u01/app/TimesTen/tt1121/quickstart/sample_code/odbc/xla:/u01/app/TimesTen/tt1121/quickstart/sample_code/jdbc:/u01/app/TimesTen/tt1121/quickstart/sample_code/odbc_drivermgr:/u01/app/TimesTen/tt1121/quickstart/sample_code/proc:/u01/app/TimesTen/tt1121/quickstart/sample_code/ttclasses:/u01/app/TimesTen/tt1121/quickstart/sample_code/ttclasses/xla:/u01/app/TimesTen/tt1121/ttoracle_home/instantclient_11_1:/u01/app/TimesTen/tt1121/ttoracle_home/instantclient_11_1/sdk:/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/orattadmin/bin

CLASSPATH set to /u01/app/TimesTen/tt1121/lib/ttjdbc5.jar:/u01/app/TimesTen/tt1121/lib/orai18n.jar:/u01/app/TimesTen/tt1121/lib/timestenjmsxla.jar:/u01/app/TimesTen/tt1121/3rdparty/jms1.1/lib/jms.jar:.


Tuesday, March 1, 2016

Setting up an Active Standby Timesten



Active
Standby
Server: 192.168.2.149(vtgptudserver)
Data Store: master1
Installing Directory:/u01/app/TimesTen/tt1121
Port's Daemon: 53396
Port TCP/IP Server TimesTen listen on: 53397

Server: 192.168.2.133 ( PTUDServer3)
Data Store: master2
Installing Directory:/u01/app/TimesTen/tt1122/
Daemon port: 53388
Port TCP/IP Server TimesTen listen on: 53389

1.   Create an Active Master Database
a. Log in to server 1 (vtgptudserver) as the instance administrator and define a DSN for the active master database. In this example we will use a pre-defined DSN master1

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 master1 using ttIsql:
ttIsql master1
Active (vtgptudserver)
[orattadmin@vtgptudserver info]$ ttisql master1


Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.

connect "DSN=master1";
Connection successful: DSN=master1;UID=orattadmin;DataStore=/u01/app/TimesTen/tt1122/info/master1;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;DRIVER=/u01/app/TimesTen/tt1122/lib/libtten.so;PermSize=40;TempSize=32;TypeMode=0;
(Default setting AutoCommit=1)
Command>


If necessary, refer to the section Creating a TimesTen Database for more information.

2.   Create a Database User to Administer the Replication Operations


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;
Active (vtgptudserver)
Command> CREATE USER adm IDENTIFIED BY adm;


User created.


Command> 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;
Active (vtgptudserver)
Command> CREATE USER appuser IDENTIFIED BY appuser;


User created.


Command> 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_app_user_obj.sql located in the quickstart/sample_scripts/replication/create_appuser_obj.sql”
Active (vtgptudserver)
connect "dsn=master1;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 has been created.
Active (vtgptudserver)
Command> tables;
  APPUSER.CUSTOMERS
  APPUSER.ORDERS
2 tables found.
Command>
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.
3.   Define the active standby pair
a. In ttIsql, connect to master1 as the replication administrator adm
connect “dsn=master1;uid=adm”;
Active (vtgptudserver)
Command> connect "dsn=master1;uid=adm";
Enter password for 'adm':
Connection successful: DSN=master1;UID=adm;DataStore=/u01/app/TimesTen/tt1122/info/master1;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;DRIVER=/u01/app/TimesTen/tt1122/lib/libtten.so;PermSize=40;TempSize=32;TypeMode=0;
(Default setting AutoCommit=1)
Command>

b. Define an active standby pair schema by using CREATE ACTIVE STANDBY PAIR statement. The default replication mode for an active standby pair is asynchronous.
 CREATE ACTIVE STANDBY PAIR master1 ON "vtgptudserver", master2 ON "PTUDServer3"
Command> CREATE ACTIVE STANDBY PAIR master1 ON "ptudvtg149", master2 ON "PTUDServer3";




Note: The data store names master1 and master2 used in the CREATE ACTIVE STANDBY statement are not DSNs. They are the filenames defined in the DataStore attribute. The hostnames used in defining the active standby pair should match the values returned by the OS hostname command on the respective servers.

c. The ttIsql command repschemes can be used to verify the current replication scheme deployed in the database.
 repschemes;

Active (vtgptudserver)
Command> repschemes;


Replication Scheme Active Standby:


  Master Store: MASTER1 on vtgptudserver
  Master Store: MASTER2 on PTUDSERVER3




  Excluded Tables:
    None


  Excluded Cache Groups:
    None


  Excluded sequences:
    None


  Store: MASTER1 on vtgptudserver
    Port: (auto)
    Log Fail Threshold: (none)
    Retry Timeout: 120 seconds
    Compress Traffic: Disabled


  Store: MASTER2 on PTUDSERVER3
    Port: (auto)
    Log Fail Threshold: (none)
    Retry Timeout: 120 seconds
    Compress Traffic: Disabled


1 replication scheme found.

Command> ALTER ACTIVE STANDBY PAIR
       >   ALTER STORE master1 on "ptudvtg149"SET PORT 53388 TIMEOUT 180
       >   ALTER STORE master2 on "PTUDServer3" SET PORT 53388 TIMEOUT 180;


4.   Start the replication agent

a.
The replication agent is responsible for replicating data between TimesTen databases. It must be running on both databases in an active standby pair. Use the built-in procedure ttRepStart to start the Replication agent.



call ttrepstart;

5.   Set the replication state to Active


Use the built-in procedure ttRepStateSet to designate the current database (repdb1_1121) the active state in the active standby pair. ttRepStateGet returns the current replication state of the database.



call ttrepstateset ('active');
call ttrepstateget;


Active (vtgptudserver)

Command> call ttrepstart;
Command>
Command> call ttrepstateset ('active');
Command> call ttrepstateget;
< ACTIVE, NO GRID >
1 row found.

After setting up an active master database and defining the active standby pair configuration, you can now create the standby database
6.   Duplicate the active database to the standby

a.
Log in to server 2 (PTUDServer3) as the instance administrator. Use the ttRepAdmin utility to duplicate from the active database to the standby database.



ttrepadmin -duplicate -from master1 -host "ptudvtg149" -uid adm -pwd adm "dsn=master2"



Note that the -from clause is using the data store name master1 and not the DSN name; -uid and -pwd correspond to the username and password of the ADMIN user on the active database.
Standby(PTUDServer3)

[orattadmin@PTUDServer3 info]$ ttrepadmin -duplicate  -remoteDaemonPort 53396 -verbosity 2 -from master1 -host "ptudvtg149" -uid adm -pwd adm "dsn=master2"
14:30:15 Contacting remote main daemon at 192.168.2.149 port 53396
14:30:15 Contacting the replication agent for MASTER1 ON PTUDVTG149 (192.168.2.149) port 53388
14:30:15 Beginning transfer from MASTER1 ON PTUDVTG149 to MASTER2 ON PTUDSERVER3
14:30:22 Checkpoint transfer 10 percent complete
14:30:22 Checkpoint transfer 20 percent complete
14:30:22 Checkpoint transfer 100 percent complete
14:30:22 Checkpoint transfer phase complete
14:30:24 Log transfer 100 percent complete
14:30:24 Log transfer phase complete
14:30:24 Transfer complete
14:30:27 Duplicate Operation Ends


7.   Start the replication agent

a.
Using ttIsql, connect to the database master2 as the replication administrator adm.



ttisql "dsn=master2;uid=adm"


b.
The replication agent on the standby is responsible for processing the data from the active database. Use the built-in procedure ttRepStart to start the replication agent.



call ttrepstart;


c.
Wait for master2 to enter the standby state. Use the built-in procedure ttRepStateGet to verify the current replication state of the database.



call ttrepstateget;
Standby(PTUDServer3)

Command> call ttrepstateget;
< STANDBY, NO GRID >
1 row found.


8.   Verify the data is being replicated between the active and the standby

a.
In ttIsql, connect to master1 as appuser, and insert a record into the orders table.



connect "dsn=master1; uid=appuser";
insert into orders values (6853180,1121,'9999999999', sysdate);


Active (vtgptudserver)



b.
Verify that the insert is replicated to the standby database master2.



select * from appuser.orders where order_number=6853180;


Standby(PTUDServer3)




Reference: