首页 > 代码库 > 实战:oracle timesten 11.2.2.7.0 on centos 6.5

实战:oracle timesten 11.2.2.7.0 on centos 6.5

入门级别,但是步骤比较细致,没有理论,可以当做入门手册.
 
************************************************************************1.新建用户************************************************************************-----1.create os user and group  groupadd ttadmingroupadd timesten mkdir /etc/TimesTenmkdir -p /app/timestenchgrp -R ttadmin /etc/TimesTenchgrp -R ttadmin  /app/timestenchmod 770 /etc/TimesTen/chmod 770 /app/timesten chmod 660 /etc/TimesTen/*useradd  -d /home/ocpyang -g ttadmin -G timesten,dba ocpyangpasswd ocpyangocpyangusermod -a -G timesten,oinstall,dba ocpyang************************************************************************2.Linux平台安装准备工作************************************************************************-------------1.OS kernel parameter ---1.1 shared memorary configkernel.shmmax=68719476736kernel.shmall=16777216/****config 64g memorary64 x 1024 x 1024 x 1024 = 68719476736 and 68719476736 / 4096 = 16777216****//sbin/sysctl -p---1.2HugePages configecho 32 > /proc/sys/vm/nr_hugepages vi /etc/sysctl.conf #config timesten instance 16g and huge page size is 2M.vm.nr_hugepages = 8192   #ttadmin group idvm.hugetlb_shm_group = 503  /sbin/sysctl -p  ---1.3 Semaphores  config#vi /etc/sysctl.conf#/sbin/sysctl -a | grep semkernel.sem = 400 32000 100 128/sbin/sysctl -p   ---1.4 REP和IMDB Cache1).配置网络参数针对复制,TCP发送和接收buffers应该增加到4MB,在/etc/sysctl.conf文件加入以下行:#vi /etc/sysctl.confnet.ipv4.tcp_rmem=4096 4194304 4194304net.ipv4.tcp_wmem=98304 4194304 4194304net.core.rmem_default=65535net.core.wmem_default=65535net.core.rmem_max=4194304net.core.wmem_max=4194304net.ipv4.tcp_window_scaling=12).配置网络参数针对IMDB Cache,TCP发送和接收buffers应该增加得更大,修改/etc/sysctl.conf文件添加以下行:#vi /etc/sysctl.confnet.ipv4.tcp_rmem=4096 4194304 4194304net.ipv4.tcp_wmem=98304 4194304 4194304net.core.rmem_default=262144net.core.wmem_default=262144net.core.rmem_max=4194304net.core.wmem_max=4194304net.ipv4.tcp_window_scaling=1net.ipv4.ip_local_port_range=1024 65000将上诉两项合并修改为:#####REP和IMDB Cachenet.ipv4.tcp_rmem=4096 4194304 4194304net.ipv4.tcp_wmem=98304 4194304 4194304net.core.rmem_default=262144net.core.wmem_default=262144net.core.rmem_max=4194304net.core.wmem_max=4194304net.ipv4.tcp_window_scaling=1net.ipv4.ip_local_port_range=1024 65000 2).使配置生效重启或者运行以下命令:#/sbin/sysctl -p  ************************************************************************3.soft install************************************************************************---3.1安装jdkjava -versionrpm -qa | grep java$ whoamiocpyang---3.2 安装timestencd /soft/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.#步骤1:输入安装实例名称Please choose an instance name for this installation? [ tt1122 ] ttwind  #输入自定义的名字Instance name will be 'ttwind'.Is this correct? [ yes ] yes#步骤2:安装组件Of the three components:  [1] Client/Server and Data Manager  [2] Data Manager Only  [3] Client OnlyWhich would you like to install? [ 1 ] 1  #输入1#步骤3:安装位置Of the following options :  [1] /home/ocpyang  [2] /soft  [3] Specify a location  [q] Quit the installationWhere would you like to install the ttwind instance of TimesTen? [ 1 ] 3    #输入3 自定义一个安装目录Please specify a directory to install TimesTen? [ /home/ocpyang ] /app/timesten  #输入自定义一个安装目录Where would you like to create the daemon home directory? [ /app/timesten/TimesTen/ttwind/info ] The daemon logs will be located in /app/timesten/TimesTen/ttwind/infoWould you like to specify a different location for the daemon logs? [ no ] 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'.#步骤4:输入自定义的主进程端口号The default port number is 53396. Do you want to use the default port number for the TimesTen daemon? [ yes ] no  #输入no 自定义端口Please enter a unique port number for the TimesTen daemon (<CR>=list)? [ ] 53355  #输入自定义端口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.#步骤5:受限会话和PL/SQL功能默认即可Restrict access to the the TimesTen installation to the group 'ttadmin'? [ yes ] NOTE: Enabling PL/SQL will increase the size of some TimesTen libraries.Would you like to enable PL/SQL for this instance? [ yes ] yes#步骤6:安装的时候指定TNS_ADMIN环境变量------------------------------------------------------------------------------切记:最后的 tnsnames.ora需要放入这个目录一份,否则报错Command> create readonly cache group cachtest       > from scott.t2       > (       > sid int not null primary key,       > sname varchar2(10)       > );Warning  5923: Cache agent has deferred the create/alter cache group request because it is not connected to Oracle yet或Command> load cache group cachtest commit every 10 rows; 5056: The cache operation fails: error_type=<Oracle Error>, error_code=<12541>, error_message: ORA-12541: TNS:no listenerThe command failed.------------------------------------------------------------------------------In order to use the 'In-Memory Database Cache' feature in any databasescreated within this installation, you must set a value for the TNS_ADMINenvironment variable. It can be left blank, and a value can be supplied laterusing <install_dir>/bin/ttModInstall.Please enter a value for TNS_ADMIN (s=skip)? [  ]/app/timesten/TimesTen/ttwind/  #输入/app/timesten/TimesTen/ttwind/nTNS_ADMIN will be set to /app/timesten/TimesTenYou can change TNS_ADMIN later by running <install_dir>/bin/ttmodinstall. NOTE: It appears that you are running version 4 or higher 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      <install_dir>/lib directory and to the 4.1.0 server binary in the      <install_dir>/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 ...#步骤7:TimesTen服务器端口号Installing server components ...What is the TCP/IP port number that you want the TimesTen Server to listen on? [ 53356 ] 53356  #主进程端口号加1Do you want to install the Quick Start Sample Programs and the TimesTen Documentation? [ no ] Would you like to install the documentation (without the Quick Start Sample Programs)? [ yes ] Where would you like to create the doc directory? [ /app/timesten/TimesTen/ttwind/doc ] The TimesTen documentation has been installed in /app/timesten/TimesTen/ttwind/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 /app/timesten/TimesTen/ttwind/bin ./setuproot -installThis will move the TimesTen startup script into its appropriate location.The startup script is currently located here :  '/app/timesten/TimesTen/ttwind/startup/tt_ttwind'.The 11.2.2.7 Release Notes are located here :  '/app/timesten/TimesTen/ttwind/README.html'Starting the daemon ...TimesTen Daemon startup OK.End of TimesTen installation.---3.3设置用户变量vi ~/.bash_profileexport  ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1export  TNS_ADMIN=$ORACLE_HOME/network/adminexport  TT_HOME=/app/timesten/TimesTen/ttwind/export  PATH=$PATH:$TT_HOME/bin:$ORACLE_HOME/binLD_LIBRARY_PATH=/app/timesten/TimesTen/ttwind/libexport  LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib:$ORACLE_HOME/libsource ~/.bash_profile ---3.4 拷贝tnsnames文件cp   /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora /app/timesten/TimesTen/ttwind/************************************************************************4.新建缓存实例************************************************************************---------4.1 Oracle数据库创建相关用户和权限--步骤1:新建表空间存储timesten的数据字典表CREATE TABLESPACE ttspace DATAFILE '/u01/app/oracle/oradata/orcl/ttspace01.dbf' SIZE 10M autoextend on next 10m maxsize 30g;@ $TT_HOME/oraclescripts/initCacheGlobalSchema.sql "TTSPACE"alter user timesten identified by timesten;--步骤2:新建数据库同步用户create user cacheuser identified by cacheuser DEFAULT TABLESPACE TTSPACEQUOTA UNLIMITED ON TTSPACE;grant connect,resource to cacheuser;@ $TT_HOME/oraclescripts/grantCacheAdminPrivileges "cacheuser"--步骤3:授权表给cacheuser用户conn scott/tigercreate table t1(sid int not null primary key,sname varchar2(10));insert into t1 values(101,'wind');insert into t1 values(102,'snow'); grant select,insert,update,delete on scott.t1 to cacheuser;  grant all on scott.t1 to cacheuser;-------4.2 timesten端创建相关用户和权限----步骤0:修改DSN并设置需要的数据目录文件#vi /app/timesten/TimesTen/ttwind/info/sys.odbc.ini [ttwind]Driver=/app/timesten/TimesTen/ttwind/lib/libtten.soDataStore=/app/timesten/TimesTen/ttwind/info/datastore/ttwindPermSize=40TempSize=32PLSQL=1DatabaseCharacterSet=ZHS16GBKConnectionCharacterSet=ZHS16GBKOracleNetServiceName=orclmkdir -p /app/timesten/TimesTen/ttwind/info/datastore/ttwindchmod  -R 770  /app/timesten/TimesTen/ttwind/info/datastore/ttwind ttIsql ttwind --步骤1:cache管理用户CREATE USER cacheuser IDENTIFIED BY cacheuser ;GRANT CREATE SESSION, CACHE_MANAGER, CREATE ANY TABLE,DROP ANY TABLE  TO cacheuser; --步骤2:cache对应用户create user scott identified by tiger;grant create session ,adminto scott; --步骤3:将oracle cache管理用户与timesten关联,设置oracle连接的用户名和密码,cache agent将会使用这个用户名和密码去oracle中读取call ttcacheuidpwdset ('cacheuser','cacheuser');  --步骤4:创建cache grid$ ttIsql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;OraclePWD=cacheuser"Command> call ttGridCreate('myGrid');--步骤5:将cache database 和cache grid关联即把当前的grid设为刚创建好的myGridCommand>  call ttGridNameSet('myGrid');--步骤6:测试autocommit 0;set passthrough 2;select * from v$version;select table_name from user_tables where table_name like '%MYGRID%';set passthrough 0; --步骤7:测试只读缓存集合$ ttIsql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;OraclePWD=cacheuser" ttIsql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;OraclePWD=cacheuser;OracleNetServiceName=orcl" call ttCacheStart;call ttCacheStop;drop Cache Group Cachtest;create readonly cache group cachtestautorefresh interval 5 secondsmode incrementalfrom scott.t1(sid int not null primary key,sname varchar2(10));查看用户下所有的用户表sqltables;查看用户下所有Cachecachegroups;--删除cache groupdrop Cache Group Cachtest;--加载load cache group cachtest commit every 10 rows;************************************************************************5.Timesten 快捷加载oracle数据库中的表和数据 ************************************************************************ttisql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;" ttIsql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;OraclePWD=cacheuser;OracleNetServiceName=orcl" ttIsql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;OraclePWD=cacheuser; OracleId=ORCL"autocommit 0;set passthrough 2;--生成表结构call ttTableSchemaFromOraQueryGet('scott','emp','SELECT * FROM scott.emp');--导入数据CALL ttLoadFromOracle ('scott','emp','SELECT * FROM scott.emp'); CREATE TABLE "SCOTT"."EMP" ( "EMPNO" number(4,0) NOT NULL,"ENAME" varchar2(10 byte),"JOB" varchar2(9 byte),"MGR" number(4,0),"HIREDATE" date,"SAL" number(7,2),"COMM" number(7,2),"DEPTNO" number(2,0) ) >create readonly cache group cacheuser.empautorefresh interval 5 seconds mode incrementalfrom scott.t1(sid int not null primary key,sname varchar2(10));      


 

实战:oracle timesten 11.2.2.7.0 on centos 6.5