September 4, 2007
Oracle 11g新特性:Result Cache之一
作者:eygle
出处:http://blog.eygle.com
在Oracle Database 11g中,Oracle引入了一个令人关注的新特性:结果集缓存(Result Cache)。顾名思义,这个新特性的含义就是将查询的结果集Cache起来,以便随后相同的查询请求可以直接利用,从而避免了再次查询。今天开始来学习一下这个新特性。
进一步的Result Cache又可以分为:Server Result Cache 和 Client Result Cache。
前者通过服务器端SGA来缓存结果集,后者通过客户端来缓存结果集。
缓存是提高性能的一个常用手段,可以说在Oracle数据库中,Cache无处不在。
对于Client Result Cache:
在使用OCI应用程序时,可以通过客户端内存来缓存查询的结果集,缓存结果可以在所有session间共享,当查询反复执行时,查询结果可以直接从客户段的缓存中获得,从而极大地提高应用效率。
客户端结果集缓存并不使用服务器端的内存,不会对服务器的内存使用造成影响,这一点和Server Result Cache不同。
同Client Result Cache相关的视图主要有:
SQL> select * from dict where table_name like '%CLIENT_RESULT_CACHE%';同Client Result Cache相关的参数有:
TABLE_NAME COMMENTS
------------------------------ ---------------------------------------------
CLIENT_RESULT_CACHE_STATS$ Synonym for CRCSTATS_$
GV$CLIENT_RESULT_CACHE_STATS Synonym for GV_$CLIENT_RESULT_CACHE_STATS
V$CLIENT_RESULT_CACHE_STATS Synonym for V_$CLIENT_RESULT_CACHE_STATS
SQL> show parameter client_result如果我们不想启用Client Result Cache的特性,可以设置参数client_result_cache_size为0即可。
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
client_result_cache_lag big integer 3000
client_result_cache_size big integer 0
对于Server Result Cache:
服务器端结果集缓存使用Shared Pool中的内存来进行结果缓存,这部分内存使用可以通过v$sgastat视图来查询观察:
SQL> select * from v$sgastat
2 where lower(name) like '%result%';
POOL NAME BYTES
------------ -------------------------- ----------
shared pool Result Cache: State Objs 2852
shared pool Result Cache: Memory Mgr 124
shared pool Result Cache: Bloom Fltr 2048
shared pool Result Cache: Cache Mgr 108
进一步的和Result Cache相关的视图有:
SQL> select * from dict where table_name like '%RESULT_CACHE%';
TABLE_NAME COMMENTS
------------------------------ ---------------------------------------------
CLIENT_RESULT_CACHE_STATS$ Synonym for CRCSTATS_$
GV$CLIENT_RESULT_CACHE_STATS Synonym for GV_$CLIENT_RESULT_CACHE_STATS
GV$RESULT_CACHE_DEPENDENCY Synonym for GV_$RESULT_CACHE_DEPENDENCY
GV$RESULT_CACHE_MEMORY Synonym for GV_$RESULT_CACHE_MEMORY
GV$RESULT_CACHE_OBJECTS Synonym for GV_$RESULT_CACHE_OBJECTS
GV$RESULT_CACHE_STATISTICS Synonym for GV_$RESULT_CACHE_STATISTICS
V$CLIENT_RESULT_CACHE_STATS Synonym for V_$CLIENT_RESULT_CACHE_STATS
V$RESULT_CACHE_DEPENDENCY Synonym for V_$RESULT_CACHE_DEPENDENCY
V$RESULT_CACHE_MEMORY Synonym for V_$RESULT_CACHE_MEMORY
V$RESULT_CACHE_OBJECTS Synonym for V_$RESULT_CACHE_OBJECTS
V$RESULT_CACHE_STATISTICS Synonym for V_$RESULT_CACHE_STATISTICS
11 rows selected.
相关的参数主要有:
SQL> show parameter result_cache_max
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
result_cache_max_result integer 5
result_cache_max_size big integer 992K
类似的,result_cache_max_size参数可以被看作Server Result Cache的一个开关,如果设置为0,则Server Result Cache功能会被禁用。而result_cache_max_result则用于定义每个Cache结果集能够使用的Result Cache的百分比。
参数result_cache_mode用于控制Server Result Cache的方式,该参数有3个选项:Manual、AUTO、Force
SQL> show parameter result_cache_mo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
result_cache_mode string MANUAL
关于这个新特性的参考链接:
http://www.ningoo.net/2007/08/22/oracle11g_new_feature_server_result_cache2.htm
http://yangtingkun.itpub.net/post/468/391015
http://yangtingkun.itpub.net/post/468/391560
Posted by eygle at 4:23 PM | Comments (0)
如何重新配置Oracle的EM Database Control
作者:eygle
出处:http://blog.eygle.com
今天打算启用一下Oracle Database 11g的Database Control,发现初始并未安装:
[oracle@test126 ~]$ emctl start
EM Configuration issue. /opt/oracle/product/11.1.0/test126.hurray.com.cn_dodd not found.
遇到这类问题,可以通过重新配置,来创建EM的配置文件:
[oracle@test126 11.1.0]$ emca -config dbcontrol db -repos recreateSTARTED EMCA at Aug 28, 2007 11:54:40 AM
EM Configuration Assistant, Version 11.1.0.5.0 Production
Copyright (c) 2003, 2005, Oracle. All rights reserved.Enter the following information:
Database SID: dodd
Listener port number: 1521
Password for SYS user:
Password for DBSNMP user:
Password for SYSMAN user:
Password for SYSMAN user: Email address for notifications (optional): eygle@eygle.com
Outgoing Mail (SMTP) server for notifications (optional):
-----------------------------------------------------------------You have specified the following settings
Database ORACLE_HOME ................ /opt/oracle/product/11.1.0
Local hostname ................ test126.hurray.com.cn
Listener port number ................ 1521
Database SID ................ dodd
Email address for notifications ............... eygle@eygle.com
Outgoing Mail (SMTP) server for notifications ...............-----------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: Y
Aug 28, 2007 11:56:58 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /opt/oracle/cfgtoollogs/emca/dodd/emca_2007_08_28_11_54_40.log.
Aug 28, 2007 11:57:01 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Aug 28, 2007 11:57:16 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Aug 28, 2007 11:57:16 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Aug 28, 2007 12:08:35 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Aug 28, 2007 12:08:47 PM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...
Aug 28, 2007 12:11:45 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Aug 28, 2007 12:11:51 PM oracle.sysman.emcp.util.DBControlUtil configureSoftwareLib
INFO: Software library configured successfully.
Aug 28, 2007 12:11:51 PM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Deploying Provisioning archives ...
Aug 28, 2007 12:12:13 PM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Provisioning archives deployed successfully.
Aug 28, 2007 12:12:13 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Aug 28, 2007 12:12:39 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Aug 28, 2007 12:12:39 PM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Aug 28, 2007 12:14:04 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Aug 28, 2007 12:14:04 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is https://test126.hurray.com.cn:1158/em <<<<<<<<<<<
Aug 28, 2007 12:14:16 PM oracle.sysman.emcp.EMDBPostConfig invoke
WARNING:
************************ WARNING ************************Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted. The encryption key has been placed in the file: /opt/oracle/product/11.1.0/test126.hurray.com.cn_dodd/sysman/config/emkey.ora. Please ensure this file is backed up as the encrypted data will become unusable if this file is lost.
***********************************************************
Enterprise Manager configuration completed successfully
FINISHED EMCA at Aug 28, 2007 12:14:16 PM
Oracle 10g中,配置方法与此相同。
配置完成之后就可以启动EM了:
[oracle@test126 11.1.0]$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.1.0.6.0
Copyright (c) 1996, 2007 Oracle Corporation. All rights reserved.
https://test126.hurray.com.cn:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ........ started.
------------------------------------------------------------------
Logs are generated in directory /opt/oracle/product/11.1.0/test126.hurray.com.cn_dodd/sysman/log
如果是Linux环境,你可能还需要在iptables中开放1158端口,增加如下一行:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1158 -j ACCEPT
重新启动防火墙之后就可以通过IE在远端连接EM的Database Control了:
[root@test126 sysconfig]# service iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_ns [ OK ]
-The End-
Posted by eygle at 2:35 PM | Comments (1)
