实战:oracle timesten 11.2.2.7.0 on centos 6.5
入门级别,但是步骤比较细致,没有理论,可以当做入门手册.
************************************************************************ 1.新建用户 ************************************************************************ -----1.create os user and group groupadd ttadmin groupadd timesten mkdir /etc/TimesTen mkdir -p /app/timesten chgrp -R ttadmin /etc/TimesTen chgrp -R ttadmin /app/timesten chmod 770 /etc/TimesTen/ chmod 770 /app/timesten chmod 660 /etc/TimesTen/* useradd -d /home/ocpyang -g ttadmin -G timesten,dba ocpyang passwd ocpyang ocpyang usermod -a -G timesten,oinstall,dba ocpyang ************************************************************************ 2.Linux平台安装准备工作 ************************************************************************ -------------1.OS kernel parameter ---1.1 shared memorary config kernel.shmmax=68719476736 kernel.shmall=16777216 /****config 64g memorary 64 x 1024 x 1024 x 1024 = 68719476736 and 68719476736 / 4096 = 16777216 ****/ /sbin/sysctl -p ---1.2HugePages config echo 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 id vm.hugetlb_shm_group = 503 /sbin/sysctl -p ---1.3 Semaphores config #vi /etc/sysctl.conf #/sbin/sysctl -a | grep sem kernel.sem = 400 32000 100 128 /sbin/sysctl -p ---1.4 REP和IMDB Cache 1).配置网络参数 针对复制,TCP发送和接收buffers应该增加到4MB,在/etc/sysctl.conf文件加入以下行: #vi /etc/sysctl.conf net.ipv4.tcp_rmem=4096 4194304 4194304 net.ipv4.tcp_wmem=98304 4194304 4194304 net.core.rmem_default=65535 net.core.wmem_default=65535 net.core.rmem_max=4194304 net.core.wmem_max=4194304 net.ipv4.tcp_window_scaling=1 2).配置网络参数 针对IMDB Cache,TCP发送和接收buffers应该增加得更大,修改/etc/sysctl.conf文件添加以下行: #vi /etc/sysctl.conf net.ipv4.tcp_rmem=4096 4194304 4194304 net.ipv4.tcp_wmem=98304 4194304 4194304 net.core.rmem_default=262144 net.core.wmem_default=262144 net.core.rmem_max=4194304 net.core.wmem_max=4194304 net.ipv4.tcp_window_scaling=1 net.ipv4.ip_local_port_range=1024 65000 将上诉两项合并修改为: #####REP和IMDB Cache net.ipv4.tcp_rmem=4096 4194304 4194304 net.ipv4.tcp_wmem=98304 4194304 4194304 net.core.rmem_default=262144 net.core.wmem_default=262144 net.core.rmem_max=4194304 net.core.wmem_max=4194304 net.ipv4.tcp_window_scaling=1 net.ipv4.ip_local_port_range=1024 65000 2).使配置生效 重启或者运行以下命令: #/sbin/sysctl -p ************************************************************************ 3.soft install ************************************************************************ ---3.1安装jdk java -version rpm -qa | grep java $ whoami ocpyang ---3.2 安装timesten cd /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 Only Which 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 installation Where 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/info Would 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 listener The command failed. ------------------------------------------------------------------------------ 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 <install_dir>/bin/ttModInstall. Please enter a value for TNS_ADMIN (s=skip)? [ ]/app/timesten/TimesTen/ttwind/ #输入/app/timesten/TimesTen/ttwind/n TNS_ADMIN will be set to /app/timesten/TimesTen You 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 #主进程端口号加1 Do 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 -install This 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_profile export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 export TNS_ADMIN=$ORACLE_HOME/network/admin export TT_HOME=/app/timesten/TimesTen/ttwind/ export PATH=$PATH:$TT_HOME/bin:$ORACLE_HOME/bin LD_LIBRARY_PATH=/app/timesten/TimesTen/ttwind/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib:$ORACLE_HOME/lib source ~/.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 TTSPACE QUOTA UNLIMITED ON TTSPACE; grant connect,resource to cacheuser; @ $TT_HOME/oraclescripts/grantCacheAdminPrivileges "cacheuser" --步骤3:授权表给cacheuser用户 conn scott/tiger create 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.so DataStore=/app/timesten/TimesTen/ttwind/info/datastore/ttwind PermSize=40 TempSize=32 PLSQL=1 DatabaseCharacterSet=ZHS16GBK ConnectionCharacterSet=ZHS16GBK OracleNetServiceName=orcl mkdir -p /app/timesten/TimesTen/ttwind/info/datastore/ttwind chmod -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设为刚创建好的myGrid Command> 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 cachtest autorefresh interval 5 seconds mode incremental from scott.t1 ( sid int not null primary key, sname varchar2(10) ); 查看用户下所有的用户表 sqltables; 查看用户下所有Cache cachegroups; --删除cache group drop 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.emp autorefresh interval 5 seconds mode incremental from scott.t1 ( sid int not null primary key, sname varchar2(10) );
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。