Use of Oracle memory database Timesten (2)
This article describes how to synchronize Timesten with Oracle.
To synchronize data with Oracle, you must create a tablespace and a user in Oracle.
1. Create a tablespace
This tablespace will be used by timesten user and cache administrator user. This tablespace should be used only to store cache-related objects, rather than sharing it with other applications.
CREATE TABLESPACE TIMESTEN DATAFILE '/u01/app/oradata/timesten/tbs_timesten.dbf' SIZE 300M;
2. Create a Timesten user
Run the initCacheGlobalSchema. SQL script and pass in the created tablespace name. The script is located at % TimesTen_install_dir %/oraclescripts
SQL> @E:/temp/oraclescripts/initCacheGlobalSchema.sql "TIMESTEN"Cannot SET TRIMSPOOLCannot SET TABPlease enter the tablespace where TIMESTEN user is to be createdThe value chosen for tablespace is TIMESTEN******* Creation of TIMESTEN schema and TT_CACHE_ADMIN_ROLE starts *******1. Creating TIMESTEN schema2. Creating TIMESTEN.TT_GRIDID table3. Creating TIMESTEN.TT_GRIDINFO table4. Creating TT_CACHE_ADMIN_ROLE role5. Granting privileges to TT_CACHE_ADMIN_ROLE** Creation of TIMESTEN schema and TT_CACHE_ADMIN_ROLE done successfully **
3. Create a cache Administrator
Here, the user name uses cacheuser and the password uses oracle. Run the script grantCacheAdminPrivileges. SQL in the % TimesTen_install_dir %/oraclescripts directory and pass in cacheuser as the parameter.
To execute this script, you must use sys to execute the script. If you have DBA permissions, some permissions cannot be authorized.
SQL>CREATE USER CACHEUSER IDENTIFIED BY ORACLE DEFAULT TABLESPACE TIMESTEN QUOTA UNLIMITED ON TIMESTEN;uesr createdSQL> @E:/temp/oraclescripts/grantCacheAdminPrivileges.sql "CACHEUSER";Cannot SET TRIMSPOOLCannot SET TABPlease enter the administrator user idThe value chosen for administrator user id is CACHEUSER***************** Initialization for cache admin begins ******************0. Granting the CREATE SESSION privilege to CACHEUSER1. Granting the TT_CACHE_ADMIN_ROLE to CACHEUSER2. Granting the DBMS_LOCK package privilege to CACHEUSERORA-01031: insufficient privileges3. Granting the CREATE SEQUENCE privilege to CACHEUSER4. Granting the CREATE CLUSTER privilege to CACHEUSER5. Granting the CREATE OPERATOR privilege to CACHEUSER6. Granting the CREATE INDEXTYPE privilege to CACHEUSER7. Granting the CREATE TABLE privilege to CACHEUSER8. Granting the CREATE PROCEDURE privilege to CACHEUSER9. Granting the CREATE ANY TRIGGER privilege to CACHEUSER10. Granting the GRANT UNLIMITED TABLESPACE privilege to CACHEUSER11. Granting the DBMS_LOB package privilege to CACHEUSERORA-01031: insufficient privileges12. Granting the SELECT on SYS.ALL_OBJECTS privilege to CACHEUSER13. Granting the SELECT on SYS.ALL_SYNONYMS privilege to CACHEUSER14. Checking if the cache administrator user has permissions on the default tablespace Permission exists16. Granting the CREATE TYPE privilege to CACHEUSER17. Granting the SELECT on SYS.GV$LOCK privilege to CACHEUSER (optional) ORA-01031: insufficient privileges18. Granting the SELECT on SYS.GV$SESSION privilege to CACHEUSER (optional) ORA-01031: insufficient privileges19. Granting the SELECT on SYS.DBA_DATA_FILES privilege to CACHEUSER (optional) ORA-01031: insufficient privileges20. Granting the SELECT on SYS.USER_USERS privilege to CACHEUSER (optional) 21. Granting the SELECT on SYS.USER_FREE_SPACE privilege to CACHEUSER (optional) 22. Granting the SELECT on SYS.USER_TS_QUOTAS privilege to CACHEUSER (optional) 23. Granting the SELECT on SYS.USER_SYS_PRIVS privilege to CACHEUSER (optional) ** Initialization for cache admin user could not be successfully done **
I use a script executed by a user with DBA permissions, so some permissions cannot be authorized, as shown below:
[oracle@bogon ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Fri Jul 31 11:57:54 2015Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> GRANT EXECUTE ON SYS.DBMS_LOCK TO cacheuser;Grant succeeded.SQL> GRANT EXECUTE ON SYS.DBMS_LOB TO cacheuser;Grant succeeded.SQL> GRANT SELECT ON SYS.GV_$LOCK TO cacheuser;Grant succeeded.SQL> GRANT SELECT ON SYS.GV_$SESSION TO cacheuser;Grant succeeded.SQL> GRANT SELECT ON SYS.DBA_DATA_FILES TO cacheuser;Grant succeeded.
Sort the script here for future calls
GRANT EXECUTE ON SYS.DBMS_LOCK TO cacheuser;GRANT EXECUTE ON SYS.DBMS_LOB TO cacheuser;GRANT SELECT ON SYS.GV_$LOCK TO cacheuser;GRANT SELECT ON SYS.GV_$SESSION TO cacheuser;GRANT SELECT ON SYS.DBA_DATA_FILES TO cacheuser;
The Oracle operation has basically ended. The following content needs to be configured for Timesten:
4. Configure TNS_ADMIN
[timesten@bogon ~]$ ttModInstall -tns_admin /opt/oracle/TimesTen/tt1122/ttoracle_home/instantclient_11_2/network/admin;TNS_ADMIN for the instance 'tt1122' is currently not set.Would you like to change TNS_ADMIN for this instance? [ yes ] yesPlease enter a value for TNS_ADMIN (q=quit)? [ /opt/oracle/TimesTen/tt1122/ttoracle_home/instantclient_11_2/network/admin ] Do you want to restart the daemon using the new configuration? [ yes ] yesRestarting the daemon ...TimesTen Daemon stopped.TimesTen Daemon startup OK.Instance tt1122 is now configured with TNS_ADMIN=/opt/oracle/TimesTen/tt1122/ttoracle_home/instantclient_11_2/network/admin
This option is ignored if TNS_ADMIN is configured during installation.
5. Set cache administration user
NOTE:This procedure requires CACHE_MANAGER privilege.
ttCacheUidPwdSet(‘UID’, ‘PWD’)
ttCacheUidGet()
Command> call ttCacheUidPwdSet('cacheuser','oracle');Command> call ttCacheUidGet();< CACHEUSER >1 row found.
6. Create a cache grid
Create a cache grid before creating a cache group. Only the first database Member of the cache grid needs to perform this operation. After logging on as a cache manager user, enter the following command to create a cache grid "myGrid"
Command> call ttGridCreate('gjds_grid');
Associate timesten with the created cache grid
Command> call ttGridNameSet('gjds_grid');
Start the cache proxy. If read only cache is set up, you must start the proxy to use it. The proxy is responsible for communication between timesten database and data streams between oracle and timesten cache database.
Command> call ttCacheStart;
7. Create cache groups
Create a read-only cache group readcache used to cache the table TEST. TT_CACHE_TEST in oracle
# GRANT the query permission of TT_CACHE_TEST to cacheusersql> grant select on TT_CACHE_TEST to cacheuser in Oracle; then execute the following statement in Timesten Command> create readonly cache group TT_CACHE_TEST1 autorefresh interval 60 seconds fromTT_CACHE_TEST (ID VARCHAR2 (20) primary key, ADDRESS VARCHAR2 (40 ), NAME VARCHAR2 (20 ));
Start the replication agent. If there is asynchronous writethrough cache groups in the database, the agent must be started. This process is responsible for data replication between TT databases and between TT and oracle databases.
Command> call ttrepstart;
8. Use read-only cache group
After logging on as a cache manager user, you must manually load the content of the corresponding cache table in readcache from oracle.
Command> LOAD CACHE GROUP TT_CACHE_TEST1 COMMIT EVERY 100 ROWS;9 cache instances affected
9. Restart the Cache proxy.
If data is not synchronized, restart the cache proxy.
Command> call ttCacheStop();Command> call ttCacheStart();