• 一.Timesten安装


    一,安装timesten IMDB并测试

    1. 创建数据库相关用户和组

    1. groupadd timesten
    2. useradd -g timesten -G dba timesten
    3. passwd timesten

    2. 创建相关目录

    1. mkdir /etc/TimesTen
    2. chmod 775 /etc/TimesTen
    3. chown timesten:timesten /etc/TimesTen
    4. mkdir /u01/app/timesTen
    5. chmod 775 /u01/app/timesTen
    6. chown timesten:timesten /u01/TimesTen

    3. 切换到timesten用户,设置环境变量

    1. [root@oracle ~]# su - timesten
    2. [timesten@oracle ~]$ vi .bash_profile 
    3. export ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome_1
    4. export TIMESTEN=/opt/timesten/TimesTen/tt1122
    5. # .bash_profile
    6. # Get the aliases and functions
    7. if [ -~/.bashrc ]; then
    8.         . ~/.bashrc
    9. fi
    10. # User specific environment and startup programs
    11. PATH=$PATH:$HOME/bin
    12. export PATH
    13. PATH=$PATH:$HOME/bin
    14. export ORACLE_BASE=/u01/app/oracle11g
    15. export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
    16. export ORACLE_SID=db11
    17. export TIMESTEN=/u01/app/timesten/TimesTen/tt1122
    18. export LD_LIBRARY_PATH=$TIMESTEN/lib:$ORACLE_HOME/lib
    19. export PATH=$TIMESTEN/bin:$ORACLE_HOME/bin:$PATH:$HOME/bin
    20. export TNS_ADMIN=$ORACLE_HOME/network/admin
    21. unset USERNAME
    22. export PATH

    4. 上传软件,并修改软件的用户和属组,切换到timesten用户

    1. [root@oracle timesten]# su - timesten
    2. [timesten@oracle ~]$ gzip -d timesten112280.linux8664.gz 
    3. [timesten@oracle ~]$ ls -l
    4. total 344792
    5. -rw-r--r-- 1 timesten timesten 353064960 May 28 2015 timesten112280.linux8664
    6. [timesten@oracle ~]$ ls -l
    7. total 344792
    8. -rw-r--r-- 1 timesten timesten 353064960 May 28  2015 timesten112280.linux8664
    9. [timesten@oracle ~]$ tar -xvf timesten112280.linux8664
    10. linux8664/
    11. linux8664/uninst.sh
    12. linux8664/install.pl
    13. linux8664/README.html
    14. linux8664/LINUX8664/
    15. linux8664/LINUX8664/ttpatchinst
    16. linux8664/LINUX8664/unzip
    17. linux8664/LINUX8664/common.tar.bz2
    18. linux8664/LINUX8664/ttclient.tar.bz2
    19. linux8664/LINUX8664/perl
    20. linux8664/LINUX8664/manifest
    21. linux8664/LINUX8664/timesten.tar.bz2
    22. linux8664/LINUX8664/bzip2
    23. linux8664/LINUX8664/ttserver.tar.bz2
    24. linux8664/3rdparty/
    25. linux8664/3rdparty/ant-1.6.2-bin.tar.bz2
    26. linux8664/3rdparty/jms-1_1-fr-apidocs.tar.bz2
    27. linux8664/doc/
    28. linux8664/doc/doc.zip
    29. linux8664/setup.sh
    30. [timesten@oracle ~]$ ll
    31. total 344796
    32. drwxrwxr-x 5 timesten timesten 4096 Jan 20 18:12 linux8664
    33. -rw-r--r-- 1 timesten timesten 353064960 May 28 2015 timesten112280.linux8664

    5. 开始安装软件

    1. [timesten@oracle ~]$ cd linux8664/
    2. [timesten@oracle linux8664]$ ll
    3. total 420
    4. drwxr-xr-x 2 timesten timesten 4096 Jan 20 18:12 3rdparty
    5. drwxrwxr-x 2 timesten timesten 4096 Jan 20 18:12 doc
    6. -rwxr-xr-x 1 timesten timesten 256471 Jan 20 18:10 install.pl
    7. drwxr-xr-x 2 timesten timesten 4096 Jan 20 18:12 LINUX8664
    8. -rwxr--r-- 1 timesten timesten 114161 Jan 20 18:10 README.html
    9. -rwxr-xr-x 1 timesten timesten 5759 Jan 20 18:10 setup.sh
    10. -rwxr-xr-x 1 timesten timesten 34886 Jan 20 18:10 uninst.sh
    11. [timesten@oracle linux8664]$ ./setup.sh
    12. NOTE: Each TimesTen installation is identified by a unique instance name.
    13. The instance name must be a non-null alphanumeric string, not longer
    14. than 255 characters.
    15. Please choose an instance name for this installation? [ tt1122 ]
    16. Instance name will be 'tt1122'.
    17. Is this correct? [ yes ]
    18. Of the three components:
    19. [1] Client/Server and Data Manager
    20. [2] Data Manager Only
    21. [3] Client Only
    22. Which would you like to install? [ 1 ]
    23. Of the following options :
    24. [1] /home/timesten
    25. [2] /home/timesten
    26. [3] Specify a location
    27. [q] Quit the installation
    28. Where would you like to install the tt1122 instance of TimesTen? [ 1 ] 3
    29. Please specify a directory to install TimesTen? [ /home/timesten ] /u01/app/timesten
    30. The directory /u01/app/timesten does not exist.
    31. Do you want to create it? [ yes ]
    32. Where would you like to create the daemon home directory? [ /u01/app/timesten/TimesTen/tt1122/info ]
    33. The daemon logs will be located in /u01/app/timesten/TimesTen/tt1122/info
    34. Would you like to specify a different location for the daemon logs? [ no ]
    35. Installing into /u01/app/timesten/TimesTen/tt1122 ...
    36. Uncompressing ...
    37. NOTE: If you are configuring TimesTen for use with Oracle Clusterware, the
    38. daemon port number must be the same across all TimesTen installations
    39. managed within the same Oracle Clusterware cluster.
    40. NOTE: All installations that replicate to each other must use the same daemon
    41. port number that is set at installation time. The daemon port number can
    42. be verified by running 'ttVersion'.
    43. The default port number is 53396.
    44. Do you want to use the default port number for the TimesTen daemon? [ yes ]
    45. The daemon will run on the default port number (53396).
    46. NOTE: For security, we recommend that you restrict access to the
    47. TimesTen installation to members of a single OS group. Only members of
    48. that OS group will be allowed to perform direct mode connections to
    49. TimesTen, and only members of that OS group will be allowed to perform
    50. operations that access TimesTen data stores, TimesTen files and shared
    51. memory. The OS group defaults to the primary group of the instance
    52. administrator. You can default to this group, choose another OS group
    53. or you can make this instance world-accessible. If you choose to make
    54. this instance world-accessible, all database files and shared memory
    55. are readable and writable by all users.
    56. Restrict access to the the TimesTen installation to the group 'timesten'? [ yes ]
    57. NOTE: Enabling PL/SQL will increase the size of some TimesTen libraries.
    58. Would you like to enable PL/SQL for this instance? [ yes ]
    59. TNS_ADMIN exists in your environment and is set to :
    60. /u01/app/oracle11g/product/11.2.0/dbhome_1/network/admin
    61. Would you like to use this TNS_ADMIN setting for the Oracle TimesTen Application-Tier Database Cache? [ yes ]
    62. TNS_ADMIN will be set to /u01/app/oracle11g/product/11.2.0/dbhome_1/network/admin
    63. You can change TNS_ADMIN later by running <install_dir>/bin/ttmodinstall.
    64. NOTE: It appears that you are running version 4 or higher of the g++
    65. compiler. TimesTen ships with multiple sets of client libraries and server
    66. binaries : one built for compatibility with g++ 3.4.6 and one with
    67. g++ 4.1.0. The installer has created links to the 4.1.0 library in the
    68. <install_dir>/lib directory and to the 4.1.0 server binary in the
    69. <install_dir>/bin directory. If you want to use a different compiler,
    70. please modify the links to point to the desired library and server binary.
    71. Installing server components ...
    72. What is the TCP/IP port number that you want the TimesTen Server to listen on? [ 53397 ]
    73. Do you want to install the Quick Start Sample Programs and the TimesTen Documentation? [ no ]
    74. Would you like to install the documentation (without the Quick Start Sample Programs)? [ yes ]
    75. Where would you like to create the doc directory? [ /u01/app/timesten/TimesTen/tt1122/doc ]
    76. The TimesTen documentation has been installed in /u01/app/timesten/TimesTen/tt1122/doc.
    77. Installing client components ...
    78. Would you like to use TimesTen Replication with Oracle Clusterware? [ no ]
    79. NOTE: The TimesTen daemon startup/shutdown scripts have not been installed.
    80. Run the 'setuproot' script :
    81. cd /u01/app/timesten/TimesTen/tt1122/bin
    82. ./setuproot -install
    83. This will move the TimesTen startup script into its appropriate location.
    84. The startup script is currently located here :
    85. '/u01/app/timesten/TimesTen/tt1122/startup/tt_tt1122'.
    86. The 11.2.2.8 Release Notes are located here :
    87. '/u01/app/timesten/TimesTen/tt1122/README.html'
    88. Starting the daemon ...
    89. TimesTen Daemon startup OK.
    90. End of TimesTen installation.
    91. [timesten@oracle linux8664]$

    6. 启动服务

    1. [root@oracle ~]# cd /u01/app/timesten/TimesTen/tt1122/bin/
    2. [root@oracle bin]# ./setuproot -install
    3. $* is no longer supported at ./setuproot line 260.
    4. Would you like to install the TimesTen daemon startup scripts into /etc/init.d? [ yes ]
    5. Copying /u01/app/timesten/TimesTen/tt1122/startup/tt_tt1122 to /etc/init.d
    6. Successfully installed the following scripts :
    7. /etc/init.d/tt_tt1122
    8. /etc/rc.d/rc0.d/K45tt_tt1122
    9. /etc/rc.d/rc1.d/K45tt_tt1122
    10. /etc/rc.d/rc2.d/S90tt_tt1122
    11. /etc/rc.d/rc3.d/S90tt_tt1122
    12. /etc/rc.d/rc5.d/S90tt_tt1122
    13. /etc/rc.d/rc6.d/K45tt_tt1122

    查看进程

    1. [root@oracle bin]# ps -ef | grep times
    2. root 31501 31129 0 Feb24 pts/3 00:00:00 su - timesten
    3. timesten 31503 31501 0 Feb24 pts/3 00:00:00 -bash
    4. timesten 35813 1 0 Feb24 ? 00:00:00 /u01/app/timesten/TimesTen/tt1122/bin/timestend -initfd 13
    5. timesten 35817 35813 0 Feb24 ? 00:00:00 /u01/app/timesten/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000000 -facility user
    6. timesten 35819 35813 0 Feb24 ? 00:00:00 /u01/app/timesten/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000002 -facility user
    7. timesten 35820 35813 0 Feb24 ? 00:00:00 /u01/app/timesten/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000003 -facility user
    8. timesten 35822 35813 0 Feb24 ? 00:00:00 /u01/app/timesten/TimesTen/tt1122/bin/ttcserver -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000004 -p 53397 -facility user -group timesten
    9. timesten 35834 35813 0 Feb24 ? 00:00:00 /u01/app/timesten/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000005 -facility user

    修改配置文件

    1. [timesten@oracle info]$ vi sys.odbc.ini
    2. [ODBC Data Sources]
    3. TT_1122=TimesTen 11.2.2 Driver
    4. sampledb_1122=TimesTen 11.2.2 Driver
    5. cachedb1_1122=TimesTen 11.2.2 Driver
    6. repdb1_1122=TimesTen 11.2.2 Driver
    7. repdb2_1122=TimesTen 11.2.2 Driver
    8. sampledbCS_1122=TimesTen 11.2.2 Client Driver
    9. cachedb1CS_1122=TimesTen 11.2.2 Client Driver
    10. repdb1CS_1122=TimesTen 11.2.2 Client Driver
    11. repdb2CS_1122=TimesTen 11.2.2 Client Driver

    7. 连接测试

    1. [timesten@oracle info]$ ttIsql TT_1122
    2. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
    3. Type ? or "help" for help, type "exit" to quit ttIsql.
    4. connect "DSN=TT_1122";
    5. Connection successful: DSN=TT_1122;UID=timesten;DataStore=/u01/app/timesten/TimesTen/tt1122/info/TT_1122;DatabaseCharacterSet=US7ASCII;ConnectionCharacterSet=US7ASCII;DRIVER=/u01/app/timesten/TimesTen/tt1122/lib/libtten.so;TypeMode=0;
    6. (Default setting AutoCommit=1)
    7. Command>
    8. Command> tables
    9. 0 tables found.
    10. Command> create table tt_test(id number(20));
    11. Command> insert into tt_test values(12345678);
    12. 1 row inserted.
    13. Command> commit;
    14. Command> select * from tt_test;
    15. < 12345678 >
    16. 1 row found.
    17. Command> insert into tt_test values(1989);
    18. 1 row inserted.
    19. Command> select * from tt_test;
    20. < 12345678 >
    21. < 1989 >
    22. 2 rows found.
    23. Command> commit;
    24. Command> tables
    25. TIMESTEN.TT_TEST
    26. 1 table found.
    27. Command> drop table tt_test;
    28. Command> tables
    29. 0 tables found.
    30. Command>

    二. 同步用户数据设置

    在timesten安装目录的oraclescripts有相关的oracle脚本

    1. [root@oracle tt1122]# cd oraclescripts/
    2. [root@oracle oraclescripts]# ll
    3. total 104
    4. -r--r----- 1 timesten timesten 8815 Jan 20 18:09 cacheCleanUp.sql
    5. -r--r----- 1 timesten timesten 5840 Jan 20 18:09 cacheInfo.sql
    6. -r--r----- 1 timesten timesten 12344 Jan 20 18:09 grantCacheAdminPrivileges.sql
    7. -r--r----- 1 timesten timesten 21528 Jan 20 18:09 initCacheAdminSchema.sql
    8. -r--r----- 1 timesten timesten 9569 Jan 20 18:09 initCacheGlobalSchema.sql
    9. -r--r----- 1 timesten timesten 7217 Jan 20 18:09 initCacheGridSchema.sql
    10. -r--r----- 1 timesten timesten 5744 Jan 20 18:09 README.TXT
    11. drwxr-x--- 3 timesten timesten 4096 Jan 20 18:09 supporting_scripts
    12. -r--r----- 1 timesten timesten 5688 Jan 20 18:09 ttca_setupRepository.sql
    13. -r--r----- 1 timesten timesten 2272 Jan 20 18:09 ttca_setupTarget.sql
    14. [root@oracle oraclescripts]#
    15. [root@oracle oraclescripts]# cp initCacheGlobalSchema.sql /tmp
    16. [root@oracle oraclescripts]# cp grantCacheAdminPrivileges.sql /tmp
    17. [root@oracle oraclescripts]# cd /tmp/
    18. [root@oracle tmp]# chmod 777 initCacheGlobalSchema.sql
    19. [root@oracle tmp]# chmod 777 grantCacheAdminPrivileges.sql
    1. 创建timesten用户使用TimesTen自带脚本
    1. [root@oracle tmp]# su - ora11g
    2. db11@oracle /home/ora11g$ 
    3. db11@oracle  /home/ora11g$
    4. db11@oracle /home/ora11g$ cd /tmp/
    5. db11@oracle  /tmp$ sqlplus / as sysdba
    6. SQL*Plus: Release 11.2.0.4.0 Production on Wed Feb 25 01:58:16 2015
    7. Copyright (c) 1982, 2013, Oracle. All rights reserved.
    8. Connected to:
    9. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    10. With the Partitioning, OLAP, Data Mining and Real Application Testing options
    11. SQL> @initCacheGlobalSchema
    12. Please enter the tablespace where TIMESTEN user is to be created
    13. users
    14. The value chosen for tablespace is users
    15. ******* Creation of TIMESTEN schema and TT_CACHE_ADMIN_ROLE starts *******
    16. 1. Creating TIMESTEN schema
    17. 2. Creating TIMESTEN.TT_GRIDID table
    18. 3. Creating TIMESTEN.TT_GRIDINFO table
    19. 4. Creating TT_CACHE_ADMIN_ROLE role
    20. 5. Granting privileges to TT_CACHE_ADMIN_ROLE
    21. ** Creation of TIMESTEN schema and TT_CACHE_ADMIN_ROLE done successfully **
    22. PL/SQL procedure successfully completed.
    23. SQL>
    2. 创建一个管理cache的用户
    1. SQL> create user cacheadmin identified by cacheadmin;
    2. User created.
    3. SQL> @grantCacheAdminPrivileges "cacheadmin"
    4. Please enter the administrator user id
    5. The value chosen for administrator user id is cacheadmin
    6. ***************** Initialization for cache admin begins ******************
    7. 0. Granting the CREATE SESSION privilege to CACHEADMIN
    8. 1. Granting the TT_CACHE_ADMIN_ROLE to CACHEADMIN
    9. 2. Granting the DBMS_LOCK package privilege to CACHEADMIN
    10. 3. Granting the CREATE SEQUENCE privilege to CACHEADMIN
    11. 4. Granting the CREATE CLUSTER privilege to CACHEADMIN
    12. 5. Granting the CREATE OPERATOR privilege to CACHEADMIN
    13. 6. Granting the CREATE INDEXTYPE privilege to CACHEADMIN
    14. 7. Granting the CREATE TABLE privilege to CACHEADMIN
    15. 8. Granting the CREATE PROCEDURE privilege to CACHEADMIN
    16. 9. Granting the CREATE ANY TRIGGER privilege to CACHEADMIN
    17. 10. Granting the GRANT UNLIMITED TABLESPACE privilege to CACHEADMIN
    18. 11. Granting the DBMS_LOB package privilege to CACHEADMIN
    19. 12. Granting the SELECT on SYS.ALL_OBJECTS privilege to CACHEADMIN
    20. 13. Granting the SELECT on SYS.ALL_SYNONYMS privilege to CACHEADMIN
    21. 14. Checking if the cache administrator user has permissions on the default
    22. tablespace
    23. No existing permission.
    24. 15. Altering the cache administrator to grant unlimited tablespace on USERS
    25. 16. Granting the CREATE TYPE privilege to CACHEADMIN
    26. 17. Granting the SELECT on SYS.GV$LOCK privilege to CACHEADMIN (optional)
    27. 18. Granting the SELECT on SYS.GV$SESSION privilege to CACHEADMIN (optional)
    28. 19. Granting the SELECT on SYS.DBA_DATA_FILES privilege to CACHEADMIN
    29. (optional)
    30. 20. Granting the SELECT on SYS.USER_USERS privilege to CACHEADMIN (optional)
    31. 21. Granting the SELECT on SYS.USER_FREE_SPACE privilege to CACHEADMIN
    32. (optional)
    33. 22. Granting the SELECT on SYS.USER_TS_QUOTAS privilege to CACHEADMIN
    34. (optional)
    35. 23. Granting the SELECT on SYS.USER_SYS_PRIVS privilege to CACHEADMIN
    36. (optional)
    37. ********* Initialization for cache admin user done successfully *********
    3. 创建一个业务用户
    1. SQL> create user hxy identified by hxy;
    2. User created.
    3. 进行一样的授权
    4. SQL> @grantCacheAdminPrivileges "hxy"
    5. Please enter the administrator user id
    6. The value chosen for administrator user id is hxy
    7. ***************** Initialization for cache admin begins ******************
    8. 0. Granting the CREATE SESSION privilege to HXY
    9. 1. Granting the TT_CACHE_ADMIN_ROLE to HXY
    10. 2. Granting the DBMS_LOCK package privilege to HXY
    11. 3. Granting the CREATE SEQUENCE privilege to HXY
    12. 4. Granting the CREATE CLUSTER privilege to HXY
    13. 5. Granting the CREATE OPERATOR privilege to HXY
    14. 6. Granting the CREATE INDEXTYPE privilege to HXY
    15. 7. Granting the CREATE TABLE privilege to HXY
    16. 8. Granting the CREATE PROCEDURE privilege to HXY
    17. 9. Granting the CREATE ANY TRIGGER privilege to HXY
    18. 10. Granting the GRANT UNLIMITED TABLESPACE privilege to HXY
    19. 11. Granting the DBMS_LOB package privilege to HXY
    20. 12. Granting the SELECT on SYS.ALL_OBJECTS privilege to HXY
    21. 13. Granting the SELECT on SYS.ALL_SYNONYMS privilege to HXY
    22. 14. Checking if the cache administrator user has permissions on the default
    23. tablespace
    24. No existing permission.
    25. 15. Altering the cache administrator to grant unlimited tablespace on USERS
    26. 16. Granting the CREATE TYPE privilege to HXY
    27. 17. Granting the SELECT on SYS.GV$LOCK privilege to HXY (optional)
    28. 18. Granting the SELECT on SYS.GV$SESSION privilege to HXY (optional)
    29. 19. Granting the SELECT on SYS.DBA_DATA_FILES privilege to HXY (optional)
    30. 20. Granting the SELECT on SYS.USER_USERS privilege to HXY (optional)
    31. 21. Granting the SELECT on SYS.USER_FREE_SPACE privilege to HXY (optional)
    32. 22. Granting the SELECT on SYS.USER_TS_QUOTAS privilege to HXY (optional)
    33. 23. Granting the SELECT on SYS.USER_SYS_PRIVS privilege to HXY (optional)
    34. ********* Initialization for cache admin user done successfully *********
    35. SQL>
    4. 设置/u01/app/timesten/TimesTen/tt1122/info/sys.odbc.ini
    1. [TT_1122]
    2. Driver=/u01/app/timesten/TimesTen/tt1122/lib/libtten.so
    3. DataStore=/u01/app/timesten/TimesTen/tt1122/info/TT_1122
    4. DatabaseCharacterSet=ZHS16GBK
    5. OracleNetServiceName=db11
    6. PermSize=2048
    7. TempSize=1024
    5. 启动TimesTen
    1. [timesten@oracle info]$ ttdaemonadmin -stop
    2. TimesTen Daemon stopped.
    3. [timesten@oracle info]$ ttdaemonadmin -start
    4. TimesTen Daemon startup OK.
    5. [timesten@oracle info]$ ttisql TT_1122
    6. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
    7. Type ? or "help" for help, type "exit" to quit ttIsql.
    8. connect "DSN=TT_1122";
    9. Connection successful: DSN=TT_1122;UID=timesten;DataStore=/u01/app/timesten/TimesTen/tt1122/info/TT_1122;DatabaseCharacterSet=US7ASCII;ConnectionCharacterSet=US7ASCII;DRIVER=/u01/app/timesten/TimesTen/tt1122/lib/libtten.so;PermSize=2048;TempSize=1024;TypeMode=0;OracleNetServiceName=db11;
    10. (Default setting AutoCommit=1)
    11. Command>
    6. 创建TimesTen内存数据库的用户,用户必须和Oracle数据库名称相同
    1. Command> create user cacheadmin identified by cacheadmin;
    2. User created.
    3. Command> grant create session,cache_manager,create any table to cacheadmin;
    4. Command> create user hxy identified by hxy;
    5. User created.
    6. Command> grant create session,create any table to hxy;
    7. 从TimesTen链接到Oracle数据库
    1. Command> connect "dsn=TT_1122;uid=cacheadmin;PWD=cacheadmin;OraclePwd=cacheadmin";
    2. Command> call ttcacheuidpwdset('cacheadmin','cacheadmin');
    8. 创建Grid,TimesTen特性必须把cache group让在grid中
    1. connect "dsn=TT_1122;uid=cacheadmin;PWD=cacheadmin;OraclePwd=cacheadmin";
    9. 创建cache grid,TimesTen特性必须把cache group让在grid中
    1. con1: Command> call ttGridCreate('myGrid');
    2. con1: Command> call ttGridnameSet('myGrid');
    10.在Orace数据库里面建立表和唯一索引,TimesTen必须需要是一个主键和唯一索引
    1. db11@oracle /home/ora11g$ sqlplus / as sysdba
    2. SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 26 01:09:06 2015
    3. Copyright (c) 1982, 2013, Oracle. All rights reserved.
    4. Connected to:
    5. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    6. With the Partitioning, OLAP, Data Mining and Real Application Testing options
    7. SQL>
    8. SQL>
    9. SQL> conn hxy/hxy
    10. Connected.
    11. SQL> create table a (id number,name varchar2(20));
    12. Table created.
    13. SQL> create unique index a_idx on a(id);
    14. Index created.

    把权限授予cache管理用户

    1. GRANT SELECT ON a TO cacheadmin;
    2. GRANT INSERT ON a TO cacheadmin;
    3. GRANT UPDATE ON a TO cacheadmin;
    4. GRANT DELETE ON a TO cacheadmin;
    11. Load数据到TimesTen中
    1. ttisql "dsn=TT_1122;uid=cacheadmin;PWD=cacheadmin;OraclePwd=cacheadmin";

    1.启动cache

    1. Command>call ttcachestart

    2.启动cache之后就可以创建cache group了

    创建group时,需要将表的名字和结构设置成与oracle数据库中test用户下的需要加载的表的名字和结构一模一样,这样才能匹配找到相应的表,否则无法加载数据。(这里创建的readonly类型的group)

    1. con1: Command> create readonly cache group cache_a Autorefresh interval 5 seconds mode incremental From hxy.a(id number not null primary key , name varchar2(20));
    2. con1: Command> cachegroups;
    3. Cache Group CACHEADMIN.CACHE_A:
    4. Cache Group Type: Read Only
    5. Autorefresh: Yes
    6. Autorefresh Mode: Incremental
    7. Autorefresh State: Paused
    8. Autorefresh Interval: 5 Seconds
    9. Autorefresh Status: ok
    10. Aging: No aging defined
    11. Root Table: HXY.A
    12. Table Type: Read Only
    13. 1 cache group found.
    14. 3. load cache group cache_a commit every 10 rows;
    12.退出ttisql,重新进入,把对a表的查询权限在timesten数据库中授予cacheadmin
    1. [timesten@oracle ~]$ ttisql TT_1122
    2. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
    3. Type ? or "help" for help, type "exit" to quit ttIsql.
    4. connect "DSN=TT_1122";
    5. Connection successful: DSN=TT_1122;UID=timesten;DataStore=/u01/app/timesten/TimesTen/tt1122/info/TT_1122;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=US7ASCII;DRIVER=/u01/app/timesten/TimesTen/tt1122/lib/libtten.so;PermSize=2048;TempSize=1024;TypeMode=0;OracleNetServiceName=db11;
    6. (Default setting AutoCommit=1)
    7. GRANT SELECT ON hxy.a TO cacheadmin;
    8. GRANT INSERT ON hxy.a TO cacheadmin;
    9. GRANT UPDATE ON hxy.a TO cacheadmin;
    10. GRANT DELETE ON hxy.a TO cacheadmin;

    连接

    1. Command> connect "dsn=TT_1122;uid=cacheadmin;PWD=cacheadmin;OraclePwd=cacheadmin";
    2. Connection successful: DSN=TT_1122;UID=cacheadmin;DataStore=/u01/app/timesten/TimesTen/tt1122/info/TT_1122;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=US7ASCII;DRIVER=/u01/app/timesten/TimesTen/tt1122/lib/libtten.so;PermSize=2048;TempSize=1024;TypeMode=0;OracleNetServiceName=db11;
    3. (Default setting AutoCommit=1)
    4. con1: Command> select * from hxy.a;
    5. 0 rows found. ----没有数据

    在oracle数据库中插入数据

    1. SQL> show user
    2. USER is "HXY"
    3. SQL>
    4. SQL> insert into a values(1,'hello');
    5. 1 row created.
    6. SQL> insert into a values(2,'hxy');
    7. 1 row created.
    8. SQL> commit;

    去IMDB查询

    1. con1: Command> select * from hxy.a;
    2. < 1, hello >
    3. < 2, hxy >
    4. 2 rows found.

    可见,在oracle中提交,数据会自动复制到IMDB中

    错误:

    1.字符集设置成ZHS16GBK报下面的错误:

    1. [timesten@oracle info]$ ttisql TT_1122
    2. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
    3. Type ? or "help" for help, type "exit" to quit ttIsql.
    4. connect "DSN=TT_1122";
    5. 6228: Invalid value (AL32UTF8) for DatabaseCharacterSet connection attribute -- value must be the same as the current data store value (US7ASCII)
    6. The command failed.
    7. Done.
    8. Command> call ttcacheuidpwdset('cacheadmin','cacheadmin');
    9. 8296: TimesTen and Oracle database character sets do not match. TimesTen: US7ASCII, Oracle: ZHS16GBK
    10. 5935: Could not validate Oracle login: uid = CACHEADMIN, pwd = HIDDEN, OracleNetServiceName = db11, TNS_ADMIN = "/u01/app/oracle11g/product/11.2.0/dbhome_1/network/admin", ORACLE_HOME= "/u01/app/oracle11g/product/11.2.0/dbhome_1"
    11. The command failed.
    12. Command> exit
    13. Disconnecting...

    分析
    这个问题是因为已经初始化一次TT_1122后又修改了sys.odbc.ini中DatabaseCharacterSet=AL32UTF8参数。

    解决方法:
    删掉TT_1122重新初始化并且重新建立用户

    1. [timesten@oracle info]$ ttDestroy TT_1122
    2. -bash-4.1$ ttisql TT_1122
    3. Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
    4. Type ? or "help" for help, type "exit" to quit ttIsql.
    5. connect "DSN=TT_1122";
    6. Connection successful: DSN=TT_1122;UID=timesten;DataStore=/opt/timesten/TimesTen/tt1122/info/TT_1122;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=AL32UTF8;DRIVER=/opt/timesten/TimesTen/tt1122/lib/libtten.so;PermSize=2048;TempSize=1024;TypeMode=0;OracleNetServiceName=NINVOICE;
    7. (Default setting AutoCommit=1)
    8. Command> exit
    9. Disconnecting...
    10. Done.

    2.刚开始使用

    connect "dsn=TT_1122;uid=cacheadmin;PWD=cacheadmin;OraclePwd=cacheadmin";
    连接的时候一直报下面的错误:

    1. Command> connect "dsn=TT_1122;uid=cacheadm;OraclePWD=cacheadm;OraclePwd=cacheadm";
    2. 7001: User authentication failed
    3. The command failed.

    郁闷的不行,最后在内存数据库中又执行了一次

    1. Command> create user cacheadmin identified by cacheadmin;
    2. User created.
    3. Command> grant create session,cache_manager,create any table to cacheadmin;
    4. Command> create user hxy identified by hxy;
    5. User created.
    6. Command> grant create session,create any table to hxy;

    然后再次连接成功,奇怪,难道内存中的用户消失了???

    3.创建cache group的时候报错

    1. con1: Command> create readonly cache group cache_a Autorefresh interval 5 seconds mode incremental From hxy.a(id number not null primary key , name varchar2(20));
    2. 5140: Could not find HXY.A in Oracle. May not have privileges.
    3. The command failed.


    解决办法:

    把对表的查询权限授予cache管理用户cacheadmin

    1. GRANT SELECT ON hxy.a TO cacheadmin;
    2. GRANT INSERT ON hxy.a TO cacheadmin;
    3. GRANT UPDATE ON hxy.a TO cacheadmin;
    4. GRANT DELETE ON hxy.a TO cacheadmin;

    参考:

    http://blog.itpub.net/16381228/viewspace-764825 ---有错误,已在上文中修正





  • 相关阅读:
    华为机试:字符串翻转
    华为机试:数字颠倒
    华为机试:字符个数统计
    华为机试:提取不重复的整数
    华为机试:取近视值
    华为机试:进制转换
    华为机试:字符串分隔
    华为机试:明明的随机数
    华为机试:字符串最后一个单词的长度
    网易:相反数
  • 原文地址:https://www.cnblogs.com/haoxiaoyu/p/625fc8b1ba9a9385e3d1e38ec050e55f.html
Copyright © 2020-2023  润新知