OracleOCP 学习笔记Word文件下载.docx
- 文档编号:4791079
- 上传时间:2023-05-04
- 格式:DOCX
- 页数:22
- 大小:642.04KB
OracleOCP 学习笔记Word文件下载.docx
《OracleOCP 学习笔记Word文件下载.docx》由会员分享,可在线阅读,更多相关《OracleOCP 学习笔记Word文件下载.docx(22页珍藏版)》请在冰点文库上搜索。
-----------------Librarycache库缓冲区
---------------------Datadictionarycache数据缓冲区
OracleServer
AnOracleserver:
•Isadatabasemanagementsystemthatprovidesanopen,comprehensive,integratedapproachtoinformationmanagement
•ConsistsofanOracleinstanceandanOracledatabase
------Oracle服务负责打开数据库和对数据库的综合管理【翻译】
-----Oracle服务由Oracle实例和Oracle数据库组成【翻译】
comprehensive
[,kɔmpri'
hensiv]
综合的,广泛的
integrated
intigreitid]
综合的,完整的
approach
[ə'
prəutʃ]
途径,方法
Consists
由什么构成
overview
概况,概貌
OracleInstance
AnOracleinstance:
•IsameanstoaccessanOracledatabase
ameansto:
用来…
•Alwaysopensoneandonlyonedatabase
•Consistsofmemoryandprocessstructures
--------------Oracle实例用于访问数据库
--------------一个打开的Oracle实例对应一个数据库
--------------Oracle实例由内存和后台进程结构组成
EstablishingaConnectionandCreatingaSession
ConnectingtoanOracleinstanceconsistsof
establishingauserconnectionandcreatingasession.
Establishing[is'
tæ
bliʃ]建立,创建
OracleDatabase
AnOracledatabase:
•Isacollectionofdatathatistreatedasaunit
•Consistsofthreefiletypes
-------Oracle数据库是作为一个单元处理的数据的集合
----------Oracle数据库由三种类型文件组成(数据文件、控制文件、重做日志文件)
PhysicalStructure
ThephysicalstructureofanOracledatabaseis
determinedbytheoperatingsystemfilesthat
providetheactualphysicalstoragefordatabaseinformation.
•Controlfiles
•Datafiles
•Redologfiles
determined
[di'
tə:
mind]
决定
storage
stɔridʒ]
储藏,仓库
treated
tri:
tid]
对待,招待
MemoryStructure
Oracle’smemorystructureconsistsoftwomemory
areasknownas:
•SystemGlobalArea(SGA):
Allocatedatinstance
startup,andisafundamentalcomponentofanOracleInstance
•ProgramGlobalArea(PGA):
Allocatedwhentheserverprocessisstarted
fundamental
[,fʌndə'
mentl]
基本的,根本的
Allocated
æ
ləukeit]
分配
-------------系统全局区(SGA)在实例启动时开始分配,它是Oracle实例最根本的一个组件.
---------------程序全局区在服务进程开始的时候给予分配内存
SystemGlobalArea(SGA)
•TheSGAconsistsofseveralmemorystructures:
–Sharedpool
–Databasebuffercache
–Redologbuffer
–Otherstructures(e.g.lockandlatchmanagement,
statisticaldata)
•Therearetwooptionalmemorystructuresthatcan
beconfiguredwithintheSGA:
–Largepool
–Javapool
several
['
sevərəl]
若干个
SGAisdynamicandsizedusingSGA_MAX_SIZE.
•SGAmemoryallocatedandtrackedingranulesby
SGAcomponents
Contiguousvirtualmemoryallocation
SizebasedonSGA_MAX_SIZE
显示SGA:
SQL>
showsga;
或者:
select*fromv$sga;
showsga;
如:
granule
['
græ
nju:
l]
颗粒(颗粒有2种)
-------颗粒是分配内存的最小单位4mb/16mb
4mbsga_max_size<
128mb
16mbsga_max_size>
=128mb
SharedPool
Thesharedpoolisusedtostorethemostrecently
executedSQLstatementsandthemostrecentlyused
datadefinitions.
---------------共享池用于存放最近执行过的SQL声明和最近使用过的数据定义(如:
某个用户访问过的某张表,表中的列都是数据定义)
•Itconsistsoftwokeyperformance-relatedmemory
structures:
----------------共享池里面分为两种主键:
–Librarycache---------库缓冲区
–Datadictionarycache----------数据字典缓冲区
•Sizedbytheparameter
SHARED_POOL_SIZE.
-------要分配共享池使用SHARED_POOL_SIZE参数来指定,如:
ALTERSYSTEMSETSHARED_POOL_SIZE=64M;
**********注意,分配共享池空间时SGA必须有足够的空间
Oracle执行SQL语句的内部流程(分四步:
)
第一步PARSE【解析SQL语句分为:
硬解析/软解析】:
在这四步中,第一步最重要,也最占用系统资源
1.)从共享池的库缓冲区中搜索该语句是否曾经执行过,凡是执行过的SQL语句,Oracle会使用哈希函数(HASH)进行计算,产生一个很小的文本记录。
如果该SQL语句是第一次执行,则进入第2.)步。
2.)检查语法、权限等(权限信息存放在Oracle数据字典中),Oracle先从共享池的数据字典缓冲区中搜索,如果没有找到,再从数据文件(system表空间的数据文件)当中读取,然后存放在共享池的数据字典缓冲区中,以便共享。
3.)分析过程中,对访问到的表进行锁操作,目的是为了保护表的结构不被修改。
4.)Oracle优化器会根据数据的存储结构(表的存储结构,索引)统计信息等。
计算各种读取的代价,选择一条最佳路径(如:
全表扫描,根据索引查询,物化视图等),代价最低的途径,生成执行计划,同时编译并存储在共享池的库缓冲区中,以便共享。
第二步BIND【绑定变量】:
如果有变量则绑定变量(一般建议使用绑定变量)
Oracle对SQL语句是否能够被共享的要求非常严格
Selectename,jobfromempwhereempno=7788;
Selectename,jobfromempwhereempno=7789;
上面2条SQL语句是不一样的,第一条SQL语句执行之后不能被第二条所共享,要达到共享,2条SQL语句必须完全相同,为此我们可以考虑绑定变量来达到这个目的。
改写如下:
Selectename,jobfromempwhereempno=&
emplogyee_num;
这样上面2条SQL语句是完全相同的,第一条执行之后将保存在共享池的库缓冲区中,下次执行第二条时直接从共享池的库缓冲区中读取。
第三步EXECUTE【执行】:
先从数据缓冲区查找数据,如果没有,再从数据文件中读取数据到数据缓冲区,保存该数据,以便共享。
第四步FETCH【取得】:
把结果返回给用户。
LibraryCache
ThelibrarycachestoresinformationaboutthemostrecentlyusedSQLandPL/SQLstatements.Thelibrarycache:
•Enablesthesharingofcommonlyusedstatements
•Ismanagedbyaleastrecentlyused(LRU)algorithm['
lɡərið
əm]算法
•Consistsoftwostructures:
–SharedSQLarea
–SharedPL/SQLarea
•Hasitssizedeterminedbythesharedpoolsizing
-------------leastrecentlyused(LRU)最近最少使用到的【翻译】
最理想的境界是:
执行过的SQL语句都保存在共享池中
DataDictionaryCache
Thedatadictionarycacheisacollectionofthemostrecentlyuseddefinitionsinthedatabase.
•Itincludesinformationaboutdatabasefiles,tables,indexes,columns,users,privileges,andotherdatabaseobjects.
•Duringtheparsephase,theserverprocesslooksatthedatadictionaryforinformationtoresolveobjectnamesandvalidateaccess.
•Cachingthedatadictionaryinformationintomemoryimprovesresponsetimeonqueries.
•Sizeisdeterminedbythesharedpoolsizing.
注意:
**************在Oracle中执行的任何SQL语句都要访问数据字典,做任何操作都要操作数据字典。
库缓冲区和数据字典缓冲区都是属于共享池的组件,分配空间时数据字典缓冲区优先于库缓冲区,按比率分配,Oracle没有提供单独调整库缓冲区和数据缓冲区大小的功能,如果要调整库缓冲区或数据缓冲区,则只能增加共享池的大小。
DatabaseBufferCache
Thedatabasebuffercachestorescopiesofdatablocksthathavebeenretrievedfromthedatafiles.
--------数据缓冲区存放的是从数据文件里头获取的数据块的拷贝
•Itenablesgreatperformancegainswhenyouobtainandupdatedata.
•Itismanagedthroughaleastrecentlyused(LRU)algorithm.
--------数据缓冲区采用的算法是LRU,(如果数据缓冲区配额不够)最近最少使用的将被淘汰出去。
•DB_BLOCK_SIZE
determinestheprimaryblocksize.
•Consistsofindependentsub-caches:
–DB_CACHE_SIZE
–DB_KEEP_CACHE_SIZE
–DB_RECYCLE_CACHE_SIZE
•Databasebuffercachecanbedynamicallyresized
togroworshrinkusingALTERSYSTEM.
ALTERSYSTEMSETDB_CACHE_SIZE=96M;
•DB_CACHE_ADVICEcanbesettogatherstatistics
forpredictingdifferentcachesizebehavior.
stores
[stɔ:
stɔə]
商店,贮藏,仓库
retrieve
[ri'
v]
取回,恢复,补偿
performance
[pə'
fɔ:
məns]
性能,表演,表现
obtain
[əb'
tein]
获得,得到
gather
gæ
ð
ə]
聚集,集合,渐增
statistics
[stə'
tistiks]
统计,统计数字,统计学
behavior
[bi'
heiviə]
行为,举止
IO操作:
1.)物理I/O:
从数据缓冲区搜索不到所要的数据,就要从磁盘中读取,叫做物理I/O。
2.)逻辑I/O:
从数据缓冲区搜索到所要的数据,叫做逻辑I/O。
物理I/O的速度与逻辑I/O速度之比是:
1:
1000逻辑I/O是物理I/O速度的1000倍。
数据调优的标志:
能够在数据缓冲区中找到数据的比率应该在:
90%以上。
RedoLogBufferCache
-------日志缓冲区【翻译】
Theredologbuffercacherecordsallchangesmadetothedatabasedatablocks.
----日志缓冲区记录所有造成数据库数据块发生改变的操作。
•Itsprimarypurposeisrecovery.
•Changesrecordedwithinarecalledredoentries.
------RedoLog里面存放的不是SQL语句,而是日志条目(redoentries)
•Redoentriescontaininformationtoreconstructorredochanges.
•SizeisdefinedbyLOG_BUFFER.
********LOG_BUFFER支持的单位是字节,不是MB,因为日志缓冲区不能分配太大,所以从单位上来限制,引起用户注意。
purpose
pə:
pəs]
首要的,主要的
LargePool
Thelargepoolisanoptionalareaofmemoryinthe
SGAconfiguredonlyinasharedserverenvironment.
•Itrelievestheburdenplacedonthesharedpool.
•Thisconfiguredmemoryareaisusedforsessionmemory(UGA),
I/Oslaves,andbackupandrestoreoperations.
•Unlikethesharedpool,thelargepooldoesnotuseanLRUlist.
•SizedbyLARGE_POOL_SIZE.
ALTERSYSTEMSETLARGE_POOL_SIZE=64M;
JavaPool
TheJavapoolservicestheparsingrequirementsforJavacommands.
•RequiredifinstallingandusingJava.
•ItisstoredmuchthesamewayasPL/SQLindatabasetables.
•ItissizedbytheJAVA_POOL_SIZEparameter.
ProgramGlobalArea(PGA)
ThePGAismemoryreservedforeachuserprocess
thatconnectstoanOracledatabase.
--------PGA,PGA主要是给server进程使用的。
ProcessStructure
AnOracleprocessisaprogramthatdependingonits
typecanrequestinformation,executeaseriesof
steps,orperformaspecifictask.
Oracletakesadvantageofvarioustypesofprocesses:
•Userprocess:
StartedatthetimeadatabaseuserrequestsconnectiontotheOracleserver
•Serverprocess:
ConnectstotheOracleInstanceandisstartedwhenauserestablishesasession.
•Backgroundprocess:
AvailablewhenanOracleinstanceisstarted
takesadvantageof
利用
establishes
[i'
stæ
bliʃ]
建立
UserProcess
AuserprocessisaprogramthatrequestsinteractionwiththeOracleserver.
•Itmustfirstestablishaconnection.
•ItdoesnotinteractdirectlywiththeOracleserver.
ServerProcess
AserverprocessisaprogramthatdirectlyinteractswiththeOracleserver.
•Itfulfillscallsgeneratedandreturnsresults.
•Canbededicatedorsharedserver.
interacts
[,intər'
kt]
相互影响,相互作用
fulfills
[ful'
fil]
履行,完成
dedicated
dedikeitid]
专注的,献身的
BackgroundProcesses
TherelationshipbetweenthephysicalandmemorystructuresismaintainedandenforcedbyOracle’sbackgroundprocesses.
•Mandatorybackgroundprocesses
DBWnPMONCKPT
LGWRSMONRECO
•Optionalbackgroundprocesses
ARCnLMONSnnn
QMNnLMDn
CJQ0Pnnn
LCKnDnnn
DatabaseWriter(DBWn)
DBWn进程:
数据写入进程,负责把脏数据块从数据缓冲区(修改过的数据块叫作脏数据块)写入数据文件。
写入进程写入数据文件的触发事件:
Checkpointoccur----------检查点发生改变
Dirtybuffersthresholdreached------脏数据达到阈值
Nofreebuffers---------
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- OracleOCP 学习笔记 学习 笔记