注:黑色为原版部分,红色为疑问与完善内容部分(红色完善与新加的部分请老师确认是否正确,望老师多多指点)
目录
偶数机(managementserver)----管理机
奇数机(databaseserver)---------数据库机
XmanagerEnterprise5----------图形化操作工具
奇数机与偶数机账号:root密码:oracle
远程连接工具:SecureCRT
虚拟机:VMwareWorkstationPro
创建sudo的oracle用户(考试root权限被锁只能用sudo请老师确认是否正确)
去掉%wheel前的#
vi/etc/group
wheel加上oracle用户这样sudo就不需要密码了
配置网络(练习中设静态Ip,为了方便SecureCRT远程连接后续都是在SecureCRT操作)
先检查奇数机的ip
编辑网络配置命令:vi/etc/sysconfig/network-scripts/ifcfg-eth0
老师给的11g环境
奇数机初始网络配置
DEVICE=eth0网卡设备名,eth0表示第一张网卡
BOOTPROTO=dhcp是否自动获取IP(none,static,dhcp),static:静态ip,dhcp:动态ip,none:无(无指定)
ONBOOT=yes是否随网络服务启动当前网卡生效(在centOS6以上的版本ONBOOT是默认关闭的)
HWADDR=00:0c:29:d4:df:acMAC地址
偶数机初始网络配置
BOOTPROTO=none是否自动获取IP(none,static,dhcp),static:静态ip,dhcp:动态ip,none:无(无指定)
HWADDR=00:50:56:21:4a:10MAC地址
IPADDR=192.168.92.90IP地址
NETMASK=255.255.255.0子网掩码
GATEWAY=192.168.92.1网关
TYPE=Ethernet网络类型这里是以太网
USERCTL=no是否允许非root用户控制此网卡,这里为不允许
IPV6INIT=noIPV6是否启用,这里设置为不启用
PEERDNS=yes是否允许DHCP获得的DNS覆盖本地的DNS
/etc/hosts(负责IP地址与域名快速解析的文件)初始配置
127.0.0.1localhost.localdomainlocalhost
::1localhost6.localdomain6localhost6
192.168.92.80odd.oracle.comodd
192.168.92.90even.oracle.comeven
(第一部份:网络IP地址;第二部份:主机名或域名;第三部份:主机名别名;)
为了方便SecureCRT远程连接,根据奇数机动态获取的ip奇数机与偶数机都进行静态ip修改设置
奇数机部分:(注:ip根据ifconfig获取的动态ip来配置)
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:0c:29:d4:df:ac
IPADDR=192.168.72.80
NETMASK=255.255.255.0
GATEWAY=192.168.72.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
偶数机部分:(ip根据ifconfig获取的动态ip来配置)
BOOTPROTO=none
HWADDR=00:50:56:21:4a:10
IPADDR=192.168.72.90
奇数机与偶数机修改/etc/hosts
#Donotremovethefollowingline,orvariousprograms
#thatrequirenetworkfunctionalitywillfail.
192.168.72.80odd.oracle.comodd
192.168.72.90even.oracle.comeven
全部修改好后奇数机与偶数机重启网络:servicenetworkrestart
设置好后检查SecureCRT远程连接是否成功
Description
Inthisskillset,youcreateanewdatabaseandmodifytheexistingPROD1andRPOD2database.Activitiesincludeconfiguringthenetworkenvironment,createandconfiguringtablespace,creatingdatabasebackups,andimprovingaccesstothenetworkfiledirectories.Itisimportanttoconfigureyourdatabaseenvironment,sothatyoucanperformcompleterecoveryfromanyfailure,andthatyourdatabasesaremaintainedfor100%availability.Attheendofthisskillset,youshouldhaveoperationaldatabasesinopenmode.
Objectives
EndState
Attheendofthisskillset,yourdatabasePROD1,PROD2,PROD3,PROD4andEMREPmustbeaccessibletotheproctor.Nocreditwillbegivenforthisskillsetifthedatabasesarenotopenforaccess.
翻译:
说明
在此技能集中,您将创建一个新数据库并修改PROD1和RPOD2数据库。活动包括配置网络环境、创建和配置表空间、创建数据库备份以及改进对网络文件目录的访问。配置数据库环境非常重要,这样您就可以从任何故障中执行完全恢复,并且您的数据库可以保持100%的可用性。在这个技能集的末尾,您应该让操作数据库处于打开模式。
目标
确定并设置附加表空间和数据库段的存储参数。
配置数据库环境以支持最佳的数据访问性能。
保护数据库免受任何类型的故障造成的数据丢失。
创建和管理数据库配置文件。
创建和管理网络配置文件。
配置数据库实例以支持共享服务器连接。
配置网络环境以允许连接到多个数据库。
改进对网络文件目录的访问。
结束状态
在本技能集的末尾,proctor必须可以访问数据库PROD1、PROD2、PROD3、PROD4和EMREP。如果数据库未打开以供访问,则不会为此技能集授予任何学分。
1.不要更改数据库或操作系统的任何默认密码。
2.PROD1数据库中的示例模式HR、SH、BI和OE可以分别使用密码HR、SH、BI和OE进行访问。
3.您的系统上没有根访问权限。可以使用sudo执行任何脚本。
1.所有脚本都位于/home/oracle/scripts目录中。
2.使用/home/oracle/files位置创建执行技能集任务所需的任何外部文件。
3.除非指定,否则不要删除或更改目录结构和文件。目录结构和文件的未指定删除或更改可能会禁用评分。
·概述
1.如果需要和适用,您可以配置和使用图形用户界面工具,如EnterpriseManager数据库控制。
2.只能从Skillset6配置和使用EnterpriseManager网格控件。
3.数据文件大小不应超过2GB。
4.在proctor开始评分之前,在技能集的末尾,确保数据库服务器(即oddPC)上的/(即根)文件系统至少有15%的可用空间。在命令提示符下使用命令df-h检查可用空间。
Section1:CreateaDatabase
1.Createan11gR2database,PROD3,ontheManagementServerbyusingthecommandlineandrunthenecessaryscriptstocompletethePROD3databasecreation.Usethefollowingspecifications.
i.ThedatabasenameisPROD3.
TheinstancenameisPROD3.
EnsurethatthevaluefortheORACLE_SIDenvironmentalvariableissetinuppercase---forexample,ORACLE_SID=PROD3.
ThepasswordforSYSandSYSTEMisoracle.
ThereisasampleparameterfilenamedinitPROD3.orainthe/home/oracle/scriptsdirectorythatcanbecopiedtotheappropriatedirectoryandmodifiedasrequired.
ii.Runthenecessaryscripts.
iii.TheSYSTEMtablespaceshouldbelocallymanaged.
iv.Createandusethedirectorystructure/u01/app/oracle/oradata/PROD3/tostorethedatabasefiles.
第1节:创建数据库
一。使用命令行在管理服务器上创建11gR2数据库PROD3,并运行完成PROD3数据库创建所需的脚本。使用以下规格。
数据库名是PROD3。
实例名为PROD3。
请确保ORACLESID环境变量的值设置为大写,例如,ORACLESID=PROD3。
SYS和SYSTEM的密码是oracle。
在/home/oracle/scripts目录中有一个名为initPROD3.ora的示例参数文件,可以将其复制到相应的目录中,并根据需要进行修改。
二。运行必要的脚本。
系统表空间应在本地管理。
iv.创建并使用目录结构/u01/app/oracle/oradata/PROD3/来存储数据库文件。
操作部分:
在偶数机操作
Su-oracle(变更为oracle身份)
1.建库
建立auditdump目录:
mkdir-p/u01/app/oracle/admin/PROD3/adump(这个是审计目录,数据库spfile里执行后必须有这个目录,否则数据库起不来)
mkdir-p/u01/app/oracle/oradata/PROD3
vi/etc/oratab
PROD3:/u01/app/oracle/product/11.2.0/dbhome_1:Y
配置ORACLE_HOME环境变量
ExportORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
自己的解决方案配置PATH环境变量(字符串变量)
ExportPATH=$ORACLE_HOME/bin:$PATH(请老师确认是否正确)
建立passwordfile:
orapwdfile=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwPROD3force=ypassword=oracleignorecase=n
是否可以写成
orapwdfile=$ORACLE_HOME/dbs/orapwPROD3force=ypassword=oracleignorecase=n
编辑初始化参数文件:
vi/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPROD3.ora
Vi$ORACLE_HOME/dbs/initPROD3.ora
db_block_size=8192
db_domain="us.oracle.com"
db_name="PROD3"
instance_name=PROD3
control_files=("/u01/app/oracle/oradata/PROD3/control01.ctl","/u01/app/oracle/oradata/PROD3/control02.ctl")
compatible=11.2.0.0.0
undo_tablespace=UNDOTBS1
deferred_segment_creation=false
是否可以简化编辑初始化参数文件
db_create_file_dest='/u01/app/oracle/oradata'
control_files=('/u01/app/oracle/oradata/PROD3/control01.ctl','/u01/app/oracle/oradata/PROD3/control02.ctl')
sga_target=500m
注:
控制文件路径老师用的是双引号但实际操作建库的时候会报控制文件错误,改单引号就正确了请老师确认是否正确
启动实例到nomount状态:
exportORACLE_SID=PROD3
sqlplus/assysdba
startupnomount
CREATEDATABASEPROD3
MAXINSTANCES8
MAXLOGHISTORY1
MAXLOGFILES16
MAXLOGMEMBERS5
MAXDATAFILES100
DATAFILE'/u01/app/oracle/oradata/PROD3/system01.dbf'SIZE300MREUSEAUTOEXTENDONNEXT10240KMAXSIZE2G
EXTENTMANAGEMENTLOCAL
SYSAUXDATAFILE'/u01/app/oracle/oradata/PROD3/sysaux01.dbf'SIZE250MREUSEAUTOEXTENDONNEXT10240KMAXSIZE2G
DEFAULTTEMPORARYTABLESPACETEMPTEMPFILE'/u01/app/oracle/oradata/PROD3/temp01.dbf'SIZE100MREUSEAUTOEXTENDONNEXT640KMAXSIZE2G
UNDOTABLESPACEUNDOTBS1DATAFILE'/u01/app/oracle/oradata/PROD3/undotbs01.dbf'SIZE100MREUSEAUTOEXTENDONNEXT5120KMAXSIZE2G
CHARACTERSETUS7ASCII
NATIONALCHARACTERSETAL16UTF16
LOGFILE
GROUP1('/u01/app/oracle/oradata/PROD3/redo01.log')SIZE100M,
GROUP2('/u01/app/oracle/oradata/PROD3/redo02.log')SIZE100M,
GROUP3('/u01/app/oracle/oradata/PROD3/redo03.log')SIZE100M
USERSYSIDENTIFIEDBYoracleUSERSYSTEMIDENTIFIEDBYoracle;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catalog.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catproc.sql;
可选:
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catblock.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catoctk.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/owminst.plb;
connectSYSTEM/oracle
@/u01/app/oracle/product/11.2.0/dbhome_1/sqlplus/admin/pupbld.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/sqlplus/admin/help/hlpbld.sqlhelpus.sql;
重编译失效对象:
executeutl_recomp.recomp_serial();
createspfilefrompfile;
shutdownimmediate;
startup;
建库流程没有按老师的文档练用了另外一种方式比较好操作请老师确认
.Oraenv
PROD3回车切到PROD3数据库
Sqlplus/assysdba
SQL>!echo$ORACLE_HOME
/u01/app/oracle/product/11.2.0/dbhome_1
startupnomountpfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPROD3.ora';
createdatabasePROD3charactersetal32utf8extentmanagementlocal;
@/rdbms/admin/catalog.sql
@/rdbms/admin/catproc.sql
Alterusersysidentifiedbyoracle;
Alterusersystemidentifiedbyoracle;
Connsystem/oracle
@/sqlplus/admin/pupbld.sql
Conn/assysdba
createspfilefrompfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPROD3.ora';
Section2:CreateandConfigureaTablespace
1.CreateatemporarytablespacegroupnamedTEMP_GRPtosupportbatchprocessing,thecreationoflargeindexes,andanalysisoftablesonthePROD1database:
ThegroupshouldcontainthetemporarytablespacesTEMP1andTEMP2.
MakeTEMP_GRPthedefaulttemporarytablespaceforallnewusers.
奇数机:
PROD1与PROD2先备份(备份与老师文档不一致请老师确认是否正确)
Su-oracle
exportORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
exportPATH=$ORACLE_HOME/bin:$PATH
Mkdir-p/home/oracle/files/arch1
Mkdir-p/home/oracle/files/arch2
Mkdir-p/home/oracle/files/bak
(备份的数据库路径都放在/home/oracle/files下主要是考虑到放到/home/oracle下容易造成磁盘空间不足)
PROD1
startupmount;
altersystemsetlog_archive_dest_1='location=/home/oracle/files/arch1';
alterdatabasearchivelog;
alterdatabaseopen;
Exit;
.oraenv
PROD2
altersystemsetlog_archive_dest_1='location=/home/oracle/files/arch2';
cd/home/oracle/files
Virman.sh(全备脚本)
rmantarget/< run{ backupdatabaseformat'/home/oracle/files/bak/%d_%U.full'; sql'altersystemarchivelogcurrent'; backuparchivelogallformat'/home/oracle/files/bak/%d_%U.arc'; backupcurrentcontrolfileformat'/home/oracle/files/bak/%d_%U.ctl'; } EOF Chmod+xrman.sh .OraenvPROD1PROD2切换执行刚刚新建的rman.sh脚本使用方法cd/home/oracle/files后./rman.sh 创建PROD1EM Startup; alteruserdbsnmpidentifiedbyoracleaccountunlock;解锁dbsnmp用户 Lsnrctlstart;(创建em前先打开监听器,不然会报错) 错误提示没有打开监听 emca-configdbcontroldb-reposrecreate; Passwordforsysuser,passwordfordbsnmpuser,passwordforsystemuser三个用户老师给的环境密码都是oracle都填写oracle 等待3-5分钟(电脑差就挺慢了) emctlstatusdbconsole 复制黏贴红框ip地址到火狐浏览器打开 点击红框处 看到该页面显示就表示创建em成功 sqlplussys/oracle@prod1assysdba 还未配置监听使用(.oraenvPROD1sqlplus/assysdba) 第2节:创建和配置表空间 一。创建名为TEMP_GRP的临时表空间组,以支持批处理、创建大型索引和分析PROD1数据库上的表: 该组应包含临时表空间TEMP1和TEMP2。 使TEMP_GRP成为所有新用户的默认临时表空间。 createtemporarytablespacetemp1 tempfile'/u01/app/oracle/oradata/PROD1/temp1.dbf'size64Mautoextendonmaxsize2G extentmanagementlocaluniformsize1M tablespacegroupTEMP_GRP; createtemporarytablespacetemp2 tempfile'/u01/app/oracle/oradata/PROD1/temp2.dbf'size64Mautoextendonmaxsize2G alterdatabasedefaulttemporarytablespaceTEMP_GRP; 2.Createapermanenttablespacetostoresampletestdata.UsethefollowingspecificationsonthePROD1database. Tablespacename:TEST Initialdatafilesize:400MBwiththefileexpectedtogrowto4TB Initialextentsize:1MB Nextextentsize:1MB 翻译:2。创建一个永久表空间来存储样本测试数据。在PROD1数据库上使用以下规范。 表空间名称:TEST 初始数据文件大小:400MB,预计文件将增长到4TB 初始数据块大小:1MB 下一个数据块大小:1MB createbigfiletablespacetest datafile'/u01/app/oracle/oradata/PROD1/test01.dbf'size400Mautoextendonmaxsize4T extentmanagementlocaluniformsize1M; 3.Createapermanenttablespacetostoreindexes.UsethefollowingspecificationsonthePROD1database: Tablespacename:INDX Filesize:40MB 翻译:三个。创建永久表空间以存储索引。在PROD1数据库上使用以下规范: 表空间名称:INDX 文件大小:40MB createtablespaceindx datafile'/u01/app/oracle/oradata/PROD1/indx01.dbf'size40Mautoextendonmaxsize2G; 4.CreateapermanenttablespacetostoredatacollectedfromvariousOracletools.UsethefollowingspecificationsonthePROD1database: Tablespacename:TOOLS Filesize:10MB 翻译:四。创建一个永久表空间来存储从各种Oracle工具收集的数据。在PROD1数据库上使用以下规范: 表空间名称:工具 文件大小:10MB createtablespacetools datafile'/u01/app/oracle/oradata/PROD1/tools01.dbf'size10Mautoextendonmaxsize2G; 5.Createapermanenttablespaceforstoringsegmentsassociatedwithonlinetransactionprocessing(OLTP)foraccountswithhighinsertrates.Becauseofthepotentialhighvolumeofconcurrentinserts,everyeffortshouldbetakentoreducecontentionforeachofthetablesthatisstoredinthistablespace.UsethefollowingspecificationsonthePROD1database: Tablespacename:OLTP Filesize:48MB Initialextentsize:2MB Nextextentsize:2MB 表空间名称:OLTP 文件大小:48MB 初始数据块大小:2MB 下一个数据块大小:2MB createtablespaceoltp datafile'/u01/app/oracle/oradata/PROD1/oltp01.dbf'size48Mautoextendonmaxsize2G extentmanagementlocaluniformsize2M segmentspacemanagementauto; Section3:SetUpUndoManagement 1.SetupautomaticundomanagementinthePROD1databasetosupportthefollowingrequirements: AvoidtheORA-01555"Snapshottooold"errorforqueriesrunningupto90minutesonanaverage. ThenumberofconcurrentOLTPuserswillbeapproximately120duringnormalbusinesshours. Thenumberofconcurrentbatchprocessesthatwillrunintheeveningsandweekendswillbeapproximately12through15. 翻译:第3节:设置撤消管理 一。在PROD1数据库中设置自动撤消管理,以支持以下要求: 对于平均运行90分钟的查询,请避免出现ORA-01555“快照太旧”错误。 在晚上和周末运行的竞争性批处理过程的数量大约为12到15个。 altersystemsetundo_retention=5400; (下面2个我是根据题目来看的少了2个设置,请老师确认是否正确) altersystemsetprocesses=120scope=spfile; altersystemsetjob_queue_processes=15; Section4:Server-SideandClient-SideNetworkConfiguration 1.Performthefollowingtheclient-sidenetworkconfigurationtasksontheDatabaseServer.Provideconnectdescriptorsforyourdatabasebyusinglocalnamingandeasyconnectmethodswherenecessary. i.ThePROD1aliasshouldconnecttothePROD1instancebyusingthedefaultlistener,andalwaysuseadedicatedserverconnection. 翻译:第4节:服务器端和客户端网络配置 一。在数据库服务器上执行以下客户端网络配置任务。必要时,使用本地命名和简单连接方法为数据库提供连接描述符。 i.PROD1别名应使用默认侦听器连接到PROD1实例,并始终使用专用服务器连接。 lsnrctlstart vitnsnames.ora PROD1= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=odd.oracle.com)(PORT=1521)) ) (CONNECT_DATA= (SERVICE_NAME=PROD1.us.oracle.com) (server=dedicated) ii.ThePROD_SaliasshouldconnecttothePROD1instance. i.CreateanadditionallistenerLSNR2byusingport1526. 翻译:PROD_S的别名应连接到PROD1实例。 i、使用端口1526创建其他LSNR2列表。 vilistener.ora LSNR2= (ADDRESS=(PROTOCOL=tcp)(HOST=odd.oracle.com)(PORT=1526)) lsnrctlstartlistener2 ii.UseLSNR2andsharedserverconnectionforPROD_S. 翻译:二。对产品使用LSNR2和共享服务器连接。 PROD1_S= (server=shared) iii.ThePROD2aliasshouldconnecttothePROD2instancebyusingthedefaultlistenerLISTENER,TCP/IPport1521,andalwaysuseadedicatedserverconnection. 翻译:iii.PROD2别名应使用默认侦听器侦听器TCP/IP端口1521连接到PROD2实例,并始终使用专用服务器连接。 PROD2= (SERVICE_NAME=PROD2.us.oracle.com) iv.ThePROD3aliasshouldconnecttothePROD3instancebyusingthedefaultlistenerLISTENER,TCP/IPport1521,andalwaysuseadedicatedserverconnection. 翻译:iv.PROD3别名应使用默认侦听器侦听器TCP/IP端口1521连接到PROD3实例,并始终使用专用服务器连接。 PROD3= (ADDRESS=(PROTOCOL=tcp)(HOST=even.oracle.com)(PORT=1521)) (SERVICE_NAME=PROD3.us.oracle.com) v.TheEMREPaliasshouldconnecttotheEMREPinstancebyusingthedefaultlistenerLISTENER,TCP/IPport1521,andalwaysuseadedicatedserverconnection. 翻译:v、EMREP别名应使用默认侦听器侦听器TCP/IP端口1521连接到EMREP实例,并始终使用专用服务器连接。 EMREP= (SERVICE_NAME=EMREP.us.oracle.com) vi.TheRACDBaliasshouldconnecttotheRACDBservice(createdlater)withadedicatedserverconnection. TheRACDBservicewillberunningonyourRACcluster. Givenbelowarethedetailstocreateanalias: ScanName:cluster01-scan.example.com ServiceName:RACDB 翻译:六.TheRacdb,aliasshouldconnecttotheRackbService(createdlater)withadedicatedserverconnection. TheRacdbServicewillberunningonyourraccluster. Givenbelowarethedetailstocreateanalias: Scanname:Cluster01-scan.example.com 服务名称:Racdb RACDB= (ADDRESS=(PROTOCOL=tcp)(HOST=cluster01-scan.example.com)(PORT=1521)) (SERVICE_NAME=RACDB.us.oracle.com) vii.ThePROD4aliasshouldconnecttothePROD4instancebyusingthedefaultlistenerLISTENER,TCP/IPport1521,andalwaysuseadedicatedserviceconnection. 翻译:七。PROD4别名应使用默认侦听器侦听器TCP/IP端口1521连接到PROD4实例,并始终使用专用服务连接。 PROD4= (SERVICE_NAME=PROD4.us.oracle.com) (练习时我用的监听图形化请老师确认是否正确) Exit;(退出PROD1数据库操作) Cd$ORACLE_HOME/bin ExportDISPLAY=192.168.72.1:0.0(使用的是静态ip配的网关) Netmgr打开监听图形化 测试远程连接数据库RACDB不用测PROD_S放在后面远程测试连接(考试时必须要保证远程能正常连数据库不然就是没分) 测试前打开所有的监听 奇数机:lsnrctlstartlsnrctlstartLSNR2偶数机:lsnrctlstart启动数据库奇数机:PROD1PROD2偶数机:PROD3PROD4EMREP 测试远程代码Sqlplussystem/oracle@prod1sqlplussystem/oracle@prod2sqlplussystem/oracle@prod3sqlplussystem/oracle@prod4sqlplussystem/oracle@emrep(老师给的环境emrepservice_name并不是文档写的EMREP.us.oracle.com而是EMREP) 如图: 由于service_names不对监听器配置的是EMREP.us.oracle.com无法远程连接到emrep需要进行service_names修改 Section5:ConfiguretheDatabase 1.InvestigatetheparameterfileofthePROD1databaseforreasonablesizesforeachparameterlisted.Addparametersasyoudeemnecessarytosupportanoptimaldatabaseenvironmentinaddition,modifyoraddtheparametertospecifythefollowingdirectoriesthatthedatabaseshoulduseforPL/SQLI/Otothefilesystem:/home/oracle,/home/oracle/temp,and/home/oracle/scriptsandensurethatthisispersistentacrossallPROD1databaseinstancestartups. 翻译:第5节:配置数据库 一。调查PROD1数据库的参数文件,了解所列每个参数的合理大小。添加您认为支持最佳数据库环境所必需的参数。此外,修改或添加该参数,以指定数据库应用于文件系统的PL/SQLI/O的以下目录:home/oracle、/home/oracle/temp和/home/oracle/scripts,并确保这在所有PROD1数据库实例中都是持久的创业公司。 altersystemsetutl_file_dir='/home/oracle','/home/oracle/temp','/home/oracle/scripts'scope=spfile; Section6:ConfiguretheSharedServer 1.ConfigurethePROD1databasetosupportupto300sessions,reserving100fordedicatedconnections. 翻译:第6节:配置共享服务器 一。将PROD1数据库配置为最多支持300个会话,为专用连接保留100个会话。 altersystemsetsessions=300scope=spfile; altersystemsetshared_server_sessions=200scope=spfile; altersystemsetcircuits=200scope=spfile; startup 2.ConfigurethePROD1databasetosupport: i.DefaultofthreeTCPdispatchers ii.Maximumof10dispatchers 翻译:2.配置PROD1数据库以支持: altersystemsetdispatchers='(protocol=tcp)(dispatchers=3)'; altersystemsetmax_dispatchers=10; 3.ConfigurethePROD1databasetosupport: i.Aminimumof10sharedserverprocesses ii.Amaximumof30sharedserverprocesses 翻译:3.配置PROD1数据库以支持: I.至少10个共享服务器进程 Ii.最多30个共享服务器进程 altersystemsetshared_servers=10; altersystemsetmax_shared_servers=30; 做到这里可以设置prod_s的连接了 altersystemsetlocal_listener='prod_s','prod1'; 一定要启动lsnrctlstartLSNR2LSNR2监听 远程连接prod_ssqlplussystem/oracle@prod_s Section7:DatabaseBackupandAvailability 1.TriplexthecontrolfileonthePROD1databasetominimizerecoverytimeincaseofdiskdrivefailure. 翻译:第7节:数据库备份和可用性 altersystemsetcontrol_files='/u01/app/oracle/oradata/PROD1/control01.ctl','/u01/app/oracle/oradata/PROD1/control02.ctl','/u01/app/oracle/oradata/PROD1/control03.ctl'scope=spfile; hostcp/u01/app/oracle/oradata/PROD1/control01.ctl/u01/app/oracle/oradata/PROD1/control03.ctl 此处应该是cp/u01/app/oracle/oradata/PROD1/control01.ctl/u01/app/oracle/oradata/PROD1/control03.ctl Sqlplus/assysdba(由于prod数据库关闭了所以不能远程连了) 2.BackupthePROD1andPROD2databasetoprepareforcompleterecoveryunderallcircumstances. 翻译:2。备份PROD1和PROD2数据库,以备在任何情况下进行完全恢复。 altersystemsetdb_recovery_file_dest_size=5G; altersystemsetdb_recovery_file_dest='/home/oracle/files'; rmantarget/ CONFIGURECONTROLFILEAUTOBACKUPon; backupascompressedbackupsetdatabaseplusarchivelog; (PROD1和PROD2都要进行备份操作与上面一样请老师确认是否正确) Section8:CollectSchemaStatistics 1.CollectactualstatisticsfortheHRschemainthePROD1databaseasnecessary,forusewithcost-basedoptimization. 翻译:第8节:收集架构统计信息 一。必要时,收集PROD1数据库中人力资源模式的当前统计数据,以便与基于成本的优化一起使用。 execdbms_stats.gather_schema_stats('HR'); Section9:ConfiguretheParameterFile 1.TherearemultipleOracledatabasesrunningontheDatabaseServer. ConfigurethePROD1databasesuchthatdiagnosticinformationaboutcriticalerroreventsisstoredinaneasilyaccessiblelocation,namelyORACLE_HOME. 翻译:第9节:配置参数文件 一。数据库服务器上运行多个Oracle数据库。 配置PROD1数据库搜索,将有关严重错误事件的诊断信息存储在一个易于访问的位置,即ORACLEHOME。 altersystemsetdiagnostic_dest='/u01/app/oracle/product/11.2.0/dbhome_1'; Section10:ImproveAccesstoNetworkFileDirectories 1.Configureandimproveaccesstothenetworkfiledirectories. i.Youneedtoimproveaccesstothenetworkfiledirectories. ConfigurethePROD1databasetoavoidusingtheoperatingsystemKernelNFSclient. Themountpointdetailsareasfollows: MountpointavailableontheDatabaseServer:/u02/oradata/prod1 SharedlocationontheManagementServer:/vol/oradata 翻译:第10节:改进对网络文件目录的访问 一。配置并改进对网络文件目录的访问。 i、您需要改进对网络文件目录的访问。 配置PROD1数据库以避免使用操作系统内核NFS客户端。 安装点详细信息如下: 数据库服务器上可用的装入点:u02/oradata/prod1 管理服务器上的共享位置:/vol/oradata 在管理机上执行: mkdir-p/vol/oradata chmod-R777/vol/oradata (这一步只能在root用户权限操作但考试root用户被锁住只能用sudo请老师确认是否正确) [oracle@even~]$sudochmod-R777/vol/oradata servicenfsstart exportPATH="$PATH:/sbin"(将service的路径写入PATH) [oracle@evenetc]$sudoservicenfsstart vi/etc/exports 把以下内容添加进去: /vol/oradata192.168.92.80(rw,sync) exportfs-a exportfs–v /vol/oradata192.168.72.80(rw,sync)(因为之前设置了静态ip192.168.72.80)这里面的ip地址也跟着变了或者也可以用/vol/oradata*(rw,sync)解决ip问题 exportfs-v sudoservicenfsstop Sudoservicenfsstart (练习过程中在编辑/etc/exports之前启动nfs服务奇数机挂载会报错,当/etc/exports编辑完成后启动nfs服务,奇数机挂载就正确,请老师确认是否正确) 在数据库机上执行: mkdir-p/u02/oradata/prod1 mount-tnfs192.168.92.90:/vol/oradata/u02/oradata/prod1 sudomount-tnfs192.168.72.90:/vol/oradata/u02/oradata/prod1 cd$ORACLE_HOME/dbs vioranfstab --addfollowings: server:ocmnfs path:192.168.92.90 export:/vol/oradatamount:/u02/oradata/prod1 path:192.168.72.90(由于修改了静态ip) cd$ORACLE_HOME/rdbms/lib make-fins_rdbms.mkdnfs_on 重启PROD1数据库 shutdownimmediate ii.Createapermanenttablespacebyusingthefollowingspecifications: Tablespacename:SHARED_DATA Datafilesize:10MB Thetablespacemustusethemountednetworkfilesystem(NFS)forthedatafile. 翻译:ii.使用以下规范创建永久表空间: 表空间名称:SHARED 数据文件大小:10MB 表空间必须对数据文件使用挂载的网络文件系统(NFS)。 createtablespaceshared_datadatafile'/u02/oradata/prod1/shared_data.dbf'size10M; select*fromv$dnfs_servers; Section11:ApplyaPatch 1.Applythepatch12834800tothePROD4databasewithoutshuttingdownthedatabase.Usethep12834800_112030_LINUX.zipfilethatisinthe/home/oraclefolder. 翻译:第11节:修补 一。在不关闭数据库的情况下,将补丁12834800应用到PROD4数据库。使用/home/oracle文件夹中的p12834800_112030_LINUX.zip文件。 偶数机操作: unzipp12834800_112030_LINUX.zip 查看README.txt里的(2.2)InstallinginOnlineMode部分。 cd12834800 打补丁前一定要提前启prod4库不启prod4库打补丁会报错 /u01/app/oracle/product/11.2.0/dbhome_1/OPatch/opatchapplyonline-connectStringPROD4:sys:oracle: 选择Y是的 /u01/app/oracle/product/11.2.0/dbhome_1/OPatch/opatchlsinventory Section12:CreateanASMInstanceandConfigureGridInfrastructure 1.StartGridinfrastructureontheManagementServerandregisterthefollowingdatabaseintheOracleLocalRegistry(OLR). i.PROD4 ii.EMREP 翻译:第12节:创建一个ASM实例并配置网格基础设施 一。在管理服务器上启动网格基础结构,并在Oracle本地注册表(OLR)中注册以下数据库。 I.PROD4 Ii.EMREP /u01/app/11.2.0/grid/bin/crsctlstatusres-t 如果报错:CRS-4000:CommandStatusfailed,orcompletedwitherrors,则需要启动ohasd /u01/app/11.2.0/grid/bin/crsctlstartohasd /u01/app/11.2.0/grid/bin/crsctlstartresora.cssd /u01/app/11.2.0/grid/bin/srvctladddatabase-dPROD4-o/u01/app/oracle/product/11.2.0/dbhome_1-p/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilePROD4.ora /u01/app/11.2.0/grid/bin/srvctladddatabase-dEMREP-o/u01/app/oracle/product/11.2.0/dbhome_1-p/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileEMREP.ora 2.CreateanASMinstanceandaddtwodiskgroups:DATAandFRA i.UsenormalredundancyforDATAandexternalredundancyforFRA. ii.UsetheASMdisks1to4forDATAandASMdisks5to8forFRA. 翻译:2创建一个ASM实例并添加两个磁盘组:DATA和FRA i数据使用常规冗余,FRA使用外部冗余。 Ii.数据使用ASM磁盘1到4,FRA使用ASM磁盘5到8。 进入gridhome的dbs目录下,编辑init+ASM.ora, exportORACLE_HOME=/u01/app/11.2.0/gridinit+ASM.ora Cd$ORACLE_HOME/dbs Viinit+ASM.ora instance_type=ASM ExportORACLE_SID=+ASM sqlplus/assysasm creatediskgroupdatanormalredundancydisk 'ORCL:ASMDISK1', 'ORCL:ASMDISK2', 'ORCL:ASMDISK3', 'ORCL:ASMDISK4' attribute 'compatible.asm'='11.2', 'compatible.rdbms'='11.2'; creatediskgroupfraexternalredundancydisk 'ORCL:ASMDISK5', 'ORCL:ASMDISK6', 'ORCL:ASMDISK7', 'ORCL:ASMDISK8' 3.RegisterthefollowingwithGridinfrastructure: i.ASMandthediskgroups ii.Thelistener 翻译:三。向网格基础设施注册以下内容: I.ASM和磁盘组 Ii.监听 /u01/app/11.2.0/grid/bin/srvctladdlistener-llistener-s-o/u01/app/oracle/product/11.2.0/dbhome_1 /u01/app/11.2.0/grid/bin/srvctladdasm-llistener-p/u01/app/11.2.0/grid/dbs/init+ASM.ora-d'ORCL:*' altersystemsetasm_diskgroups=data,fra; /u01/app/11.2.0/grid/bin/srvctlstartasm exportORACLE_SID=+ASM Sqlplus/assysasm alterdiskgroupdatamount; alterdiskgroupframount; 最后检查是否正确利用图形化 ExportDISPLAY=192.168.72.1:0.0 ./asmca 磁盘组状态全部mounted就表示正确 Inthisskillset,youconfigureanRMANrecoverycatalog.Youperformcompletebackups,restorationandrecovery.YoualsoconfigureFlashbackDatabasetouseittoperformaflashbackoperation. ThePROD1,PROD2andPROD4databasesmustbeopenandaccessible.Nocreditwillbegivenfortheskillsetifthedatabasesarenotopenforaccess. 翻译:第二部分 在此技能集中,您可以配置RMAN恢复目录。执行完整的备份、还原和恢复。您还可以将闪回数据库配置为使用它执行闪回操作。 配置恢复目录。 配置RMAN。 执行完整的数据库备份。 配置和监控闪回数据库。 PROD1、PROD2和PROD4数据库必须是开放和可访问的。如果数据库未打开以供访问,则不会授予技能集任何学分。 先远程连接sqlplussystem/oracle@prod1sqlplussystem/oracle@prod2sqlplussystem/oracle@prod4查看是否连接正常 如果启PROD1出现错误 如图: 可以从第一场备份的PROD1进行数据恢复 Rmantarget/ Listfailure; Advisefailure; Repairfailure;(三板斧) Section1:ConfiguretheRecoveryCatalog ConnecttotherecoverycatalogcreatedonthePROD4database.Therecoverycatalogownerisrc_adminandthepasswordisRC_ADMIN. 翻译:第1节:配置恢复目录 连接到在PROD4数据库上创建的恢复目录。恢复目录所有者是rc_admin,密码是rc_admin。 偶数机: exportORACLE_SID=PROD4 createuserrc_adminidentifiedbyRC_ADMIN; grantconnect,recovery_catalog_ownertorc_admin; alteruserrc_adminquotaunlimitedonusers; rmancatalogrc_admin/RC_ADMIN createcatalog; 1.MakesurethattherecoverycatalogiscompatiblewiththeOracleDatabase11gRMANclientontheDatabaseServermachine. 用高版本的RMAN去连接低版本的catalog 奇数机操作: rmantargetsys/oracle@prod1catalogrc_admin/RC_ADMIN@prod4 upgradecatalog; 升级完毕catalog以后,再连一次catalog确定没有告警信息: 2.RegisterthePROD1andPROD2databasewiththerecoverycatalog. registerdatabase; rmantargetsys/oracle@prod2catalogrc_admin/RC_ADMIN@prod4 Section2:Backups CreatebackupsofthePROD1andPROD2databases.Allbackupsshouldbelistedintherecoverycatalog. 1.CreateabackupforthePROD2databasethatcanbeusedforrecoveryunderanycircumstances.Ensurethatyouhaveacompletesetoffilesfromwhichtorecoverifamediafailureoccurs. 翻译:第2节:备份 创建PROD1和PROD2数据库的备份。所有备份都应列在恢复目录中。 rmantargetsys/oracle@prod2catalogrc_admin/RC_ADMIN@prod4(使用catalog方式进行备份) CONFIGURECONTROLFILEAUTOBACKUPON; backupdatabase; sql'altersystemswitchlogfile'; backuparchivelogall; #backupcurrentcontrolfile; backupcurrentcontrolfile;(不需要前面的#号) 记录备份过程中产生的输出信息 2.Createalong-termbackupofthePROD1databaseforarchivalpurposes.UsetagQ107. 翻译:2。为存档目的创建PROD1数据库的长期备份。使用标签Q107。 mkdir-p/home/oracle/files/PROD1/backupforever backupdatabasetagQ107keepforeverformat'/home/oracle/files/PROD2/backupforever/%U';; backupdatabasetagQ107keepforeverformat'/home/oracle/files/PROD1/backupforever/%U'; 3.ThebackupprocessoftheEXAMPLEdatafileinthePROD1databasetakesalongtime.Performthenecessaryconfigurationtospeedupthebackupprocessandreducethesizeofthebackupfiles.Thesizeforeachbackupfileshouldnotbegreaterthan30MB. CONFIGUREDEVICETYPEDISKPARALLELISM4BACKUPTYPETOBACKUPSET; backupascompressedbackupsettablespaceexamplesectionsize30M; 4.ReducetheoverheadsoffastincrementalbackupstoaminimumonthePROD1database. 翻译:4.将PROD1数据库上快速增量备份的开销降至最低。 Sqlplussys/oracle@prod1assysdba ALTERDATABASEENABLEBLOCKCHANGETRACKINGUSINGFILE'/home/oracle/files/change_tracking.file'; Section3:ConfigureFlashback 1.EnableFlashbackDatabaseforthePROD1database. i.Configureafastrecoveryareaof4GB. ii.Thefastrecoveryareashouldbeinthe/home/oracle/flashdirectoryontheDatabaseServer. 翻译:第三节配置闪回 1.为PROD1数据库启用闪回数据库。 I.配置4GB的快速恢复区域。 Ii.快速恢复区域应该在数据库服务器上的目录中。 altersystemsetdb_recovery_file_dest_size=4G; altersystemsetdb_recovery_file_dest='/home/oracle/flash'; alterdatabaseflashbackon; 2.InthePROD1database,intheHRschema,theDEPARTMENT_IDcolumnistheprimarykeyoftheDEPARTMENTStable.Performnecessaryconfigurationstosupporttransactionblackoutinallpossibledependencies. i.LoginasHRandrunthescript2_3_2.sqltoperformseriesofinsertandthenupdatetransactions. ii.ReinstatethevalueintheDEPARTMENTStablewiththeoriginalvaluesbeforetheupdatetransactions. 翻译:2.在PROD1数据库的HR模式中,DEPARTMENT_ID列是DEPARTMENTS表的主键。执行必要的配置以支持所有可能的依赖项中的事务中断。 Ii.使用更新事务之前的原始值恢复DEPARTMENTS表中的值。 先确保数据库是归档模式。 Archiveloglist;(检查数据库是否是归档模式) alterdatabaseaddsupplementallogdata; alterdatabaseaddsupplementallogdata(primarykey)columns; connecthr/hr@prod1 @/home/oracle/scripts/2_3_2.sql 先找出departments上发生的事务ID: connectsys/oracle@prod1assysdba SELECTXID,OPERATIONFROMFLASHBACK_TRANSACTION_QUERYWHEREupper(table_name)='DEPARTMENTS'; XIDOPERATION ------------------------------------------------ 03000A00BE020000UPDATE 02000A00A4020000UPDATE 0100020013020000INSERT 主要是2个update的XID(练习中这个XID是一个随机数,根据查询结果来) DECLARE V_XIDSYS.XID_ARRAY; BEGIN V_XID:=SYS.XID_ARRAY('03000A00BE020000','02000A00A4020000'); DBMS_FLASHBACK.TRANSACTION_BACKOUT(2,V_XID); END; / V_XID:=SYS.XID_ARRAY('01000F00B1020000','070009006C030000');(后面两个是update里面的xid根据上方查询得到的随机xid的值) 如果出错,则先把department_idin(290,300,310)的三条记录删除,然后执行 deletefromhr.departmentswheredepartment_idin(290,300,310); alterdatabasedropsupplementallogdata(primarykey)columns; alterdatabasedropsupplementallogdata; V_XID:=SYS.XID_ARRAY('xx,'xx);(后面两个是update里面的xid根据上方查询得到的随机xid的值) 多做几次日志切换,至少4次。然后重新添加supplementallog,并执行2_3_2.sql。 Inthisskillset,youdemonstratetheskillsrequiredtoadministeranOracledatabasethatisusedforaDataWarehouse.Youdiagnosewhyamaterializedviewisnotfastrefreshingandtroubleshootthis.Youconfigurethedatabasetoacceptnewtablespaceswithdatafilesfromdifferentoperatingsystemsandconfiguretheenvironmenttosupportsecurefilesandparallelexecution. ThePROD1,PROD2,andPROD4databasesmustbeopenandaccessible.Nocreditwillbegivenfortheskillsetifthedatabasesarenotopenforaccess. 翻译:第三部分 在此技能集中,您将演示管理用于数据仓库的Oracle数据库所需的技能。您可以诊断为什么物化视图不能快速刷新并对此进行故障排除。将数据库配置为接受包含来自不同操作系统的数据文件的新表空间,并将环境配置为支持安全文件和并行执行。 创建数据库链接。 创建一个快速刷新的物化视图。 使用可传输表空间功能创建插件表空间。 优化星级查询。 配置并行执行。 Section1:CreateaDatabaseLink 1.CreateadatabaselinkcalledPROD_LINKtopermitallusersinthePROD2databasetoaccessthePROD1database.AllPROD2databaseusersshouldbeabletoconnecttoPROD1usingthelinkandconnectastheSYSTEMuseronthePROD1database. 翻译:第1节:创建数据库链接 一。创建名为PROD_link的数据库链接,以允许PROD2数据库中的所有用户访问PROD1数据库。所有PROD2数据库用户都应该能够使用该链接连接到PROD1,并作为PROD1数据库上的系统用户进行连接。 第三场是小破坏一般是删除数据文件看情况而定运气好可以直接切到PROD2库rmantarget/listfailureadvisefailurerepairfailure(三板斧解决) Prod2会被破坏,需要先恢复prod2 viinitPROD2.ora db_name=PROD2 [oracle@odddbs]$echo$ORACLE_SID SQL>startupnomount; [oracle@odddbs]$rmantarget/ RMAN>restorespfilefrom'/home/oracle/files/PROD2/autobackup/2019_06_29/o1_mf_s_1012214447_gkfmxhbo_.bkp'; 注意这里红色的部分表示控制文件的自动备份,该自动备份是在前面创建备份的时候,而生成的。前面在备份的时候,所有的输出都需要记录到一个自己的日志里,便于在这里找到控制文件的自动备份位于哪个文件里。 Spfile恢复以后,把原来的pfile删除,并用恢复出来的spfile启动实例到nomount状态 [oracle@odddbs]$rm-rfinitPROD2.ora RMAN>restorecontrolfilefrom'/home/oracle/files/PROD2/autobackup/2019_06_29/o1_mf_s_1012214447_gkfmxhbo_.bkp'; RMAN>alterdatabasemount; 查看一下联机日志文件的序列号,如下序列号为10的日志文件的归档状态为NO,说明该日志文件没有归档,所以setuntilsequence10 SQL>selectgroup#,sequence#,status,archivedfromv$log; GROUP#SEQUENCE#STATUSARC --------------------------------------- 110CURRENTNO 39ACTIVEYES 28ACTIVEYES RMAN>run{ 2>setuntilsequence10; 3>restoredatabase; 4>recoverdatabase; 5>} RMAN>alterdatabaseopenresetlogs; 我直接模拟重大破坏我是直接把PROD2库整个删了 我没有根据老师的文档来我用我自己的恢复方式请老师确认是否正确 PROD2整个库删了以后 Vi/etc/oratab 加上PROD2:/u01/app/oracle/product/11.2.0/dbhome_1:Y 查看cd/u01/app/oracle/oradata如果里面没有PROD2文件夹新建一个PROD2文件夹 mkdir/u01/app/oracle/oradata/PROD2 Startupnomount; 根据提示在$ORACLE_HOME/dbs路径下创建initPROD2.ora(询问了一下同学最大的破坏就是数据库全删只保留一个pfile应该是这个文件请老师确认一下) mkdir$ORACLE_HOME/dbs/initPROD2.ora db_name="PROD2" instance_name=PROD2 control_files=('/u01/app/oracle/oradata/PROD2/control01.ctl','/u01/app/oracle/oradata/PROD2/control02.ctl') /2019_06_29/o1_mf_s_1012214447_gkfmxhbo_.bkp'; cd2020_04_06看到下面的备份文件 RMAN>restorespfilefrom'/home/oracle/files/PROD2/autobackup/2020_04_06/o1_mf_s_1037023741_h8okvz3h_.bkp';(还原spfile) RMAN>restorecontrolfilefrom'/home/oracle/files/PROD2/autobackup/2020_04_06/o1_mf_s_1037023741_h8okvz3h_.bkp';(还原控制文件) Sqlplus/assysdba(进PROD2) Shutdownimmediate; 查看日志cat/u01/app/oracle/diag/rdbms/prod2/PROD2/trace/alert_PROD2.log 无法打开/u01/app/oracle/admin/PROD2/adump/..查看是否有该文件夹 查看发现cd/u01/app/oracle/admin没有PROD2要新建/u01/app/oracle/admin/PROD2/adump mkdir-p/u01/app/oracle/admin/PROD2/adump mkdir-p/u01/app/oracle/admin/PROD2/dump mkdir-p/u01/app/oracle/admin/PROD2/pfile Startupmount; createpublicdatabaselinkPROD_LINKconnecttosystemidentifiedbyoracleusing'PROD1'; Section2:FastRefreshableMaterializedViews 1.EnsurethatthePROD_MVmaterializedviewintheSHschemainthePROD1databaseisfastrefreshed,andallowsrewrites. 翻译:第2节:快速刷新的物化视图 SQL>setlong9999999 Connsh/sh@prod1 SQL>selectqueryfromuser_mviewswheremview_name='PROD_MV'; QUERY -------------------------------------------------------------------------------- SELECTtime_id,prod_subcategory,SUM(unit_cost)ASsum_units FROMcostsc,productsp WHEREc.prod_id=p.prod_id GROUPBYtime_id,prod_subcategory Connsys/oracle@prod1assysdba grantadvisortosh; connectsh/sh@prod1 declare ls_sqlvarchar2(3000); ls_tasknamevarchar2(1000); begin ls_taskname:='MYTASK'; ls_sql:=q'[creatematerializedviewPROD_MVrefreshfastasSELECTtime_id,prod_subcategory,SUM(unit_cost)ASsum_unitsFROMcostsc,productspWHEREc.prod_id=p.prod_idGROUPBYtime_id,prod_subcategory]'; DBMS_ADVISOR.TUNE_MVIEW( task_name=>ls_taskname, mv_create_stmt=>ls_sql); end; setlong999999 selectSTATEMENTfromDBA_TUNE_MVIEWwheretask_name='MYTASK'orderbyACTION_ID; 在查询的结果里面依次执行 CREATEMATERIALIZEDVIEWLOGON"SH"."COSTS"WITHROWID,SEQUENCE("PROD_ID","TIME_ID","UNIT_COST")INCLUDINGNEWVALUES; CREATEMATERIALIZEDVIEWLOGON"SH"."PRODUCTS"WITHROWID,SEQUENCE("PROD_ID","PROD_SUBCATEGORY")INCLUDINGNEWVALUES; dropMaterializedviewSH.PROD_MV; CREATEMATERIALIZEDVIEWSH.PROD_MV REFRESHFASTWITHROWID ENABLEQUERYREWRITE AS SELECTSH.PRODUCTS.PROD_SUBCATEGORYC1,SH.COSTS.TIME_IDC2,SUM("SH"."COSTS"."UNIT_COST")M1,COUNT("SH"."COSTS"."UNIT_COST")M2,COUNT(*)M3 FROMSH.PRODUCTS,SH.COSTS WHERESH.COSTS.PROD_ID=SH.PRODUCTS.PROD_ID GROUPBYSH.PRODUCTS.PROD_SUBCATEGORY,SH.COSTS.TIME_ID; Section3:OptimizeStarQueries 1.Maketherequiredchangestothe3_3_1.sqlscriptinthe/home/oracle/scriptsfoldertoensurethatthequeryexecutesasastartransformationqueryandmakesurethattransformationsarealsopossibleforanyotherqueryinanyotherschemainPROD1databasewhenthatschemaissuitablyconfigured. Note:Startransformationsmustbefullyconfiguredtopermittheuseoftemporarytables. 翻译:第3节:优化星形查询 一。对/home/oracle/scripts文件夹中的3_3_1.sql脚本进行所需的更改,以确保查询作为星型转换查询执行,并确保在适当配置架构时,PROD1数据库中任何其他架构中的任何其他查询也可以进行转换。 注意:必须完全配置星型转换以允许使用临时表。 cd/home/oracle/scripts cat3_3_1.sql SELECTch.channel_class,c.cust_city,t.calendar_quarter_desc, SUM(s.amount_sold)sales_amount FROMsh.saless,sh.timest,sh.customersc,sh.channelsch WHEREs.time_id=t.time_id ANDs.cust_id=c.cust_id ANDs.channel_id=ch.channel_id ANDc.cust_state_province='CA' ANDch.channel_descin('Internet','Catalog') ANDt.calendar_quarter_descIN('1999-Q1','1999-Q2') GROUPBYch.channel_class,c.cust_city,t.calendar_quarter_desc 星型转换的前提条件: 初始化参数: connect/assysdba altersystemsetstar_transformation_enabled=true; 2、事实表与维度表的关联字段上要有外键: connectsh/sh selectconstraint_name,constraint_type,status,validatedfromuser_constraintswheretable_name='SALES'; CONSTRAINT_NAMECSTATUSVALIDATED ---------------------------------------------------- SALES_PRODUCT_FKRENABLEDNOTVALIDATED SALES_TIME_FKRENABLEDNOTVALIDATED SALES_CHANNEL_FKRENABLEDNOTVALIDATED SALES_PROMO_FKRENABLEDNOTVALIDATED SYS_C0011009CENABLEDVALIDATED SYS_C0011010CENABLEDVALIDATED SYS_C0011011CENABLEDVALIDATED SYS_C0011012CENABLEDVALIDATED SYS_C0011013CENABLEDVALIDATED SYS_C0011014CENABLEDVALIDATED SYS_C0011015CENABLEDVALIDATED SALES_CUSTOMER_FKRENABLEDNOTVALIDATED 12rowsselected. SQL> 把time_id和cust_id上的外键设置为validate状态: altertablesalesenablevalidateconstraintSALES_TIME_FK; altertablesalesenablevalidateconstraintSALES_CUSTOMER_FK; altertablesalesenablevalidateconstraintSALES_CHANNEL_FK; 检查times表和customers表的主键的状态: SQL>selectconstraint_name,constraint_type,status,validatedfromuser_constraintswheretable_name='TIMES'andconstraint_type='P'; TIMES_PKPENABLEDNOTVALIDATED altertabletimesenablevalidateconstraintTIMES_PK; selectconstraint_name,constraint_type,status,validatedfromuser_constraintswheretable_name='CUSTOMERS'andconstraint_type='P'; CUSTOMERS_PKPENABLEDNOTVALIDATED altertablecustomersenablevalidateconstraintCUSTOMERS_PK; selectconstraint_name,constraint_type,status,validatedfromuser_constraintswheretable_name='CHANNELS'andconstraint_type='P'; CHANNELS_PKPENABLEDNOTVALIDATED altertablechannelsenablevalidateconstraintCHANNELS_PK; 在事实表的外键列上要有bitmap索引: SQL>selectindex_namefromuser_ind_columnswheretable_name='SALES'andcolumn_name='TIME_ID'; INDEX_NAME ------------------------------ SALES_TIME_BIX SQL>selectindex_namefromuser_ind_columnswheretable_name='SALES'andcolumn_name='CUST_ID'; SALES_CUST_BIX selectindex_namefromuser_ind_columnswheretable_name='SALES'andcolumn_name='CHANNEL_ID'; SALES_CHANNEL_BIX 删除bitmap索引(考试不会用到) Dropindexsh.SALES_TIME_BIX; Dropindexsh.SALES_CUST_BIX; Dropindexsh.SALES_CHANNEL_BIX; 如果没有建bitmap索引可以用下面的方式建bitmap索引 createbitmapindexcust_id_indonsh.sales(cust_id)local; createbitmapindextime_id_indonsh.sales(time_id)local; createbitmapindexchannel_id_indonsh.sales(channel_id)local; 4、收集优化器统计信息 execdbms_stats.gather_table_stats('SH','SALES',cascade=>true); execdbms_stats.gather_table_stats('SH','TIMES',cascade=>true); execdbms_stats.gather_table_stats('SH','CUSTOMERS',cascade=>true); execdbms_stats.gather_table_stats('SH','CHANNELS',cascade=>true); 5、验证执行计划: setautotracetraceonlyexp; @/home/oracle/scripts/3_3_1.sql Section4:CreateaPlug-inTablespaceandExternalTables 1.Createaplug-intablespace,TRPDATA,byusingthetransportabletablespacefeatureinthePROD1database. i.Thedatafiletobetransported,TRPDATA_6,iscreatedonabigendianplatform,thatis,Solaris64-bit. ii.UsetheTRPDATA_6datafileandthetrans3_2.dmpdumpfilelocatedinthe/home/oracle/scriptsdirectory. iii.TheexporteduserisSST.ThetablespaceobjectsshouldbelongtotheSSTuser. 翻译:第4节:创建插件表空间和外部表 一。使用PROD1数据库中的transportabletablespace特性创建一个插件表空间TRPDATA。 i.要传输的数据文件TRPDATA_6是在一个大端平台(即Solaris64位)上创建的。 二。使用TRPDATA_6数据文件和位于/home/oracle/scripts目录中的trans3_2.dmp转储文件。 三、出口用户为SST。表空间对象应该属于SST用户。 获得具体的platform的名称: selectPLATFORM_NAME,ENDIAN_FORMATfromv$transportable_platformorderby2,1; RMAN>convertdatafile'/home/oracle/scripts/TRPDATA_6'fromplatform'Solaris[tm]OE(64-bit)'format'/u01/app/oracle/oradata/PROD1/TRPDATA_6.dbf'; Sqlplussys/oracle@prod1assysdba; createdirectoryscriptdiras'/home/oracle/scripts'; grantread,write,executeondirectoryscriptdirtopublic; createusersstidentifiedbyoracle; grantdbatosst; viprod1_imp.par userid=system/oracle@prod1 directory=scriptdir dumpfile=trans3_2.dmp TRANSPORT_DATAFILES=('/u01/app/oracle/oradata/PROD1/TRPDATA_6.dbf') job_name=impjob impdpparfile=prod1_imp.par altertablespaceTRPDATAreadwrite; 翻译:2。在scripts目录中,可以找到prod_master.dat.gz和prod_master.ctl。使用prod_master.ctl文件中找到的信息,在SH架构中创建一个OracleLoader外部表,该表必须运行预处理器才能操作数据。 Cd/home/oracle/scripts cpprod_master.ctlprod_master.ctl.backup viprod_master.ctl 把preprocessor注释掉。(preprocessor'/home/oracle/scripts/uncompress.sh')也可以删掉 Catprod_master.ctl 先按照prod_master.ctl里的表结构创建sh.prod_master。然后等后面生成外部表的语法以后,再删除。 createtableprod_master(product_idnumber, product_namevarchar2(50), codevarchar2(20), reorder_thresholdnumber, costnumber(10,2), pricenumber(10,2), primary_sourcevarchar2(50), secondary_sourcevarchar2(50), obsoleteddate); chmoda+xuncompress.sh sqlldrsh/sh@prod1control=prod_master.ctlexternal_table=GENERATE_ONLYlog=prod_master.log viprod_master.log并找到createtable部分,把其中的表名改成prod_master,并添加preprocessor,最后执行下面的语句: prod_master.log改成和下面执行的语句即可 Droptablesh.prod_master;(先删除之前的再执行下面的sql语句) CREATETABLEsh.prod_master ( "PRODUCT_ID"NUMBER, "PRODUCT_NAME"VARCHAR2(50), "CODE"VARCHAR2(20), "REORDER_THRESHOLD"NUMBER, "COST"NUMBER(10,2), "PRICE"NUMBER(10,2), "PRIMARY_SOURCE"VARCHAR2(50), "SECONDARY_SOURCE"VARCHAR2(50), "OBSOLETED"DATE ORGANIZATIONexternal TYPEoracle_loader DEFAULTDIRECTORYscriptdir ACCESSPARAMETERS RECORDSDELIMITEDBYNEWLINECHARACTERSETUS7ASCII PREPROCESSORscriptdir:'uncompress.sh' BADFILE'SCRIPTDIR':'prod_master.dat.bad' LOGFILE'prod_master.log_xt' FIELDSTERMINATEDBY","LDRTRIM MISSINGFIELDVALUESARENULL REJECTROWSWITHALLNULLFIELDS "PRODUCT_ID"CHAR(255) TERMINATEDBY",", "PRODUCT_NAME"CHAR(50) "CODE"CHAR(20) "REORDER_THRESHOLD"CHAR(255) "COST"CHAR(255) "PRICE"CHAR(255) "PRIMARY_SOURCE"CHAR(50) "SECONDARY_SOURCE"CHAR(50) "OBSOLETED"CHAR(12) TERMINATEDBY"," DATE_FORMATDATEMASK'DD-MON-YYYY' location 'prod_master.dat.gz' )REJECTLIMITUNLIMITED; select*fromprod_master; Section5:ConfigureParallelExecution 1.ConfigureparallelexecutioninthePROD1database.Useaplantablethatpersistsacrosslogins.AstheSYSuser,implementthefollowing: i.ParallelexecutionistobedoneautomaticallybyOracleonlywhenstatementsexecuteformorethan5seconds. 翻译:第5节:配置并行执行 i.只有当语句执行超过5秒时,Oracle才会自动执行并行操作。 connsys/oracle@prod1assysdba altersystemsetparallel_min_time_threshold=5; ii.Ensurethatthemaximumdegreeofparallelismforastatementisdeterminedautomaticallywhilerunningthestatement. 翻译:ii.确保在运行语句时自动确定语句的最大并行度。 altersystemsetparallel_degree_policy=auto; iii.Allowupto100parallelexecutionslaveswith10%oftheslavesdefinedaspermanent. 翻译:iii.允许多达100个并行执行从机,其中10%的从机被定义为永久的。 altersystemsetparallel_max_servers=100; altersystemsetparallel_min_servers=10; iv.Ifastatementthatrequiresmorethan5secondscannotexecuteinparallel,itshouldnotexecuteatall. 翻译:iv.如果一个需要超过5秒的语句不能并行执行,那么它根本不应该执行。 altersystemsetparallel_servers_target=100;(这个答案是否正确请老师确认) v.SettheSH.SALEStabletohaveadefaultdegreeofparallelismof8.CheckaftereachremainingtasktoensurethatthisdegreeofparallelismsetfortheSH.SALEStableispersistenttilltheendofthisskillset. 翻译:v、将SH.SALES表的默认并行度设置为8。在完成每个剩余的任务后进行检查,以确保SH.SALES表的这种并行度集在该技能集结束之前是持久的。 altertablesh.salesparallel8; vi.Examinethe3_5_1_6.sqlscriptlocatedinthe/home/oracle/scriptsfolder.Executethescriptaftermakingnecessarychangestoensure: 1.TheexecutionplanfortheUPDATEstatementshowsparallelexecution 2.TheexecutionplanisstoredinSH.PLAN_TABLE 翻译:vi.检查位于/home/oracle/scripts文件夹中的3u5u1u6.sql脚本。在进行必要的更改后执行脚本,以确保: 1.UPDATE语句的执行计划显示并行执行 2。执行计划存储在SH.plan_表中 创建plan_table: @/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/utlxplan.sql @/rdbms/admin/utlxplan.sql altersessionenableparalleldml; @/home/oracle/scripts/3_5_1_6.sql Inthisskillset,youarerequiredtomodifyadatabasetoallowcreationoftablespaceswithdifferentblocksize.Youcreatepartitionedobjectsandconfigureyourenvironmenttosecuredata. 翻译:第四部分 在此技能集中,需要修改数据库以允许创建具有不同块大小的表空间。创建分区对象并配置环境以保护数据。 创建额外的缓冲缓存。 优化LOB数据的空间使用。 创建加密表空间。 管理模式数据。 创建分区表。 建立细粒度审计。 配置数据库以检索所有以前版本的表行。 Section1:CreateanAdditionalBufferCacheandTable 1.CreateanadditionalbuffercacheinSGAofthePROD1databaseforusewith16KBblocks.Ensurethatthe16KBbuffercacheisalwaysavailableinSGA. 翻译:第1节:创建额外的缓冲缓存和表 altersystemsetdb_16k_cache_size=10M; 2.CreateapartitionedtablecalledNEW_ORDERSunderSHschema ORDER_IDNUMBER(12)Primarykey, Total_AmountNumber(10) Ifthecolumnof Order_ID<1000storeinTablespaceUsers, and Order_ID<2000storeinTablespaceExample. 翻译:2。在SHschema下创建名为NEW_ORDERS的分区表 订单号(12)主键, 总金额(10) 如果 Order_ID<1000存储在表空间用户中, 以及 Order_ID<2000存储在表空间示例中。 createtableNEW_ORDERS( Total_AmountNumber(10)) partitionbyrange(order_id) partitionp1valueslessthan(1000)tablespaceusers, partitionp2valueslessthan(2000)tablespaceexample ); 3.AsHRuser,CreatetableMIXED_DATAwithcolumnDEPARTMENT_NAME VARCHAR2(10),Thendropit. CreatetableMIXED_DATAagain,withcolumnDEPARTMENT_ID 翻译:三。作为HR用户,使用列DEPARTMENT\uNAME创建表MIXED\uDATA VARCHAR2(10),然后删除它。 再次创建表MIXED_DATA,列DEPARTMENT_ID createtableMIXED_DATA(DEPARTMENT_NAMEVARCHAR2(20)); createtableMIXED_DATA(DEPARTMENT_NAMEVARCHAR2(10));(按照题意varchar2是10) droptableMIXED_DATA; createtableMIXED_DATA(DEPARTMENT_IDVARCHAR2(10)); Section2:OptimizeSpaceUsagefortheLOBDataandEncryptedTablespace 1.CreateatableinthePROD1databasetooptimizespaceusageformultiplerowsthatcanhavethesameLOBdataandalsocompresstheLOBdata. i.AstheOEuser,createtheCUSTOMER_PROFILEStableintheSF_DATAtablespacewiththefollowingcolumns: CUST_IDNUMBER, FIRSTZ_NAMEVARCHAR2(20), LAST_NAMEVARCHAR2(30), PROFILE_INFOBLOB ii.Createadirectorystructure/home/oracle/scripts/cust_files,andthencreateadirectoryobject,CUST_FILES,whichpointsto/home/oracle/scripts/cust_files. iii.Loaddataintothetablebyusingtheprocedureinthe4_2_2.sqlscriptlocatedinthe/home/oracle/scriptsdirectory. iv.EnablecompressionforthePROFILE_INFOcolumnandalsosavespacebyavoidingmultiplecopiesofthesameLOBdata. 翻译:一。在PROD1数据库中创建一个表,以优化具有相同LOB数据的多行的空间使用并压缩LOB数据。 i.作为OE用户,在sfu数据表空间中创建具有以下列的CUSTOMER_PROFILES表: 客户身份证号码, 名字VARCHAR2(20), 姓VARCHAR2(30), 配置文件信息块 ii。创建一个目录结构/home/oracle/scripts/cust_files,然后创建一个目录对象cust_files,它指向/home/oracle/scripts/cust_files。 iii.使用位于/home/oracle/scripts目录中的4u2.sql脚本中的过程将数据加载到表中。 iv.启用配置文件信息列的压缩,并通过避免同一LOB数据的多个副本来节省空间。 Connsys/orcacle@prod1assysdba altersystemsetdb_securefile=permitted; createtableoe.CUSTOMER_PROFILES( PROFILE_INFOBLOB) tablespacesf_data lob(PROFILE_INFO)storeassecurefile (tablespacesf_data deduplicate compress); mkdir-p/home/oracle/scripts/cust_files cp/home/oracle/scripts/cust1.txt/home/oracle/scripts/cust_files createdirectoryCUST_FILESas'/home/oracle/scripts/cust_files'; grantread,writeondirectoryCUST_FILEStopublic; @/home/oracle/scripts/4_2_2.sql execoe.loadLOBFromBFILE_proc; 2.Createanencryptedtablespace. i.LogintothePROD3databaseasSYS. [YoucanuseDatabaseCreationAssistant(DBCA)tocreatethePROD3databaseontheManagementServerifitisnotalreadycreatedinSkillset1]. Runthe4_2_22.sqlscript. Createanencryptedtablespacewiththefollowingspecifications: Tablespacename:ENCT_DATA Filesize:50MB 翻译:2。创建加密的表空间。 [如果PROD3数据库尚未在技能集1中创建,则可以使用数据库创建助手(DBCA)在管理服务器上创建该数据库]。 运行4_2_22.sql脚本。 使用以下规范创建加密表空间: 表空间名称:ENCT_DATA 文件大小:50MB sqlplus/nolog Sqlplussys/oracle@prod3assysdba @/home/oracle/scripts/4_2_22.sql ii.UsetheENCT_DATAtablespacetoimplementsecuritymeasurestoencryptthedataintheCUSTOMERSandPROMOTIONStablesintheSHschema. 翻译:ii.使用ENCT_数据表空间来实现安全措施,以加密SH模式中CUSTOMERS和PROMOTIONS表中的数据。 偶数机: Cd$ORACLE_HOME/network/admin visqlnet.ora WALLET_LOCATION= (SOURCE=(METHOD=file)(METHOD_DATA=(DIRECTORY=/home/oracle/files))) mkdir-p/home/oracle/files ALTERSYSTEMSETENCRYPTIONKEYIDENTIFIEDBY"oracle123"; createtablespaceENCT_DATA datafile'/u01/app/oracle/oradata/PROD3/ENCT_DATA01.dbf'size50M ENCRYPTION DEFAULTSTORAGE(ENCRYPT); altertablesh.customersmovetablespaceENCT_DATA; altertablesh.promotionsmovetablespaceENCT_DATA; Section3:ManageSchemaData 1.CreateanewtablespaceandanewtableintheHRschemainthePROD1databasewiththefollowingspecifications: i.TablespaceLOB_DATAwitha16KBchunksize,andinitialandnextextentseachwithasizeof2MB. Tablename:MAGAZINE_ARTICLES Tablespace:USERS Columnnames: AUTHORVARCHAR2(30) ARTICLE_NAMEVARCHAR2(50) ARTICLE_DATEDATE ARTICLE_DATACLOB Thedatainthistableisnotaccessedfrequently.Disablestorageinrow. 翻译:第3节:管理架构数据 1。使用以下规范在PROD1数据库的HR模式中创建新表空间和新表: i.表空间LOB_数据块大小为16kb,初始和下一个数据块大小均为2mb。 表空间:用户 列名: 作者VARCHAR2(30) 条款日期 第四条数据CLOB 此表中的数据不经常访问。禁用行中的存储。 exportORACLE_SID=PROD1 createtablespaceLOB_DATA datafile'/u01/app/oracle/oradata/PROD1/LOB_DATA01.dbf'size10M blocksize16K; createtablehr.MAGAZINE_ARTICLES( AUTHORVARCHAR2(30), ARTICLE_NAMEVARCHAR2(50), ARTICLE_DATEDATE, ARTICLE_DATACLOB) SEGMENTCREATIONIMMEDIATE tablespaceusers lob(ARTICLE_DATA)storeasartical_lob (tablespaceLOB_DATA chunk16384 disablestorageinrow nocache ii.UsedatapumpimporttopopulatetheHR.MAGAZINE_ARTICLEStablewithdatafromtheexp_mag.dmpfilelocatedinthe/home/oracle/scriptsfolder. 翻译:ii.使用datapumpimport用/home/oracle/scripts文件夹中的exp_mag.dmp文件中的数据填充HR.MAGAZINE_ARTICLES表。 impdphr/hr@prod1directory=scriptdirdumpfile=exp_mag.dmptables='MAGAZINE_ARTICLES'content=data_only Section4:CreatePartitionedTables 1.CreateapartitionedtablecalledNEW_ORDER_ITEMSinthePROD1databasebyusingtherange-parititionedNEW_ORDERStable.TheNEW_ORDER_ITEMSpartitionedtableshouldavoidstoringunnecessarycolumns.UsethePART_TBS1andPART_TBS2tablespaces,andtherange-partitionedNEW_ORDERStablethatexistsintheSHschemaofthePROD1database. i.UsethefollowingcolumnspecificationsforcreatingtheNEW_ORDER_ITEMStable: ORDER_IDNUMBER(12)NOTNULL PRODUCT_IDNUMBERNOTNULL QUANTITYNUMBERNOTNULL SALES_AMOUNTNUMBERNOTNULL 翻译:第4节:创建分区表 一。在PROD1数据库中使用范围划分的NEW_ORDERS表创建一个名为NEW_ORDER_ITEMS的分区表。NEW_ORDER_ITEMS分区表应避免存储不必要的列。使用PART_TBS1和PART_TBS2表空间,以及PROD1数据库的SH模式中存在的rangepartitionedNEW_ORDERS表。 i.使用以下列规范创建新的_ORDER_ITEMS表: 订单号(12)不为空 产品编号不为空 数量编号不为空 销售金额编号不为空 createtableNEW_ORDER_ITEMS (ORDER_IDNUMBER(12)NOTNULL, PRODUCT_IDNUMBERNOTNULL, QUANTITYNUMBERNOTNULL, SALES_AMOUNTNUMBERNOTNULL, CONSTRAINTfk_new_ordersFOREIGNKEY(order_id)REFERENCESnew_orders(order_id)) PARTITIONBYREFERENCE(fk_new_orders) partitionp1tablespacePART_TBS1, partitionp2tablespacePART_TBS2 ii.PopulatetheNEW_ORDERSandNEW_ORDER_ITEMStablesbyexecutingthe4_4_12.sqlscriptlocatedinthe/home/oracle/scriptsdirectory. 翻译:ii.通过执行位于/home/oracle/scripts目录中的4_4_12.sql脚本,填充新的_ORDERS和新的_ORDER_ITEMS表。 altertablenew_ordersaddc1varchar2(10); altertablenew_ordersaddc2varchar2(10); altertablenew_ordersmodifytotal_amountdate; @/home/oracle/scripts/4_4_12.sql 2.Createapartitionedtablethatautomaticallystoresrowsfornonexistentpartitions. i.LogintothePROD1databaseastheSHuserandcreateaSALES_HISTORY_2006table.Thetableshouldhavethefollowingcolumns: PROD_IDNUMBERNOTNULL CUST_IDNUMBERNOTNULL TIME_IDDATENOTNULL CHANNEL_IDNUMBERNOTNULL PROMO_IDNUMBERNOTNULL QUANTITY_SOLDNUMBER(10,2)NOTNULL AMOUNT_SOLDNUMBER(10,2)NOTNULL PartitionsshouldbebasedontheTIME_IDcolumn. Datafortheyears2001,2002,2003,and2004shouldbestoreinseparatepartitionshavingpartitionnamesSAL1,SAL2,SAL3,andSAL4,respectively,anddataafter2004isstoredinaseparatepartitionforeachmonth. Usethe4_4_22.sqlscriptinthe/home/oracle/scriptsdirectorytopopulatethetable. 翻译:2。创建一个分区表,自动存储不存在分区的行。 产品ID号不为空 客户ID号不为空 通道ID号不为空 促销ID号不为空 售出数量(10,2)不为空 分区应该基于TIME\uID列。 2001年、2002年、2003年和2004年的数据应分别存储在分区名为SAL1、SAL2、SAL3和SAL4的单独分区中,2004年之后的数据每月存储在单独分区中。 使用/home/oracle/scripts目录中的4_4_22.sql脚本填充表。 createtableSALES_HISTORY_2006( PROD_IDNUMBERNOTNULL, CUST_IDNUMBERNOTNULL, TIME_IDDATENOTNULL, CHANNEL_IDNUMBERNOTNULL, PROMO_IDNUMBERNOTNULL, QUANTITY_SOLDNUMBER(10,2)NOTNULL, AMOUNT_SOLDNUMBER(10,2)NOTNULL) partitionbyrange(time_id) interval(NUMTOYMINTERVAL(1,'month')) partitionsal1valueslessthan(to_date('01-01-2002','DD-MM-YYYY')), partitionsal2valueslessthan(to_date('01-01-2003','DD-MM-YYYY')), partitionsal3valueslessthan(to_date('01-01-2004','DD-MM-YYYY')), partitionsal4valueslessthan(to_date('01-01-2005','DD-MM-YYYY')) @/home/oracle/scripts/4_4_22.sql Section5:SetUpFine-GrainedAuditing 1.Setupfine-grainedauditing(FGA)ontheSALARYandCOMMISSION_PCTcolumnsoftheEMPLOYEEStableintheHRschemaofthePROD1database.AnauditrecordshouldbecreatedifeitherofthesecolumnsisselectedaspartoftheoutputofaqueryorisusedintheWHEREconditionofaSELECTstatementandtheirvaluesarenotnull. 2.ValidatethattheFGAistakingplacebyexecutingstatementsthatresultinauditingrecordsbeingcreatedandbyexecutingstatementswherenoauditingrecordswillbegenerated.Donotdeleteyourauditrecords. 翻译:第5节:建立细粒度审计 1.在PROD1数据库的HR模式中,对EMPLOYEES表的SALARY和COMMISSION\uPCT列设置细粒度审计(FGA)。如果这些列中的任何一列被选择作为查询输出的一部分,或者被用于SELECT语句的WHERE条件,并且它们的值不为空,则应创建审核记录。 2。通过执行导致创建审核记录的语句和执行不生成审核记录的语句来验证是否正在执行FGA。不要删除你的审计记录。 DBMS_FGA.ADD_POLICY( object_schema=>'HR', object_name=>'employees', policy_name=>'fga_policy_1', audit_column=>'salary,commission_pct', enable=>true, statement_types=>'select'); selectsalaryfromemployees; selectLSQLTEXTfromfga_log$; Section6:ConfiguretheDatabasetoRetrieveAllPreviousVersionsoftheTableRows 1.Performthefollowingtasks. i.CreateatablenamedORIGINAL_SALARYintheHRschemainthePROD1database.ORIGINAL_SALARYincludestheEMPLOYEE_ID,COMMISSION_PCT,andSALARYofallrecordsintheHR.EMPLOYEEStable. Notethedateandtime,andthencommitthechanges. 翻译:第6节:配置数据库以检索表行的所有早期版本 1.执行以下任务。 i.在PROD1数据库的人力资源模式中创建一个名为ORIGINAL_SALARY的表。原始薪资包括HR.EMPLOYES表中所有记录的员工ID、佣金PCT和薪资。 createtableORIGINAL_SALARYas selectemployee_id,commission_pct,salary fromemployees; selectto_char(sysdate,'yyyy-mm-ddhh24:mi:ss')fromdual; SQL>selectto_char(sysdate,'yyyy-mm-ddhh24:mi:ss')fromdual; TO_CHAR(SYSDATE,'YY ------------------- 2015-09-2123:04:47 ii.DeleteallemployeesintheHR.ORIGINAL_SALARYtablewhoseHIRE_DATEisbefore2002.Committhechanges.CreateaHR.SALARY_VIEWviewthatshowsalltheoriginalrowsbeforedeletion. 翻译:ii.删除HR.ORIGINALUSALARY表中所有雇佣日期在2002年之前的员工。提交更改。创建一个显示删除前所有原始行的人力资源薪资视图。 deleteORIGINAL_SALARYwhereemployee_idin (selectemployee_idfromemployeeswherehire_date commit; createorreplaceviewSALARY_VIEWas fromORIGINAL_SALARY asoftimestampto_timestamp('2015-09-2123:04:47','yyyy-mm-ddhh24:mi:ss'); iii.AtablenamedMIXED_DATA,ownedbyHR,isaccidentallydroppedbyaDBAloggingintothewrongdatabase.Theremaybemultiplecopiesofthetablethathasbeendropped.TheuserwantsyoutorecoverthetablethathasacolumnnamedDEPARTMENT_NAME.RestorethetableandnameitMD_RCV. SQL>showrecyclebin ORIGINALNAMERECYCLEBINNAMEOBJECTTYPEDROPTIME ----------------------------------------------------------------------------- MIXED_DATABIN$IEG0LNoFF+rgU1BcqMDQ1A==$0TABLE2015-09-21:21:17:31 MIXED_DATABIN$IEG0LNoGF+rgU1BcqMDQ1A==$0TABLE2015-09-21:21:17:31 SQL>desc"BIN$IEG0LNoFF+rgU1BcqMDQ1A==$0" NameNullType DEPARTMENT_NAMEVARCHAR2(20) SQL>desc"BIN$orKR3SOLH37gU1BIqMCzfA==$0" SQL>desc"BIN$IEG0LNoGF+rgU1BcqMDQ1A==$0" DEPARTMENT_IDVARCHAR2(10) SQL>desc"BIN$orKR3SOKH37gU1BIqMCzfA==$0" SQL>flashbacktable"BIN$IEG0LNoFF+rgU1BcqMDQ1A==$0"tobeforedroprenametoMD_RCV; SQL>flashbacktable"BIN$orKR3SOKH37gU1BIqMCzfA==$0"tobeforedroprenametoMD_RCV; Flashbackcomplete. 2.PerformthenecessaryconfigurationsinthePROD1databasesothatallpreviousversionsoftherowsforthepastoneyearintheSH.PROMOTIONStableareretrievable. i.Createandusethefollowingtablespaceandusertoperformthenecessaryconfigurations: TablespacenamedFRATBSwithadatafileof50MB UsernamedFR_ADMIN ii.PreviousversionsoftherowsintheSH.PROMOTIONStableshouldberetrievablefromanarchive,FRA1,andyoushouldbeabletoperformdatadefinitionlanguage(DDL)operationsonthebasetable,SH.PROMOTIONS.Runthe4_6_22.sqlscriptlocatedinthe/home/oracle/scriptsdirectory. 翻译:2。在PROD1数据库中执行必要的配置,以便可以检索SH.PROMOTIONS表中过去一年的所有以前版本的行。 i.创建并使用以下表空间和用户来执行必要的配置: 名为FRATBS的表空间,数据文件为50mb 名为FR_ADMIN的用户 Ii.应该可以从归档文件FRA1中检索SH.PROMOTIONS表中以前版本的行,并且应该能够对基表SH.PROMOTIONS执行数据定义语言(DDL)操作。运行位于/home/oracle/scripts目录中的4_6_22.sql脚本。 createuserfr_adminidentifiedbyoracle; grantdba,FLASHBACKARCHIVEADMINISTERtofr_admin; connectfr_admin/oracle@prod1 createtablespaceFRATBSdatafile'/u01/app/oracle/oradata/PROD1/FRATBS01.dbf'size50M; createflashbackarchiveFRA1tablespaceFRATBSquota50Mretention1year; altertableSH.PROMOTIONSflashbackarchiveFRA1; @/home/oracle/scripts/4_6_22.sql Inthisskillset,youwillconfiguretheResourceManagertolimitresourceusagebyusers.Useresultcache,tuneSQLstatements,configurefuturebaselines,andgatherstatistics.Userealapplicationtestingfeatures,suchasSQLReplayandWorkloadReplay. Attheendofthisskillset,yourdatabasesPROD1,andPROD2mustbeinOPENmodeandavailableforqueryingtoenableskillsetscoring.Nocreditwillbegivenfortheskillsetifthedatabasesarenotopenforaccess. 翻译:第五部分 在此技能集中,您将配置资源管理器以限制用户使用资源。使用结果缓存、优化SQL语句、配置将来的基线和收集统计信息。使用真实的应用程序测试功能,如SQL重放和工作负载重放。 创建同义词。 配置资源管理器。 调整SQL语句。 执行实际应用程序测试。 创建SQL计划基线。 捕捉性能统计数据。 调整实例。 在这个技能集的末尾,您的数据库PROD1和PROD2必须处于打开模式,并且可以查询以启用技能集评分。如果数据库未打开以供访问,则不会授予技能集任何学分。 第五场会对PROD2库进行大破坏除了pfile其他全部被删恢复方式就用第三场流程 Section1:CreateaSynonym 1.Createapublicsynonymnamedsalesforsh.sales@PROD1inthePROD2Database. 翻译:第1节:创建同义词 一。在PROD2数据库中为sh.sales@PROD1创建一个名为sales的公共同义词。 Sqlplussys/oracle@prod2assysdba connectsys/oracle@prod2assysdba createpublicsynonymsalesforsh.sales@prod_link; 2.InPROD1,createuserAPPS,password:Apps1234,ExporttheschemaofSHuser. ImportandremaptheschematoAPPS. 翻译:2。在PROD1中,创建用户应用程序,密码:Apps1234,导出SHuser的模式。 导入架构并将其重新映射到应用程序。 createuserappsidentifiedbyApps1234; grantdbatoapps; df-h先查看磁盘空间 如果磁盘空间不足先考虑删掉一些日志 Cd/home/oracle/files viexpsh.par schemas=SH dumpfile=shdata.dmp job_name=expjob expdpparfile=expsh.par viimpsh.par remap_schema=SH:APPS impdpparfile=impsh.par 3.InPROD1,createuserOLTP_USER,password:OLTP_USER1 CreateTableforOLTP_USER: Table1name:CLASSES, Columns: CLASS_IDNUMBER(10)PRIMARYKEY CLASS_NAMEVARCHAR2(20) Table2name:CLASSES2, CUST_LAST_NAMEVARCHAR2(10) 翻译:三。在PROD1中,创建用户OLTP_user,密码:OLTP_USER1 为OLTP_用户创建表: 表1名称:类, 列: 类别标识号(10)主键 课程名称VARCHAR2(20) 表2名称:CLASSES2, 客户姓氏VARCHAR2(10) createuserOLTP_USERidentifiedbyOLTP_USER1; grantdbatoOLTP_USER; connectOLTP_USER/OLTP_USER1@prod1 createtableoltp_user.CLASSES( CLASS_IDNUMBER(10)PRIMARYKEY, createtableoltp_user.CLASSES2( CUST_LAST_NAMEVARCHAR2(10)); 4.InPROD1,createanewtablespace,CUST_TBSwithmanualsegmentmanagementoption,andatable,SH.NEW_CUSTwiththecolumns:cust_idnumber,cust_namevarchar2(50),inthattablespace. CreateapartitionedtableSH.PRODUCT_INFORMATION_PART,withcolumns PRODUCT_IDNUMBER(10) PROD_NAMEVARCHAR2(10) Thetablewillbepartitionedbyrange,andusingPRODUCT_IDasthepartitionkey. WhenPRODUCT_ID<1000putthedataintopartitionPART1. WhenPRODUCT_ID<2000putthedataintopartitionPART2. 翻译:4.在PROD1中,创建一个新表空间,CUST_TBSwithmanualsegmentmanagement选项,以及一个表SH.new_CUSTwiththecolumns:CUST_idnumber,CUST_namevarchar2(50),在该表空间中。 创建带列的分区表SH.PRODUCT_INFORMATION_PART 产品识别号(10) 产品名称VARCHAR2(10) 将按范围对表进行分区,并使用产品ID作为分区键。 当产品ID<1000时,将数据放入分区PART1。 当产品ID<2000时,将数据放入分区PART2。 createtablespaceCUST_TBSdatafile'/u01/app/oracle/oradata/PROD1/CUST_TBS01.dbf'size10M extentmanagementlocalautoallocate segmentspacemanagementmanual; createtablesh.NEW_CUST(cust_idnumber,cust_namevarchar2(50))tablespaceCUST_TBS; createtableSH.PRODUCT_INFORMATION_PART( PRODUCT_IDNUMBER(10), PROD_NAMEVARCHAR2(10)) partitionbyrange(product_id) partitionpart1valueslessthan(1000), partitionpart2valueslessthan(2000) Section2:ConfiguretheResourceManager 先创建databasecontrol alteruserdbsnmpidentifiedbyoracleaccountunlock; emca-configdbcontroldb-reposrecreate 考试顺利的话第一场已经建立好em,这里无需再建立 1.SetupandconfiguretheResourceManageronthePROD1database. Followingarethespecifications: 1.AssigntheSHuserastheresourceadministrator. 翻译:第2节:配置资源管理器 1.在PROD1数据库上设置和配置资源管理器。 规范如下: 1.将SH用户指定为资源管理员。 grantADMINISTERRESOURCEMANAGERtosh; DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SYSTEM_PRIVILEGE( GRANTEE_NAME=>'SH', PRIVILEGE_NAME=>'ADMINISTER_RESOURCE_MANAGER', ADMIN_OPTION=>FALSE); 另外一种方法可以是用em图形化操作(图方便推荐第二种) 2.Createtworesourcemanagerconsumergroups:OLTPandDSS.(Usecommentstodenotewhateachgroupwillbeusedfor.) 翻译:2。创建两个资源管理器使用者组:OLTP和DSS。(使用注释来表示每个组的用途。) emctlstartdbconsole 打开第一场创建好的em 打开火狐浏览器 选择server-consumergroups 点击create新建 老师文档中少一个新建OLTP 看到这2个表示已经新建成功 3.CreateaplannamedDAYTIMEwiththefollowingdirectivesonly. i.FortheOLTPgroup,wecannotallowmorethan20activesessions.Ifthe21stuserattemptstologin,therequestshouldbeabortedifthewaitexceeds60seconds. 翻译.3.仅使用以下指令创建名为DAYTIME的计划。 计划名必须先填不然无法进行后面的操作 把之前新建的OLTP和DSS组加进来 翻译:ii.DSS组的最大活动会话数为5。如果请求的会话超过5个,则请求应在120秒后中止。 翻译:iv.OLTP组可以使用的最大撤消量应设置为200MB。 翻译:v、将OLTP、DSS和其他_组的CPU比率分别设置为50、30和20。 翻译:决策支持系统组的并行度限制为20。 翻译:vii.如果会话超过10000个I/O请求或传输的数据超过2500兆字节,则将DSS组中的任何会话临时切换到低组使用者组。该会话应在违规的顶部调用完成后返回到其原始组。 翻译:3.日间资源计划应为活动计划。 altersystemsetresource_manager_plan=daytime; 第二种: 都打钩 Section3:OptimizeSchemaObjects AnapplicationneedstoaccesstheCUST_LAST_NAMEcolumnintheCUSTOMERStableintheSHschemaofthePROD1database.Theproblemisthatuserscansupplynameswithoutregardtocase.Theapplicationchangesalltheuser-suppliednamestouppercase. 翻译:第3节:优化模式对象 应用程序需要访问PROD1数据库的SH模式中CUSTOMERS表中的CUST_LAST_NAME列。问题是用户可以不考虑大小写而提供名称。应用程序将所有用户提供的名称更改为大写。 createindexidx_customers_lastnameonCUSTOMERS(upper(CUST_LAST_NAME)); 2.TurnonmonitoringforalltheindexesontheCUSTOMERStableintheSHschemaofthePROD1database. 翻译:2。打开PROD1数据库的SH模式中CUSTOMERS表上所有索引的监视。 select'alterindex'||index_name||'monitoringusage;'fromuser_indexeswheretable_name='CUSTOMERS'; SQL>select'alterindex'||index_name||'monitoringusage;'fromuser_indexeswheretable_name='CUSTOMERS'; 'ALTERINDEX'||INDEX_NAME||'MONITORINGUSAGE;' ------------------------------------------------------------ alterindexIDX_CUSTOMERS_LASTNAMEmonitoringusage; alterindexCUSTOMERS_YOB_BIXmonitoringusage; alterindexCUSTOMERS_MARITAL_BIXmonitoringusage; alterindexCUSTOMERS_GENDER_BIXmonitoringusage; alterindexCUSTOMERS_PKmonitoringusage; 通过查看V$OBJECT_USAGE视图来获得索引是否被用上了。 Select*fromv$OBJECT_USAGE; 3.CreatetwonewtablesnamedSTUDENTSandATTENDEESintheOLTP_USERschemaofthePROD1database.TheschemapasswordisOLTP_USER1. i.TheSTUDENTStablewillcontainthreecolumns.STUD_IDwillbeanumberandtheprimarykey. ii.FNAMEandLNAMEwillbetheothertwocolumnsandmayvaryinlengthwithamaximumof20characters. iii.ATTENDEESwillbeanintersectiontableinamany-to-manyrelationshipbetweentheSTUDENTSandCLASSEStables,whichisalsointheOLTP_USERschema. iv.TheATTENDEEStablewillcontaintheprimarykeysofeachoftheothertablesasitsprimarykey. CreatetheATTENDEEStablesothattheprimarykeyindexandthetableitselfarethesameobject. 翻译3.在PROD1数据库的OLTP_用户模式中创建两个名为STUDENTS和ATTENDEES的新表。架构密码是OLTP_USER1。 I.学生表将包含三列。STUD_ID将是一个数字和主键。 Ii.FNAME和LNAME是另外两列,长度可能不同,最多20个字符。 iii.与会者将是学生和类表之间多对多关系中的交叉表,该交叉表也在OLTP_用户模式中。 iv.与会者表将包含其他每个表的主键作为其主键。 创建与会者表,使主键索引和表本身是同一对象。 connectoltp_user/OLTP_USER1@prod1 createtableSTUDENTS(STUD_IDnumberprimarykey,FNAMEvarchar2(20),LNAMEvarchar2(20)); createtableATTENDEES(stud_idnumber,class_idnumber,constraintpk_attendeesprimarykey(stud_id,class_id)) organizationindex; 4.BecauseoftheunevenlydistributeddataintheDEPARTMENT_IDcolumnoftheEMPLOYEEStableoftheHRschemaofthePROD1database,youneedtosupplymoreinformationtotheoptimizertoallowformoreefficientuseofindexes. i.RegeneratestatisticsontheEMPLOYEEStabletosolvethisproblem. 5.AnalysishasrevealedthattheCOUNTRY_IDcolumnoftheCUSTOMERStableoftheSHschemaofthePROD1databasehasverylowcardinality. i.Thiscolumnisneverupdated. Createanindexthatcantakeadvantageoftheseattributesofthiscolumn. 翻译:4.由于PROD1数据库的HRschema的EMPLOYEES表的DEPARTMENT_ID列中的数据分布不均匀,您需要向优化器提供更多信息,以便更有效地使用索引。 i.重新生成EMPLOYEES表上的统计信息以解决此问题。 execdbms_stats.gather_table_stats('HR','EMPLOYEES',method_opt=>'forcolumnsDEPARTMENT_IDsize254'); 5个。分析表明,PROD1数据库的SHschema的CUSTOMERS表的COUNTRY-ID列具有很低的基数。 本专栏从未更新。 创建可以利用此列的这些属性的索引。 createbitmapindexidx_cust_countryidonCUSTOMERS(COUNTRY_ID); 6.CreateanindexontheCOUNTRY_IDandCUST_CITYcolumnsintheCUSTOMERStableoftheSHschemaofthePROD1database. i.TheapplicationrequiresthattheleadingcolumnofthisindexmustbetheCOUNTRY_IDcolumn. ii.TakeadvantageoftheOraclefeatureofindexesthatallowsthecreationoftheindextouselessspacewhentheleadingcolumnisoftenduplicated. 翻译:6。在PROD1数据库的SH模式的CUSTOMERS表中的COUNTRY_ID和CUST_CITY列上创建索引。 i.应用程序要求此索引的前导列必须是COUNTRY\uID列。 二。利用索引的Oracle特性,当前导列经常重复时,可以使用较少的空间创建索引。 createindexidx_cust_cconCUSTOMERS(COUNTRY_ID,CUST_CITY)compress1; 7.MakesurethatthepackagenamedSTANDARDinthePROD1databaseisavailableinmemorypersistentlyacrossallstartups. 翻译:7.确保PROD1数据库中名为STANDARD的包在所有启动的内存中持久可用。 execdbms_shared_pool.keep('sys.STANDARD'); 8.AnalysisofthePROD1databaserevealsthatathird-partyapplicationisnotusingbindvariablesandhasskeweddata.Inaddition,youfindsharedpoollatchcontention.Findthebestsolutiontoreducesharedpoolusage. 翻译:8.对PROD1数据库的分析表明,第三方应用程序没有使用bind变量,并且数据倾斜。此外,您还发现共享池锁存争用。找到减少共享池使用率的最佳解决方案。 altersystemsetcursor_sharing=force; 9.YourjuniorDBAhascreatedanewtablespace,CUST_TBS,andplacedatable,NEW_CUST,inthattablespace. i.Observationshowsthattheinstancerecordssignificantnumbersofbufferbusywaitsontheheaderblock. ii.TheV$WAITSTATviewhasaccumulatedlargenumbersofwaitsinthesegmentheadercategory. iii.TheNEW_CUSTtablehaslargenumbersofconcurrentinsertsduringbusinesshours. Takeappropriateactionstoreducethecontention.Long-termqueryperformanceshouldbemaintained.Note:thesolutionmustworkwhetherNEW_CUSTtableisinasmallfileorabigfiletablespace. 翻译:9.您的初级DBA创建了一个新表空间CUST_TBS,并在该表空间中放置了一个表new_CUST。 I.观察表明,实例在头块上记录了大量的缓冲区忙等待。 Ii.V$WAITSTAT视图在段头类别中累积了大量等待。 采取适当的措施减少争用。应保持长期查询性能。注意:无论新的CUST表在smallfile还是bigfile表空间中,解决方案都必须有效。 altertablesh.NEW_CUSTmovetablespaceusers; droptablespaceCUST_TBSincludingcontentsanddatafiles; altertablesh.NEW_CUSTmovetablespaceCUST_TBS; 10.LoginastheSHuserandgatherstatisticsfortheSALEStable. Ensurethatthecursorspertainingtotheobjectinthecacheareneverinvalidated. execdbms_stats.gather_table_stats('SH','SALES',no_invalidate=>true); 11.ThereareperformanceproblemsduringinsertsintothePRODUCT_INFORMATION_PARTtableintheSHschemainthePROD1database. i.AsequenceisusedtogeneratethevaluesforthePRODUCT_IDcolumninthistable. ii.RangescansarealsofrequentlyperformedonthePRODUCT_IDcolumn. Createanindex,PROD_IDXonthePRODUCT_IDcolumn,whichavoidsproblemsduringinsertscausedbyhotblocks. 翻译:11.在PROD1数据库的SH模式的PRODUCT_INFORMATION_PART表中插入时,存在性能问题。 i.序列用于生成此表中产品ID列的值。 Ii范围扫描也经常在产品ID列上执行。 在产品ID列上创建一个索引PROD_IDX,这样可以避免由热块引起的插入问题。 createindexPROD_IDXonsh.PRODUCT_INFORMATION_PART(PRODUCT_ID) globalpartitionbyhash(product_id) partitions4; Section4:TuneSQLStatements 1.InthePROD1database,loginasHRuserandrunthe5_4_1.sqlscriptlocatedinthe/home/oracle/scriptsdirectory.Tunethequeriestousethesamequeryresultfromtheresultcache.Settheresultcachesizeto15MB. 翻译:第4节:调整SQL语句 altersystemsetresult_cache_max_size=15M; altertablecustomersresult_cache(modeforce); setautotracetraceonly selectcust_city,count(*)fromcustomersgroupbycust_city;(5_4_1.sql的脚本就是这个) 确保consistentgets为0 检查: selectname,statusfromv$result_cache_objects; 2.LoginastheSHuserandrunthe5_4_2.sqlscriptlocatedin/home/oracle/scripts. Inthequery,theCUST_CITY,CUST_STATE_PROVINCE,andCOUNTRY_IDcolumnsareusedtogetherasthepredicates. TunethestatementtoimprovetheselectivitycalculatedbytheoptimizerfortheSQLstatementinthe5_4_2.sqlscript. 在查询中,CUST_CITY、CUST_STATE_PROVINCE和COUNTRY_ID列一起用作谓词。 调整语句以提高优化器为5_4_2.SQL脚本中的SQL语句计算的选择性。 新增题目内容 ThesampleSQLisasfollows: SELECTcount(*)FROMcustomersWHEREcust_city='BJ'andcust_state_province='CA'andcountry_id=52790; selectdbms_stats.create_extended_stats('SH','customers','(CUST_CITY,CUST_STATE_PROVINCE,COUNTRY_ID)')fromdual; dbms_stats.gather_table_stats('SH','CUSTOMERS'); execdbms_stats.gather_table_stats('SH','CUSTOMERS',method_opt=>'forcolumns(cust_city,cust_state_province,country_id)size254'); createindexsh.index_cust_countryonsh.customers(cust_city,cust_state_province,country_id);(2种应该都可以) 3.YourcompanyismigratingfromOracleDatabase10g(10.2.0.1)toOracleDatabase11g. i.Testtheperformanceofthequeriesinthenewenvironment. Theappsstg.dmpfilecontainsthesetofSQLstatements. ThepasswordfortheAPPSschemaisApps1234. ii.ImporttheSTS_PSSQLtuningsetstagedintheSTS_PS_TABtable. UsetheappropriatetooltoimprovetheperformanceofthestatementsintheSTS_PSSQLtuningset.StoretheimprovedplaninthepersistentplantablenamedPLAN_TABLEintheAPPSschema. 翻译:3.您的公司正在从OracleDatabase10g(10.2.0.1)迁移到OracleDatabase11g。 I.测试新环境中查询的性能。 dmp文件包含一组SQL语句。 APPS架构的密码是Apps1234。 Ii.导入STS_PS_选项卡表中暂存的STS_PSSQL优化集。 使用适当的工具改进STS_PSSQL优化集中语句的性能。将改进后的计划存储在APPS架构中名为plan_table的持久计划表中。 impdpapps/Apps1234@prod1dumpfile=appsstg.dmpdirectory=scriptdir connapps/Apps1234 execDBMS_SQLTUNE.UNPACK_STGTAB_SQLSET('STS_PS','SYS',TRUE,'STS_PS_TAB','APPS'); 这个图标都是点击进去可选择的不需要自己手输 最后的截图 创建正常的persistent的plan_table: Connapps/Apps1234 PLAN_TABLE已经存在这个脚本跑不了(请老师看下) selecttable_namefromuser_tableswheretable_name='PLAN_TABLE'; 把这里建议的索引创建好。 针对上面显示的6条sql,用explanplan把它们的执行计划放入plan_table里。 explainplanfor select/*STS_PS*/s.prod_id,prod_name,sum(amount_sold) fromproductsp,saless wherep.prod_id=s.prod_idandpromo_idin (selectpromo_id frompromotions wherepromo_begin_date='27-JAN-99'andpromo_end_date='27-may-99')groupbys.prod_id,prod_name; select/*STS_PS*/PROD_ID,sum(QUANTITY_SOLD),sum(AMOUNT_SOLD) fromsales wherecust_idin (selectcust_id fromcustomers wherecust_city='SanFrancisco')groupbyprod_id,QUANTITY_SOLD,AMOUNT_SOLD; select/*STS_PS*/s.prod_id,prod_name,sum(quantity_sold)total fromsaless,customersc,productsp wheres.cust_id=c.cust_idandp.prod_id=s.prod_idandcust_city='SanFrancisco'groupbys.prod_id,prod_name; select/*STS_PS*/rownum,cust_id,prod_id,prod_name,total from( Selects.cust_idcust_id,p.prod_idProd_id,prod_name,sum(amount_sold)total fromproductsp,saless,customersc wherep.prod_id=s.prod_idands.cust_id=c.cust_idgroupbys.cust_id,p.prod_id,prod_nameorderby4desc) whererownum<=5; select/*STS_PS*/rownum,prod_id,prod_name,total from (selectp.prod_idProd_id,prod_name,sum(QUANTITY_SOLD)total wherep.prod_id=s.prod_idgroupbyp.prod_id,prod_nameorderby3desc) select/*STS_PS*/prod_id,sum(QUANTITY_SOLD),sum(AMOUNT_SOLD) wherechannel_id=4groupbyprod_id,QUANTITY_SOLD,AMOUNT_SOLD; 优化的部分在em中 Availability-AdvisorCentral-SQLPerformanceAnalyzer 依次点开 explanplanfor 4.CreatetheSQLplanbaselinesasperthefollowingspecifications: LogintothePROD1databaseastheSHuserandrunthe5_4_41.sqlscriptlocatedinthe/home/oracle/scriptsdirectory.CreatetheSQLplanbaselinesfortheSQLstatement. 翻译:4.按照以下规范创建SQL计划基线: Connsh/sh@Prod1 altersessionsetoptimizer_capture_sql_plan_baselines=true;@/home/oracle/scripts/5_4_41.sql @/home/oracle/scripts/5_4_41.sql showparameteroptimizer_capture_sql_plan_baselines应该是true selectsql_textfromdba_sql_plan_baselines;进行验证,结果集里应该有5_4_41.sql脚本里的sql文本 Section5:TuneanInstance 1.ThePROD1andPROD2databasesarerunningonaserverwith2CPUs. PreventPROD1instancefrominterferingwiththePROD2instance. 翻译:第5节:调整实例 1.PROD1和PROD2数据库运行在具有两个cpu的服务器上。 防止PROD1实例干扰PROD2实例。 altersystemsetcpu_count=1scope=spfile; startupforce SQL>selectINSTANCE_CAGINGfromv$rsrc_plan; INS --- OFF SQL>altersystemsetresource_manager_plan='daytime'; Systemaltered. ON !!!这里一定要注意,重启以后,前面做过的result_cache的内容会被清空,所以需要重新做一遍section4.1里部分,也就是下面这三条命令: selectcust_city,count(*)fromcustomersgroupbycust_city; emca-deconfigdbcontroldb-reposdrop ENDState:TheproctorapplicationwillconnecttoyourdatabaseinstancesasusersSYSandSYSTEMwiththepasswordoracle.Youcanusethefollowingcheckstoverifyyourdatabasesareinthecorrectendstatebeforethescoringprocessstarts: LogontothePROD1databasebyusing: sys/oracle@prod1assysdba system/oracle@prod1 QuerytheDUALtable. LogontothePROD2databasebyusing: sys/oracle@prod2assysdba system/oracle@prod2 Inthisskillset,youarerequiredtoconfigure,anduseOracleEnterpriseManager11gGridControl.AfterconfiguringGridControl,youarerequiredtoperformaseriesoftasksusingtheGridControlenvironment. Attheendofthisskillset,yourdatabasesPROD1,andEMREPmustbeinOPENmodeandaccessible.Nocreditwillbegivenfortheskillsetifthedatabasesarenotopenforaccess. 翻译:第六部分 在此技能集中,需要配置和使用OracleEnterpriseManager11g网格控件。配置网格控件后,需要使用网格控件环境执行一系列任务。 配置EM电网控制。 使用网格控件管理数据库。 创建用户、作业和表空间。 在本技能集的末尾,数据库PROD1和EMREP必须处于打开模式且可访问。如果数据库未打开以供访问,则不会授予技能集任何学分。 密码 文档 1.要访问Oracle数据库文档,请双击数据库服务器桌面上的FirefoxWeb浏览器图标。输入以下URL:file:///stage/doc/db/English/index.htm 1.数据文件大小不应超过2GB。 4.所有名称和密码均区分大小写。 5.在proctor开始评分之前,在技能集的末尾,确保数据库服务器(即oddPC)上的/(即根)文件系统至少有15%的可用空间。在命令提示符下使用命令df-h检查可用空间。 1.WhenyouentertheURLforGridControl,thebrowserdisplaysthe"SecureConnectionFailed"warning. Click"Oryoucanaddanexception". Anadditionalmessageisdisplayed.Click"AddException". Apop-upwindowopens.Click"GetCertificate". Then,click"ConfirmSecurityException". 翻译:安全证书无效 1。输入网格控件的URL时,浏览器将显示“安全连接失败”警告。 单击“或者可以添加异常”。 将显示一条附加消息。单击“添加异常”。 弹出窗口打开。点击“获取证书”。 然后,单击“确认安全异常”。 正式考试环境中,OMS和OMR都已经启动起来了,你不需要做任何操作。 而在测试环境中,你需要自己启动OMS,其顺序为: LISTENER= 然后lsnrctlstart启动监听器 也就是在lsnrctlstatus里能够看到EMREP这个service。 3、启动oms:/u02/app/oracle/Middleware/oms11g/bin/emctlstartoms Section1:EnableGridControltoManageTargetDatabaseMachine 1.DeployOracleManagementAgentonyourDatabaseServer.AgentregistrationpasswordisOracle123. 翻译:第1节:启用网格控件管理目标数据库计算机 1.在数据库服务器上部署Oracle管理代理。代理注册密码是Oracle123。 exportOMS_HOME=/u02/app/oracle/Middleware/oms11g cd$OMS_HOME/sysman/agent_download/11.1.0.1.0/linux scpagentDownload.linuxodd:/home/oracle oracle@odd’spassword:oracle 第二种方式直接在浏览器 下载agentDownload.linux下载好后桌面移动到/home/oracle下 cd/home/oracle chmoda+xagentDownload.linux ./agentDownload.linux-b/u01/app/oracle/product/11.2.0-y 密码是Oracle123 以root执行:/u01/app/oracle/product/11.2.0/agent11g/root.sh 因为root用户被锁所以只能使用sudosudo/u01/app/oracle/product/11.2.0/agent11g/root.sh sudoFirefox 账号密码sysmanOracle123 Monitorpassword是oracle 翻译:2.创建一个名为EMADMIN的网格控件超级用户,密码为EMADMIN(区分大小写)。 Section2:UseGridControl 翻译:1.使用网格控件,将PROD1服务器上的PGA_AGGREGATE_TARGET更改为200MB,以便在实例重新启动时恢复。 也可以直接连到PRID1里执行sql命令:altersystemsetpga_aggregate_target=200M; 账号密码:sysoracle选SYSDBA 也可以直接连到PRID1里执行sql命令:altersystemsetfast_start_mttr_target=300; 翻译:3.使用Grid控件,在PROD1数据库的系统表空间上配置一个警报。警报应在87%满时注册为警告,在95%满时注册为严重警告。 翻译:4.使用网格控件,设置要发送到电子邮件地址dba@ocm.com的通知。通知消息应随时发送到此地址。 点击create创建通知规则name韩老师的意思是随便取一个 5.UsingGridControl,createanewtablespaceinthePROD1databasecalledREGISTRATION(casesensitive). Createwithone90MBdatafile. Makesurethatthisdatafilecangrowto120MB. Configurethetablespaceforoptimalblockspaceutilization. 翻译:5.使用Grid控件,在PROD1数据库中创建一个名为REGISTRATION(区分大小写)的新表空间。 创建一个90MB的数据文件。 请确保此数据文件可以增长到120MB。 配置表空间以获得最佳块空间利用率。 createtablespaceREGISTRATION datafile'/u01/app/oracle/oradata/PROD1/REGISTRATION01.dbf'size90Mmaxsize120M Section3:ImplementSchedulesandJobs (Note:Allnamesarecasesensitive.) 1.UsingGridControl,createascheduleforthePROD1database. CallthisscheduleDAILY_REBUILD. Configureittorunat2PMeveryday. 翻译:第3节:实施计划和作业 (注意:所有名称都区分大小写。) 一。使用网格控件,为PROD1数据库创建计划。 每天调用此计划重新生成。 将其配置为每天下午2点运行。 翻译:3.使用网格控件,为PROD1数据库创建一个名为EMP_IND_REBUILD的程序,该程序重建HR.EMPLOYEES表上的所有索引。 cursorcur_all_indexesis selectowner,index_namefromdba_indexes wheretable_name='EMPLOYEES'andowner='HR'; forred_indincur_all_indexesloop executeimmediate'alterindex'||red_ind.owner||'.'||red_ind.index_name||'rebuild'; endloop; exceptionwhenothersthen null; 翻译:4.使用网格控件,创建一个名为USR_WINDOW1的窗口,该窗口使用每日重建计划和默认的_计划资源管理器计划。 翻译:5.使用网格控件,创建一个名为REBUILD_job的作业,该作业使用每日重建计划和EMP_IND_REBUILD程序。 Inthisskillset,youarerequiredtoconfigureanduseastandbydatabase. ThePROD1databaseshouldbeopen.TheSBDB1databaseshouldbeopenandavailableforqueryingwithallrecentchangesavailablefromPROD1.Nocreditwillbegivenfortheskillsetifthedatabasesarenotopenforaccess. 翻译:第7部分 在此技能集中,需要配置和使用备用数据库。 创建物理备用数据库。 使备用数据库可用于测试。 恢复备用数据库的正常功能。 配置快速启动故障转移。 PROD1数据库应该打开。SBDB1数据库应该是打开的,并且可以使用PROD1提供的所有最新更改进行查询。如果数据库没有打开以供访问,则不会为技能集提供任何积分。 2.TRPDATA、INDX、TOOLS、TEST和OLTP表空间已从PROD1数据库中删除。如果这些表空间仍然存在,请在继续使用此技能集之前手动删除它们。 droptablespaceTRPDATAincludingcontentsanddatafiles; droptablespaceINDXincludingcontentsanddatafiles; droptablespaceTOOLSincludingcontentsanddatafiles; droptablespaceTESTincludingcontentsanddatafiles; droptablespaceOLTPincludingcontentsanddatafiles; 如果有SHARED_DATA表空间先删掉 DroptablespaceSHARED_DATAincludingcontentsanddatafiles; 翻译:3.确保从Oracle重新启动中取消配置侦听器。 在管理机上: srvctlstoplistener srvctlremovelistener 这个是rac中关闭监听命令写的有问题。 5.使用从管理服务器上的数据库宿主运行的侦听器。 6.在proctor开始评分之前,在技能集的末尾,确保数据库服务器(即oddPC)上/(即根)文件系统至少有15%的可用空间。在命令提示符下使用命令df-h检查可用空间。 Section1:CreatingaPhysicalStandbyDatabase Usethefollowingspecificationstocreatethephysicalstandbydatabase: 1.TheORACLE_SIDshouldbeSBDB1(case-sensitive)forthestandbydatabasetobecreatedontheManagementServer. 2.TheentireproductiondatabasePROD1shouldbeincludedinthephysicalstandbydatabase. 3.Specifythenewdirectorylocationas/u01/app/oracle/oradata/SBDB1forthedatafilesandonlineredologfilesofthestandbydatabase. 4.AllowremoteconnectionstotheSBDB1database. Example:CONNECTsys/oracle@SBDB1assysdbashouldconnecttotheSBDB1databaseusingadedicatedserverconnection. 第1节:创建物理备用数据库 使用以下规范创建物理备用数据库: 一。要在管理服务器上创建备用数据库,ORACLESID应为SBDB1(区分大小写)。 2。整个生产数据库PROD1应该包含在物理备用数据库中。 三。将备用数据库的数据文件和联机重做日志文件的新目录位置指定为/u01/app/oracle/oradata/SBDB1。 四。允许远程连接到SBDB1数据库。 示例:连接sys/oracle@SBDB1,因为sysdba应该使用专用服务器连接连接到SBDB1数据库。 在管理机上: 建立auditdump和数据文件目录: mkdir-p/u01/app/oracle/oradata/SBDB1 mkdir-p/u01/app/oracle/admin/SBDB1/adump 建立与PROD1相同的FRA路径: mkdir-p/home/oracle/flash 奇数机: 在PROD1里创建standbylogfile: 这里需要先确认PROD1里的onlinelog的大小,假设是50M。 alterdatabaseaddstandbylogfilegroup11('/u01/app/oracle/oradata/PROD1/std01.log')size50M; alterdatabaseaddstandbylogfilegroup12('/u01/app/oracle/oradata/PROD1/std02.log')size50M; alterdatabaseaddstandbylogfilegroup13('/u01/app/oracle/oradata/PROD1/std03.log')size50M; alterdatabaseaddstandbylogfilegroup14('/u01/app/oracle/oradata/PROD1/std04.log')size50M; 为SBDB1创建密码文件: orapwdfile=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwSBDB1force=ypassword=oracleignorecase=n 准备一个初始化参数: viinitSBDB1.ora db_name=PROD1 db_unique_name=SBDB1 control_files='/u01/app/oracle/oradata/SBDB1/control01.ctl' db_file_name_convert='/u01/app/oracle/oradata/PROD1','/u01/app/oracle/oradata/SBDB1' log_file_name_convert='/u01/app/oracle/oradata/PROD1','/u01/app/oracle/oradata/SBDB1' sga_target=512M db_domain=us.oracle.com standby_file_management=auto 在数据库机上配置到备库的连接字符串: SBDB1= (SERVICE_NAME=SBDB1.us.oracle.com) cd$ORACLE_HOME/bin Netmgr 在管理机上配置连接字符串: cattnsnames.ora exportDISPLAY=192.168.72.1:0.0 在主库上PROD1上强制日志和做日志切换: alterdatabaseforcelogging; altersystemarchivelogcurrent; 在数据库机上配置监听器,添加用于broker的静态注册: SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=PROD1.us.oracle.com) (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1) (SID_NAME=PROD1) (GLOBAL_DBNAME=PROD1_DGMGRL.us.oracle.com) (GLOBAL_DBNAME=PROD1_DGB.us.oracle.com) 在偶数机(管理服务器)上配置监听器,添加用于broker的静态注册: (GLOBAL_DBNAME=SBDB1.us.oracle.com) (SID_NAME=SBDB1) (GLOBAL_DBNAME=SBDB1_DGMGRL.us.oracle.com) (GLOBAL_DBNAME=SBDB1_DGB.us.oracle.com) SBDB1:/u01/app/oracle/product/11.2.0/dbhome_1:Y 启动duplicate操作: exportORACLE_SID=SBDB1 如果连不上重启监听 rmantargetsys/oracle@prod1auxiliarysys/oracle@sbdb1 检测必须是notmounted状态 DUPLICATETARGETDATABASEFORSTANDBYfromactivedatabase; Exit SBDB1 创建spfile 备库里设置flashrecoveryarea: 在主库和备库上执行: PROD1和SBDB1: altersystemsetdg_broker_start=true; 使用broker把DG搭建起来: connectsys/oracle@prod1 dgmgrlsys/oracle@prod1 CREATECONFIGURATIONdg1asPRIMARYDATABASEISPROD1CONNECTIDENTIFIERIS'PROD1'; ADDDATABASESBDB1asCONNECTIDENTIFIERIS'SBDB1'MAINTAINEDASPHYSICAL; enableconfiguration; showconfiguration; showdatabaseverboseprod1; 检查属性:StaticConnectIdentifier,如果不是1521端口,比如: StaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=odd.oracle.com)(PORT=1621))(CONNECT_DATA=(SERVICE_NAME=PROD1_DGMGRL.us.oracle.com)(INSTANCE_NAME=PROD1)(SERVER=DEDICATED)))' 则改为: editdatabasePROD1setpropertyStaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=odd.oracle.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=PROD1_DGMGRL.us.oracle.com)(INSTANCE_NAME=PROD1)(SERVER=DEDICATED)))'; 则数据库会自动被broker启动。 Section2:TesttheStandbyDatabase Performthefollowingtasks: 1.ConfigurethestandbydatabaseSBDB1tobeusedfortesting,includingupdates,andmakenochangestotheprimarydatabase. 2.Runthe7_2_2.sqlscripttoperformupdatesontheSBDB1database. 第2节:测试备用数据库 执行以下任务: 一。将备用数据库SBDB1配置为用于测试(包括更新),并且不对主数据库进行任何更改。 2。运行7_2_2.sql脚本对SBDB1数据库执行更新。 Dgmgrlsys/oracle@SBDB1 CONVERTDATABASESBDB1toSNAPSHOTSTANDBY; @/home/oracle/scripts/7_2_2.sql Section3:RestoretheStandbyDatabase Restorethestandbydatabasetoitsnormalfunctionfordisasterrecovery. 第3节:恢复备用数据库 将备用数据库恢复到正常的灾难恢复功能。 dgmgrlsys/oracle@sbdb1 CONVERTDATABASESBDB1tophysicalstandby; 如果中间遇到任何错误,可以先disableconfiguration;在enableconfiguration;然后再执行:CONVERTDATABASESBDB1tophysicalstandby; Sqlplussys/oracle@sbdb1assysdba alterdatabaseopenreadonly; Dgmgrlsys/oracle@sdbdb1 DGMGRL>showdatabasesbdb1; Database-sbdb1 Role:PHYSICALSTANDBY IntendedState:APPLY-ON<==注意这里是ON TransportLag:0seconds ApplyLag:0seconds RealTimeQuery:ON Instance(s): DatabaseStatus: SUCCESS 2.Configuremanagedrecoverysothatthechangestotheprimarydatabasearereflectedinthestandbyassoonaspossible. 因为在部署之初就已经在主库上创建了standbylog,所以缺省使用broker配置DG的时候就是实时应用的。 3.Reducetheoverheadsoffastincrementalbackupstoaminimumontheprimarydatabase. 2.配置托管恢复,以便对主数据库的更改尽快反映在备用数据库中。 3.将主数据库上快速增量备份的开销降至最低。 在备库上启动changetrackingfile Sbdb1 ALTERDATABASEENABLEBLOCKCHANGETRACKINGUSINGFILE'/u01/app/oracle/oradata/SBDB1/change_tracking.file'; 4.Archivelogsmustnotbedeletedontheprimarydatabaseuntiltheyhavebeenappliedtothestandbydatabase. 在主库上执行RMAN命令: CONFIGUREARCHIVELOGDELETIONPOLICYTOappliedonallstandby; Section4:ConfiguretheStandbyDatabase 第4节:配置备用数据库 一。创建SBDB1SRV数据库服务并为其分配物理备用的数据保护角色。只有当管理服务器上EMREP数据库的角色更改为物理备用时,此服务才应自动启动。 cd/u01/app/11.2.0/grid/bin ./crsctlstarthas srvctladdservice-dEMREP-sSBDB1SRV-lPHYSICAL_STANDBY-yAUTOMATIC 2.Configureconnecttimefailoverforthedataguardconfiguration. ConfigurethePRODSRVlocalnetserviceonthedatabaseservermachinetoconnecttothestandbydatabaseincaseofswitchover. 在数据库服务器机器上配置PRODSRV本地的网络服务,以便在切换时连接到备用数据库。 execDBMS_SERVICE.CREATE_SERVICE(SERVICE_NAME=>'PRODSRV',NETWORK_NAME=>'PRODSRV.us.oracle.com'); execDBMS_SERVICE.start_SERVICE(SERVICE_NAME=>'PRODSRV'); 在数据库机和管理机上编辑tnsnames.ora PRODSRV= (SERVICE_NAME=PRODSRV.us.oracle.com) 在主库上创建触发器: PROD1: CREATETRIGGERMANAGE_SERVICESAFTERSTARTUPONDATABASE ROLEVARCHAR2(30); SELECTDATABASE_ROLEINTOROLEFROMV$DATABASE; IFROLE='PRIMARY'THEN DBMS_SERVICE.START_SERVICE('PRODSRV'); ENDIF; Section5:AutomateFailover 1.AutomatefailoverandusetheDatabaseServerforanycomponentsthatprovidetheautomation.Makesurethattheconfigurationissynchronizedandfullyoperational. 第5节:自动故障转移 一。自动化故障转移,并将数据库服务器用于提供自动化的任何组件。确保配置已同步且完全可操作。 有人建议自动故障转移放弃 在主库启动flashbackdatabase: PROD1: (会提示ERRORatline1: ORA-38706:CannotturnonFLASHBACKDATABASElogging. ORA-38713:FlashbackDatabaseloggingisalreadyturnedon. 第1行出错: ORA-38706:无法打开闪回数据库日志记录。 ORA-38713:闪回数据库日志记录已打开。) 然后在broker里停止MRP: Dgmgrlsys/oracle@prod1 DGMGRL>EDITDATABASESBDB1SETSTATE=apply-off; 然后到备库里启动闪回: 然后在broker里启动MRP: DGMGRL>EDITDATABASESBDB1SETSTATE=apply-on; Showdatabaseverboseprod1; editdatabasePROD1setpropertyFastStartFailoverTarget='SBDB1'; editconfigurationsetpropertyFastStartFailoverThreshold='120'; Showconfiguration; ENABLEFAST_STARTFAILOVER; STARTOBSERVER;(最后一步会卡在那里) LogontotheSBDB1databasebyusing: sys/oracle@SBDB1assysdba system/oracle@SBDB1 Inthisscenario,youwillbegivenahardwaresetupreadyforanOracleDatabase11gR2RealApplicationCluster(RAC)installation.YouwillinstallGridInfrastructureforclustersandsetupAutomaticStorageManager(ASM). Attheendofthisskillset,thePROD1databaseshouldbeopen.Nocreditwillbegivenforthescenarioifthedatabaseisnotopenforaccess. Important-ReadFirst 1.ThehostnamesandIPaddressesforyourtwoRACnodesareprovidedinthe/etc/hostsfileonyourDatabaseServer. 2.ThetwoRACnodesarehost01.example.comandhost02.example.com. 3.Theipaddressforhost01.example.comis192.0.2.101andforhost02.example.comis192.0.2.102. 4.UsevncviewermachineIP:2toaccessyourRACnode1forexample,vncviewer192.0.2.101:2orhost01:2(notethe:2afterthenodemachinename).TheVNCpasswordisoracle. 5.OntheRACnodedesktopifyoufindtheSmartCardManagerUIopen,clickthe"Close"buttonandcontinuewiththetasks. 6.Youhaverootaccesswiththepasswordoracleandanoracleuseraccountwiththepasswordoracle. 7.Thesoftwareisstagedinthe/stage/folderonhost01. 8.FornetworkconfigurationwhileinstallingGridInfrastructure,chooseeth0aspublicnetworkadapterandeth1andeth2forprivateinterconnect. 9.Usetheclusternamecluster01. 10.UsetheSCANnamecluster01-scan.example.comfortheGridInfrastructureinstallation. 11.DonotusetheGNSoptionfortheGridInfrastructureinstallation. 12.DonotrestarttheRACnodes. 13.MinimumSystemRequirementsforGridInfrastructureInstallation Duringinstallation,ifanydeficienciesarefound,theinstallerwilldisplaythemessagesonthePerformSystemPrerequisitespage. Clickthe"Fix&CheckAgain"button.Theinstallerwillgenerateafixupscripttoberunasrootonhast01andhost02.Followtheinstructionsasdisplayedonyourscreen. Whenfinished,returntotheinstallerandclickthe"Fix&CheckAgain"button.Youmayreceivea"DeviceChecksforASM"warning.Ignorethiswarningbyselectingthe"IgnoreAll"checkbox,thenclickYesontheConfirmationbox,andthenclickNexttocontinue. 翻译:第八部分 在这种情况下,将为您提供一个硬件设置,以便安装OracleDatabase11gR2RealApplicationCluster(RAC)。您将为群集安装网格基础结构并设置自动存储管理器(ASM)。 安装Oracle网格基础设施。 创建ASM磁盘组。 创建和管理一个ASM实例。 创建ACF。 启动、停止、配置和管理Oracle网格基础设施。 在这个技能集的末尾,PROD1数据库应该是打开的。如果数据库未打开以供访问,则不会对该方案给予信任。 重要的先读 1.数据库服务器上的/etc/hosts文件中提供了两个RAC节点的主机名和IP地址。 2.这两个RAC节点是host01.example.com和host02.example.com。 3.host01.example.com的ip地址是192.0.2.101,host02.example.com的ip地址是192.0.2.102。 4.使用vncviewermachineIP:2访问您的RAC节点1,例如,vncviewer192.0.2.101:2或host01:2(请注意节点计算机名称后面的:2)。VNC密码是oracle。 5.在RAC节点桌面上,如果发现智能卡管理器UI打开,请单击“关闭”按钮并继续执行任务。 6.您可以使用密码oracle进行根访问,并使用密码oracle的oracle用户帐户进行访问。 7.软件在host01上的/stage/文件夹中暂存。 8.对于安装网格基础结构时的网络配置,请选择eth0作为公用网络适配器,选择eth1和eth2作为专用互连。 9.使用集群名称cluster01。 10.使用扫描名cluster01SCAN.example.com安装网格基础结构。 11.不要使用GNS选项来安装网格基础设施。 12.不要重新启动RAC节点。 13.电网基础设施安装的最低系统要求 在安装过程中,如果发现任何缺陷,安装程序将在“执行系统必备项”页上显示消息。 单击“修复并再次检查”按钮。安装程序将生成一个fixup脚本,在hast01和host02上以根用户身份运行。请按照屏幕上显示的说明进行操作。 完成后,返回安装程序并单击“修复并再次检查”按钮。您可能会收到“DeviceChecksforASM”警告。通过选中“全部忽略”复选框忽略此警告,然后在确认框上单击“是”,然后单击“下一步”继续。 TASKS Section1:InstallGridInfrastructureandCreateASMDiskGroups 2.Createadiskgroup,DATA,withnormalredundancy.Selectthefollowingasmdisks: ASMDISK01 ASMDISK02 ASMDISK03 ASMDISK04 通过GI的安装图形界面创建 3.Createadiskgroup,ACFSwithexternalredundancyforuseasanADVMvolumefile.Selectthefollowingasmdisks: ASMDISK05 ASMDISK06 ASMDISK07 ASMDISK08 第1节:安装网格基础结构并创建ASM磁盘组 1.安装电网基础设施。网格基本目录应该是/u01/app/grid,主目录应该是/u01/app/11.2.0/grid。使用注释部分提供的详细信息。该软件在racnode1上的以下位置暂存:/stage/grid/。在ASM磁盘组数据中创建投票磁盘和OCR。 2。创建一个具有正常冗余的磁盘组DATA。选择以下asmdisks: 三。创建具有外部冗余的磁盘组ACFS,用作ADVM卷文件。选择以下asmdisks: creatediskgroupACFSexternalredundancydisk 'ORCL:ASMDISK05', 'ORCL:ASMDISK06', 'ORCL:ASMDISK07', 'ORCL:ASMDISK08' 'compatible.rdbms'='11.2', 'compatible.advm'='11.2'; srvctlstartdiskgroup-gACFS 4.Createadiskgroup,FRAwithexternalredundancytoholdtheFastRecoveryArea(FRA).Selectthefollowingasmdisks: ASMDISK09 ASMDISK10 ASMDISK11 ASMDISK12 creatediskgroupFRAexternalredundancydisk 'ORCL:ASMDISK09', 'ORCL:ASMDISK10', 'ORCL:ASMDISK11', 'ORCL:ASMDISK12' srvctlstartdiskgroup-gFRA 5.CreateACFS.CreatethisvolumeintheACFSdiskgroupnamevolumeDB_FILES,specify2GBsize,andmounttheACFSon/u01/app/oracle/acfs_share. 进入asmcmd volcreate-GACFS-s2048MDB_FILES 到节点2上执行:asmcmdvolenable-GACFSdb_files 两个节点分别执行: mkdir-p/u01/app/oracle/acfs_share mkfs-tacfs/dev/asm/db_files-xxx mount-tacfs/dev/asm/db_files-xxx/u01/app/oracle/acfs_share Section2:ConfigureandMaintainGridinfrastructure 1.MirrortheOCRfilesintotheFRAdiskgroup. /u01/app/11.2.0/grid/bin/ocrconfig-add+FRA 2.DumptheOracleLocalRepositoryfileonthefirstnode.NamethefileMYOLR,andcreateitinthe/home/oracle/directory. /u01/app/11.2.0/grid/bin/ocrconfig-local-export/home/oracle/MYOLR 3.DisableautomaticstartupoftheGridInfrastructure. 在两个节点上执行: /u01/app/11.2.0/grid/bin/crsctldisablecrs 4.Copythedb_images.zipfilefrom/home/oracleonhost01totheACFSmountpoint. cp/home/oracle/db_images.zip/u01/app/oracle/acfs_share 5.CreateasnapshotoftheACFSfilesystemandnameitACFS_SNAP01(case-sensitive). acfsutilsnapcreateACFS_SNAP01/u01/app/oracle/acfs_share 没有完全按照老师的步骤 准备工作: 2个压缩包同时解压会出现一个压缩包再解压一次出现2个文件 打开11gRAC 虚拟机打开node1与node2 如果解压的文件夹放在d盘不会出现这样的提示如果不是在d盘则会出现这样的提示选择该文件夹下的ASM1-ASM12(node1与node2都是这样) 进入node1 root用户下vi/etc/hosts配置hosts根据ifconfig获取的ip自行分配和修改分配如下 192.168.62.21node1.oracle.comnode1 192.168.62.22node2.oracle.comnode2 191.2.10.1node1-priv.orcl.comnode1-priv 191.2.10.3node2-priv.orcl.comnode2-priv 191.2.11.1node1-priv2.orcl.comnode1-priv2 191.2.11.3node2-priv2.orcl.comnode2-priv2 下面三个#注释必须打开 192.168.62.23node1-vip.oracle.comnode1-vip 192.168.62.24node2-vip.oracle.comnode2-vip 192.168.62.30node-scan.oracle.comnode-scan vi/etc/sysconfig/network-scripts/ifcfg-eth0 配置静态ip HWADDR=00:0c:29:5b:d3:34 IPADDR=192.168.62.21 GATEWAY=192.168.62.1 重启网络:servicenetworkrestart Node: Node1 IPADDR=192.168.62.22 Node2: HWADDR=00:0C:29:38:EF:52 Node1配置用户环境变量 vi.bash_profile exportPATH exportORACLE_BASE=/u01/app/grid exportORACLE_HOME=/u01/app/11.2.0/grid exportORACLE_SID=+ASM1 Source.bash_profile Node2配置用户环境变量 exportORACLE_SID=+ASM2 检查裸设备是否在两个节点(node1与node2)存在 /etc/init.d/oracleasmlistdisks 文件上传至media文件夹下 Node1: 创建GI安装包文件夹 mkdir-p/stage/grid cd/media 挂载iso文件在刚创建的文件夹下 回mount11.2.0.3_grid_linux.iso/stage/grid/-tiso9660-oloop ExportDISPLAY=192.168.72.1:0.0(该网关看自动获取的网关) /stage/grid/grid/runInstaller打开GI安装图形化 第一步选skipsoftwareupdates 第二步: 默认第一个下一步 第三步:选择advancedinstallation 第四步:默认选English下一步 第五步:GNS默认勾选去掉考试的时候是 ClusterName:cluster01 SCANName:cluster01-scan.example.com SCANPort:1521 第六步:选择SSHconnectivity密码听说考试是oracle不是很确定。 添加的节点 考试时是host02.example.com Host02-vip.example.com 第七步:etho选publiceth1选privateeth2选private 第八步:默认选oracleautomaticstoragemanagement(oracleASM) 第九步:DISKGROUPNAME:DATAredundancy选normal磁盘选择ASM1-ASM4 第十步:选择usesamepasswordsfortheseaccounts密码oracle考试不确定密码 第十一步:Donotuse... 第十二步: 第十三步:OracleBase改成/u01/app/grid下面是/u01/app/11.2.0/grid 第十四步: 第十五步:检查 第十六步:安装过程node1与node跑2个脚本/u01/app/oraInventory/orainstRoot.sh/u01/app/11.2.0/grid/root.sh 一定要node1与node2先跑完第一个脚本才可以再执行root脚本2个节点都要跑(不可以2个节点都执行脚本会报错先node1执行完再node2) 安装完成 /u01/app/11.2.0/grid/bin/asmca 进入asm图形化 新建一个FRA磁盘组ASM5-8 创建ACFSASM9-12 创建db_files卷 考试的时候应该是填2G这边因为老师的环境磁盘分配的是500M所以只能填500M 创建ACFS集群文件系统 Mounted(2of2表示成功) 由于老师的环境没有db_images.zip所以只能自己在/home/oracle下自己创建考试中应该是有的 zip-kdb_images.zip* df-h 将db_images.zip复制到/u01/app/oracle/acfs_share里面 cpdb_images.zip/u01/app/oracle/acfs_share 添加OCR镜像 Su-root /u01/app/11.2.0/grid/bin/ocrcheck-config 给ACFS做snapshot,名称ACFS_SNAP,放在ACFS文件系统上 /sbin/acfsutilsnapcreateACFS_SNAP01/u01/app/oracle/acfs_share 做两个节点的OLR的dump /u01/app/11.2.0/grid/bin/ocrdump-local/home/oracle/MYOLR 两个节点关闭GI的自动启动功能 /u01/app/11.2.0/grid/bin/crsctldisablehas Description-注意这一部分不是真题 Inthissession,youaregoingtodeployRACdatabase. Tasks srvctlstopdatabase-dorcl srvctlstartinstance-dorcl-iorcl1-omount srvctlstartdatabase-dorcl srvctladdserverpool-gocm_serverpool-l0-u2 srvctlmodifyserverpool-gocm_serverpool-n"node1,node2" 把数据库改为policy管理: srvctlmodifydatabase-dorcl-gocm_serverpool srvctlconfigdatabase-dorcl 或者采用把数据库从OCR里删除再添加进去的方式 srvctlremovedatabase-dorcl srvctladddatabase-dorcl-o/u01/app/oracle/product/11.2.0/dbhome_1-p+DATA/orcl/spfileorcl.ora-pocm_serverpool srvctladdservice-dorcl-ssrv1-gocm_serverpool-cUNIFORM srvctlstartservice-dorcl-ssrv1 srvctlstatusservice-dorcl-ssrv1 srvctladdservice-dorcl-ssrv2-gocm_serverpool-cSINGLETON srvctlstartservice-dorcl-ssrv2 srvctlstatusservice-dorcl-ssrv2 altersystemsetmax_memory_target=800Mscope=spfile; 重启实例。 sqlplussystem/oracle createtablesystem.t1(idnumber,c1varchar2(10)); createindexidx_idonsystem.t1(id)reversecompress; createsequenceSEQ_T1startwith10maxvalue100000cache2000noorder; execdbms_shared_pool.keep('system.SEQ_T1','Q'); 没有按照老师的步骤来 第一步先配置2个节点的环境变量 Node1: #exportPATH #exportORACLE_BASE=/u01/app/grid #exportORACLE_HOME=/u01/app/11.2.0/grid #exportPATH=$ORACLE_HOME/bin:$PATH #exportORACLE_SID=+ASM1 exportORACLE_BASE=/u01/app/oracle exportORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 exportORACLE_SID=RACDB1 source.bash_profile Node2: exportORACLE_SID=RACDB2 Node1和node2 chownoracle:oinstall/u01/app/oracle mkdir-p$ORACLE_HOME mkdir-p/stage/db 回mount11.2.0.3_database_linux.iso/stage/db/-tiso9660-oloop 打开OUI安装界面 /stage/db/database/runInstaller 第一步: Iwishto...勾去掉 第三步: 第四步: 点击“SSHConnectivity”进行SSH互信配置,填写oracle密码为oracle考试不确定 第五步: 第六步:数据库版本选择企业版“EnterpriseEdition”,点击“Next” 第七步:考试的时候路径会发生变化一定进行修改 第八步:配置操作系统用户组权限,选择“dba”和“oper” 第九步:预安装检查 第十步:开始安装 第十一步:运行root脚本(node1执行完再执行node2) /u01/app/oracle/product/11.2.0/dbhome_1/root.sh Cd/stage/db dbca 第四步:取消EnterpriseManager配置点击“Next” 第五步:选择统一的用户名密码配置,密码填写oracle考试不确定 第六步: 第七步: 第八步: [oracle@host01bin]$sqlplussys/oracle@RACDBassysdba SQL*Plus:Release11.2.0.3.0ProductiononMonMar2812:11:202016 Connectedto: OracleDatabase11gEnterpriseEditionRelease11.2.0.3.0-Production WiththePartitioning,RealApplicationClusters,AutomaticStorageManagement,OLAP, DataMiningandRealApplicationTestingoptions SQL>select*fromv$instance; INSTANCE_NUMBERINSTANCE_NAME HOST_NAME ---------------------------------------------------------------- VERSION STARTUP_TSTATUS PAR THREAD#ARCHIVELOG_SWITCH_WAIT ------------------------------------------------------------------------- LOGINS SHUDATABASE_STATUSINSTANCE_ROLE ACTIVE_STBLO 1RACDB_1 host01.example.com 11.2.0.3.0 28-MAR-16OPEN YES 1STOPPED ALLOWED NOACTIVE PRIMARY_INSTANCENORMAL NO 2)创建序列 SQL>createsequences_racstartwith100maxvalue999999cache50000order; Sequencecreated. 3)查看序列内容 SQL>setlinesize300 SQL>select*fromuser_sequenceswheresequence_name='S_RAC'; SEQUENCE_NAME MIN_VALUEMAX_VALUEINCREMENT_BYCOCACHE_SIZE LAST_NUMBER -------------------------------------------------------------------------- S_RAC 1 999999 1NY 50000 100 Host01和host02分别执行: Selects_rac.nextvalfromdual;缓存到内存中。此步必须执行才能得分。 1.2.2创建service:ACNTPAY,要求连到OCMPOOL时,每次只使用一个实例 1)查看集群状态 [oracle@host01~]$cd/u01/app/11.2.0/grid/bin [oracle@host01bin]$./crsctlstatres-t NAME TARGETSTATE SERVER STATE_DETAILS LocalResources ora.ACFS.dg ONLINEONLINE host01 host02 ora.DATA.dg ora.FRA.dg ora.LISTENER.lsnr ora.asm Started ora.gsd OFFLINEOFFLINE ora.net1.network ora.ons ora.registry.acfs ora.LISTENER_SCAN1.lsnr ora.LISTENER_SCAN2.lsnr ora.LISTENER_SCAN3.lsnr ora.cvu ora.host01.vip ora.host02.vip ora.oc4j ora.racdb.db Open 2 ora.scan1.vip ora.scan2.vip ora.scan3.vip 2)创建service [oracle@host01bin]$./srvctladdservice-dRACDB-sACNTPAY-cSINGLETON-gOCMPOOL 3)启动service [oracle@host01bin]$./srvctlstartservice-dRACDB-sACNTPAY ora.racdb.acntpay.svc 4)查看RAC所使用的服务器池(ServerPools)的方法 [oracle@host01bin]$./srvctlconfigdatabase-dRACDB Databaseuniquename:RACDB Databasename:RACDB Oraclehome:/u01/app/oracle/product/11.2.0/dbhome_1 Oracleuser:oracle Spfile:+DATA/RACDB/spfileRACDB.ora Domain: Startoptions:open Stopoptions:immediate Databaserole:PRIMARY Managementpolicy:AUTOMATIC Serverpools:OCMPOOL Databaseinstances: DiskGroups:DATA,ACFS Mountpointpaths: Services:ACNTPAY Type:RACDatabaseispolicymanaged RACDB createsequencePS_SEQincrementby1startwith100maxvalue99999minvalue100cache99900order; srvctladdservice-dRACDB-sACNTPAY-gOCMPOOL-csingleton-yautomatic