实战:oracle timesten 11.2.2.7.0 on centos 6.5

  1. 入门级别,但是步骤比较细致,没有理论,可以当做入门手册.  
  1.    
  1. ************************************************************************  
  2. 1.新建用户  
  3. ************************************************************************  
  4.   
  5. -----1.create os user and group   
  6.   
  7.    
  8.   
  9. groupadd ttadmin  
  10.   
  11. groupadd timesten  
  12.   
  13.    
  14.   
  15. mkdir /etc/TimesTen  
  16.   
  17. mkdir -p /app/timesten  
  18.   
  19. chgrp -R ttadmin /etc/TimesTen  
  20.   
  21. chgrp -R ttadmin  /app/timesten  
  22.   
  23. chmod 770 /etc/TimesTen/  
  24.   
  25. chmod 770 /app/timesten  
  26.   
  27.    
  28.   
  29. chmod 660 /etc/TimesTen/*  
  30.   
  31.   
  32. useradd  -d /home/ocpyang -g ttadmin -G timesten,dba ocpyang  
  33.   
  34. passwd ocpyang  
  35.   
  36. ocpyang  
  37.   
  38. usermod -a -G timesten,oinstall,dba ocpyang  
  39.   
  40. ************************************************************************  
  41. 2.Linux平台安装准备工作  
  42. ************************************************************************  
  43.   
  44.   
  45. -------------1.OS kernel parameter   
  46.   
  47. ---1.1 shared memorary config  
  48.   
  49. kernel.shmmax=68719476736  
  50. kernel.shmall=16777216  
  51.   
  52.   
  53. /****config 64g memorary  
  54.   
  55. 64 x 1024 x 1024 x 1024 = 68719476736 and 68719476736 / 4096 = 16777216  
  56.   
  57. ****/  
  58.   
  59.   
  60. /sbin/sysctl -p  
  61.   
  62.   
  63. ---1.2HugePages config  
  64.   
  65. echo 32 > /proc/sys/vm/nr_hugepages  
  66.   
  67.    
  68.   
  69.   
  70. vi /etc/sysctl.conf  
  71.   
  72.  #config timesten instance 16g and huge page size is 2M.  
  73. vm.nr_hugepages = 8192     
  74.   
  75. #ttadmin group id  
  76. vm.hugetlb_shm_group = 503    
  77.   
  78. /sbin/sysctl -p  
  79.   
  80.    
  81.   
  82.    
  83.   
  84.   
  85. ---1.3 Semaphores  config  
  86.   
  87.   
  88. #vi /etc/sysctl.conf  
  89.   
  90. #/sbin/sysctl -a | grep sem  
  91.   
  92. kernel.sem = 400 32000 100 128  
  93.   
  94. /sbin/sysctl -p  
  95.   
  96.    
  97.   
  98.    
  99.   
  100.    
  101.   
  102.   
  103. ---1.4 REP和IMDB Cache  
  104.   
  105.   
  106. 1).配置网络参数  
  107. 针对复制,TCP发送和接收buffers应该增加到4MB,在/etc/sysctl.conf文件加入以下行:  
  108. #vi /etc/sysctl.conf  
  109.   
  110.   
  111. net.ipv4.tcp_rmem=4096 4194304 4194304  
  112. net.ipv4.tcp_wmem=98304 4194304 4194304  
  113. net.core.rmem_default=65535  
  114. net.core.wmem_default=65535  
  115. net.core.rmem_max=4194304  
  116. net.core.wmem_max=4194304  
  117. net.ipv4.tcp_window_scaling=1  
  118.   
  119.   
  120. 2).配置网络参数  
  121. 针对IMDB Cache,TCP发送和接收buffers应该增加得更大,修改/etc/sysctl.conf文件添加以下行:  
  122. #vi /etc/sysctl.conf  
  123.   
  124. net.ipv4.tcp_rmem=4096 4194304 4194304  
  125. net.ipv4.tcp_wmem=98304 4194304 4194304  
  126. net.core.rmem_default=262144  
  127. net.core.wmem_default=262144  
  128. net.core.rmem_max=4194304  
  129. net.core.wmem_max=4194304  
  130. net.ipv4.tcp_window_scaling=1  
  131. net.ipv4.ip_local_port_range=1024 65000  
  132.   
  133.   
  134. 将上诉两项合并修改为:  
  135.   
  136. #####REP和IMDB Cache  
  137. net.ipv4.tcp_rmem=4096 4194304 4194304  
  138. net.ipv4.tcp_wmem=98304 4194304 4194304  
  139. net.core.rmem_default=262144  
  140. net.core.wmem_default=262144  
  141. net.core.rmem_max=4194304  
  142. net.core.wmem_max=4194304  
  143. net.ipv4.tcp_window_scaling=1  
  144. net.ipv4.ip_local_port_range=1024 65000  
  145.   
  146.    
  147.   
  148. 2).使配置生效  
  149. 重启或者运行以下命令:  
  150. #/sbin/sysctl -p  
  151.   
  152.    
  153.   
  154.    
  155.   
  156. ************************************************************************  
  157. 3.soft install  
  158. ************************************************************************  
  159.   
  160.   
  161. ---3.1安装jdk  
  162.   
  163. java -version  
  164.   
  165. rpm -qa | grep java  
  166.   
  167.   
  168. $ whoami  
  169. ocpyang  
  170.   
  171. ---3.2 安装timesten  
  172.   
  173. cd /soft/linux8664/  
  174.   
  175.   
  176. $ ./setup.sh   
  177.   
  178. NOTE: Each TimesTen installation is identified by a unique instance name.  
  179.       The instance name must be a non-null alphanumeric string, not longer  
  180.       than 255 characters.  
  181.   
  182. #步骤1:输入安装实例名称  
  183. Please choose an instance name for this installation? [ tt1122 ] ttwind  #输入自定义的名字  
  184. Instance name will be ‘ttwind‘.  
  185. Is this correct? [ yes ] yes  
  186.   
  187. #步骤2:安装组件  
  188. Of the three components:  
  189.   
  190.   [1] Client/Server and Data Manager  
  191.   [2] Data Manager Only  
  192.   [3] Client Only  
  193.   
  194. Which would you like to install? [ 1 ] 1  #输入1  
  195.   
  196. #步骤3:安装位置  
  197. Of the following options :  
  198.   
  199.   [1] /home/ocpyang  
  200.   [2] /soft  
  201.   [3] Specify a location  
  202.   [q] Quit the installation  
  203.   
  204.   
  205. Where would you like to install the ttwind instance of TimesTen? [ 1 ] 3    #输入3 自定义一个安装目录  
  206. Please specify a directory to install TimesTen? [ /home/ocpyang ] /app/timesten  #输入自定义一个安装目录  
  207. Where would you like to create the daemon home directory? [ /app/timesten/TimesTen/ttwind/info ]   
  208.   
  209. The daemon logs will be located in /app/timesten/TimesTen/ttwind/info  
  210. Would you like to specify a different location for the daemon logs? [ no ]   
  211.   
  212. Uncompressing ...  
  213.   
  214. NOTE: If you are configuring TimesTen for use with Oracle Clusterware, the  
  215.       daemon port number must be the same across all TimesTen installations  
  216.       managed within the same Oracle Clusterware cluster.  
  217.   
  218. NOTE: All installations that replicate to each other must use the same daemon  
  219.       port number that is set at installation time. The daemon port number can  
  220.       be verified by running ‘ttVersion‘.  
  221.   
  222. #步骤4:输入自定义的主进程端口号  
  223.   
  224. The default port number is 53396.  
  225.   
  226.    
  227.   
  228. Do you want to use the default port number for the TimesTen daemon? [ yes ] no  #输入no 自定义端口  
  229. Please enter a unique port number for the TimesTen daemon (<CR>=list)? [ ] 53355  #输入自定义端口  
  230.   
  231. NOTE: For security, we recommend that you restrict access to the  
  232.       TimesTen installation to members of a single OS group. Only members of  
  233.       that OS group will be allowed to perform direct mode connections to  
  234.       TimesTen, and only members of that OS group will be allowed to perform  
  235.       operations that access TimesTen data stores, TimesTen files and shared  
  236.       memory. The OS group defaults to the primary group of the instance  
  237.       administrator. You can default to this group, choose another OS group  
  238.       or you can make this instance world-accessible. If you choose to make  
  239.       this instance world-accessible, all database files and shared memory  
  240.       are readable and writable by all users.  
  241.   
  242. #步骤5:受限会话和PL/SQL功能默认即可  
  243. Restrict access to the the TimesTen installation to the group ‘ttadmin‘? [ yes ]   
  244.   
  245. NOTE: Enabling PL/SQL will increase the size of some TimesTen libraries.  
  246.   
  247. Would you like to enable PL/SQL for this instance? [ yes ] yes  
  248.   
  249.   
  250. #步骤6:安装的时候指定TNS_ADMIN环境变量  
  251. ------------------------------------------------------------------------------  
  252.   
  253. 切记:最后的 tnsnames.ora需要放入这个目录一份,否则报错  
  254. Command> create readonly cache group cachtest  
  255.        > from scott.t2  
  256.        > (  
  257.        > sid int not null primary key,  
  258.        > sname varchar2(10)  
  259.        > );  
  260. Warning  5923: Cache agent has deferred the create/alter cache group request because it is not connected to Oracle yet  
  261.   
  262. 或  
  263.   
  264. Command> load cache group cachtest commit every 10 rows;  
  265.  5056: The cache operation fails: error_type=<Oracle Error>, error_code=<12541>, error_message: ORA-12541: TNS:no listener  
  266. The command failed.  
  267.   
  268. ------------------------------------------------------------------------------  
  269.   
  270. In order to use the ‘In-Memory Database Cache‘ feature in any databases  
  271. created within this installation, you must set a value for the TNS_ADMIN  
  272. environment variable. It can be left blank, and a value can be supplied later  
  273. using <install_dir>/bin/ttModInstall.  
  274.   
  275. Please enter a value for TNS_ADMIN (s=skip)? [  ]/app/timesten/TimesTen/ttwind/  #输入/app/timesten/TimesTen/ttwind/n  
  276.   
  277. TNS_ADMIN will be set to /app/timesten/TimesTen  
  278. You can change TNS_ADMIN later by running <install_dir>/bin/ttmodinstall.  
  279.   
  280.    
  281.   
  282. NOTE: It appears that you are running version 4 or higher of the g++  
  283.       compiler. TimesTen ships with multiple sets of client libraries and server  
  284.       binaries : one built for compatibility with g++ 3.4.6 and one with  
  285.       g++ 4.1.0. The installer has created links to the 4.1.0 library in the  
  286.       <install_dir>/lib directory and to the 4.1.0 server binary in the  
  287.       <install_dir>/bin directory. If you want to use a different compiler,  
  288.       please modify the links to point to the desired library and server binary.  
  289.   
  290. Installing server components ...  
  291.   
  292. #步骤7:TimesTen服务器端口号  
  293.   
  294. Installing server components ...  
  295. What is the TCP/IP port number that you want the TimesTen Server to listen on? [ 53356 ] 53356  #主进程端口号加1  
  296. Do you want to install the Quick Start Sample Programs and the TimesTen Documentation? [ no ]   
  297. Would you like to install the documentation (without the Quick Start Sample Programs)? [ yes ]   
  298. Where would you like to create the doc directory? [ /app/timesten/TimesTen/ttwind/doc ]   
  299. The TimesTen documentation has been installed in /app/timesten/TimesTen/ttwind/doc.  
  300. Installing client components ...  
  301.   
  302. Would you like to use TimesTen Replication with Oracle Clusterware? [ no ]   
  303.   
  304. NOTE: The TimesTen daemon startup/shutdown scripts have not been installed.  
  305.   
  306. Run the ‘setuproot‘ script :  
  307.  cd /app/timesten/TimesTen/ttwind/bin  
  308.  ./setuproot -install  
  309. This will move the TimesTen startup script into its appropriate location.  
  310.   
  311. The startup script is currently located here :  
  312.   ‘/app/timesten/TimesTen/ttwind/startup/tt_ttwind‘.  
  313.   
  314. The 11.2.2.7 Release Notes are located here :  
  315.   ‘/app/timesten/TimesTen/ttwind/README.html‘  
  316.   
  317. Starting the daemon ...  
  318. TimesTen Daemon startup OK.  
  319. End of TimesTen installation.  
  320.   
  321.   
  322. ---3.3设置用户变量  
  323.   
  324. vi ~/.bash_profile  
  325.   
  326. export  ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1  
  327.   
  328. export  TNS_ADMIN=$ORACLE_HOME/network/admin  
  329.   
  330. export  TT_HOME=/app/timesten/TimesTen/ttwind/  
  331.   
  332. export  PATH=$PATH:$TT_HOME/bin:$ORACLE_HOME/bin  
  333.   
  334. LD_LIBRARY_PATH=/app/timesten/TimesTen/ttwind/lib  
  335. export  LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib:$ORACLE_HOME/lib  
  336.   
  337.   
  338. source ~/.bash_profile   
  339.   
  340.   
  341. ---3.4 拷贝tnsnames文件  
  342.   
  343. cp   /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora /app/timesten/TimesTen/ttwind/  
  344.   
  345.   
  346. ************************************************************************  
  347. 4.新建缓存实例  
  348. ************************************************************************  
  349.   
  350. ---------4.1 Oracle数据库创建相关用户和权限  
  351.   
  352. --步骤1:新建表空间存储timesten的数据字典表  
  353.   
  354. CREATE TABLESPACE ttspace DATAFILE  
  355.  ‘/u01/app/oracle/oradata/orcl/ttspace01.dbf‘  
  356.  SIZE 10M autoextend on next 10m maxsize 30g;  
  357.   
  358.   
  359. @ $TT_HOME/oraclescripts/initCacheGlobalSchema.sql "TTSPACE"  
  360.   
  361. alter user timesten identified by timesten;  
  362.   
  363.   
  364. --步骤2:新建数据库同步用户  
  365.   
  366. create user cacheuser identified by cacheuser   
  367. DEFAULT TABLESPACE TTSPACE  
  368. QUOTA UNLIMITED ON TTSPACE;  
  369.   
  370. grant connect,resource to cacheuser;  
  371.   
  372. @ $TT_HOME/oraclescripts/grantCacheAdminPrivileges "cacheuser"  
  373.   
  374.   
  375. --步骤3:授权表给cacheuser用户  
  376.   
  377. conn scott/tiger  
  378.   
  379. create table t1  
  380. (  
  381. sid int not null primary key,  
  382. sname varchar2(10)  
  383. );  
  384.   
  385. insert into t1 values(101,‘wind‘);  
  386.   
  387. insert into t1 values(102,‘snow‘);  
  388.   
  389.    
  390.   
  391. grant select,insert,update,delete on scott.t1 to cacheuser;  
  392.    
  393.  grant all on scott.t1 to cacheuser;  
  394.   
  395.   
  396. -------4.2 timesten端创建相关用户和权限  
  397.   
  398. ----步骤0:修改DSN并设置需要的数据目录文件  
  399.   
  400. #vi /app/timesten/TimesTen/ttwind/info/sys.odbc.ini   
  401.   
  402. [ttwind]  
  403. Driver=/app/timesten/TimesTen/ttwind/lib/libtten.so  
  404. DataStore=/app/timesten/TimesTen/ttwind/info/datastore/ttwind  
  405. PermSize=40  
  406. TempSize=32  
  407. PLSQL=1  
  408. DatabaseCharacterSet=ZHS16GBK  
  409. ConnectionCharacterSet=ZHS16GBK  
  410. OracleNetServiceName=orcl  
  411.   
  412.   
  413. mkdir -p /app/timesten/TimesTen/ttwind/info/datastore/ttwind  
  414.   
  415. chmod  -R 770  /app/timesten/TimesTen/ttwind/info/datastore/ttwind  
  416.   
  417.  ttIsql ttwind  
  418.   
  419.    
  420.   
  421.   
  422. --步骤1:cache管理用户  
  423. CREATE USER cacheuser IDENTIFIED BY cacheuser ;  
  424.   
  425. GRANT CREATE SESSION, CACHE_MANAGER, CREATE ANY TABLE,DROP ANY TABLE  TO cacheuser;  
  426.   
  427.    
  428.   
  429. --步骤2:cache对应用户  
  430.   
  431. create user scott identified by tiger;  
  432.   
  433. grant create session ,adminto scott;  
  434.   
  435.    
  436.   
  437. --步骤3:将oracle cache管理用户与timesten关联,设置oracle连接的用户名和密码,  
  438. cache agent将会使用这个用户名和密码去oracle中读取  
  439.   
  440. call ttcacheuidpwdset (‘cacheuser‘,‘cacheuser‘);  
  441.   
  442.    
  443.   
  444.    
  445.   
  446. --步骤4:创建cache grid  
  447.   
  448. $ ttIsql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;OraclePWD=cacheuser"  
  449.   
  450. Command> call ttGridCreate(‘myGrid‘);  
  451.   
  452. --步骤5:将cache database 和cache grid关联即把当前的grid设为刚创建好的myGrid  
  453.   
  454. Command>  call ttGridNameSet(‘myGrid‘);  
  455.   
  456. --步骤6:测试  
  457. autocommit 0;  
  458. set passthrough 2;  
  459.   
  460. select * from v$version;  
  461.   
  462. select table_name from user_tables where table_name like ‘%MYGRID%‘;  
  463.   
  464. set passthrough 0;  
  465.   
  466.    
  467.   
  468.   
  469. --步骤7:测试只读缓存集合  
  470.   
  471. $ ttIsql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;OraclePWD=cacheuser"  
  472.   
  473.  ttIsql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;OraclePWD=cacheuser;OracleNetServiceName=orcl"  
  474.   
  475.    
  476.   
  477.   
  478. call ttCacheStart;  
  479.   
  480. call ttCacheStop;  
  481.   
  482.   
  483. drop Cache Group Cachtest;  
  484. create readonly cache group cachtest  
  485. autorefresh interval 5 seconds  
  486. mode incremental  
  487. from scott.t1  
  488. (  
  489. sid int not null primary key,  
  490. sname varchar2(10)  
  491. );  
  492.   
  493.   
  494. 查看用户下所有的用户表  
  495. sqltables;  
  496.   
  497. 查看用户下所有Cache  
  498.   
  499. cachegroups;  
  500.   
  501. --删除cache group  
  502.   
  503. drop Cache Group Cachtest;  
  504.   
  505. --加载  
  506. load cache group cachtest commit every 10 rows;  
  507.   
  508.   
  509. ************************************************************************  
  510. 5.Timesten 快捷加载oracle数据库中的表和数据   
  511. ************************************************************************  
  512.   
  513.   
  514. ttisql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;"  
  515.   
  516.   
  517.  ttIsql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;OraclePWD=cacheuser;OracleNetServiceName=orcl"  
  518.   
  519.  ttIsql "DSN=ttwind;UID=cacheuser;PWD=cacheuser;OraclePWD=cacheuser; OracleId=ORCL"  
  520.   
  521.   
  522. autocommit 0;  
  523. set passthrough 2;  
  524.   
  525. --生成表结构  
  526.   
  527. call ttTableSchemaFromOraQueryGet(‘scott‘,‘emp‘,‘SELECT * FROM scott.emp‘);  
  528.   
  529. --导入数据  
  530.   
  531. CALL ttLoadFromOracle (‘scott‘,‘emp‘,‘SELECT * FROM scott.emp‘);  
  532.   
  533.    
  534.   
  535.   
  536. CREATE TABLE "SCOTT"."EMP" (   
  537. "EMPNO" number(4,0) NOT NULL,  
  538. "ENAME" varchar2(10 byte),  
  539. "JOB" varchar2(9 byte),  
  540. "MGR" number(4,0),  
  541. "HIREDATE" date,  
  542. "SAL" number(7,2),  
  543. "COMM" number(7,2),  
  544. "DEPTNO" number(2,0)  
  545.  ) >  
  546.   
  547.   
  548. create readonly cache group cacheuser.emp  
  549. autorefresh interval 5 seconds  
  550.  mode incremental  
  551. from scott.t1  
  552. (  
  553. sid int not null primary key,  
  554. sname varchar2(10)  
  555. );  
  556.   
  557.    
  558.   
  559.    
  560.   
  561.    
  562.   
  563.    
  564.   
  565.    
  566.   

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。