Sei sulla pagina 1di 14

Chapter 1-4 Check your kernel version by running the following command: uname -r # uname -r 2.6.18-8.el !

e"uired #ackage versions $or later%: r#m -"a&gre# com#at-libstdc''-((-(.2.(r#m -"a&gre# elfutils-libelf-).12 r#m -"a&gre# elfutils-libelf-devel-).12 r#m -"a&gre# glibc-2. r#m -"a&gre# glibc-devel-2. r#m -"a&gre# glibc-common-2. r#m -"a&gre# gccr#m -"a&gre# gcc-c''r#m -"a&gre# kernel-headers r#m -"a&gre# libgccr#m -"a&gre# libaior#m -"a&gre# libaio-devel-).(.1)6r#m -"a&gre# libstdc''r#m -"a&gre# libstdc''-develr#m -"a&gre# uni*+,-Cr#m -"a&gre# uni*+,-C-develr#m -"a&gre# sysstatr#m -"a&gre# binutils-2.1.. ).).6r#m -"a&gre# make-(.81 /f you0ve #erformed a 1default !23s1 install as suggested by +racle4 there are still some re"uired #ackages that must be installed: # r#m -ivh gcc-5.1.2-52.el .i(86.r#m # r#m -ivh uni*+,-C-2.2.11-..1.i(86.r#m # r#m -ivh uni*+,-C-devel-2.2.11-..1.i(86.r#m # r#m -ivh libaio-devel-).(.1)6-(.2.i(86.r#m Configuring Linux for Oracle 6ow that the 7inu* software is installed4 you need to configure it for +racle. 8his section walks through the ste#s re"uired to configure 7inu* for +racle ,atabase 11g !elease 1. Create the Oracle Groups and User Account

6e*t4 create the 7inu* grou#s and user account that will be used to install and maintain the +racle ,atabase 11g !elease 1 software. 8he user account will be called oracle4 and the grou#s will be oinstall and dba. 9*ecute the following commands as root: :usr:sbin:grou#add oinstall :usr:sbin:grou#add dba :usr:sbin:useradd -m -g oinstall -; dba oracle <root=server >?# id oracle uid@ ))$oracle% gid@ ))$oinstall% grou#s@ ))$oinstall%4 )1$dba% Aet the #assword on the oracle account: #asswd oracle Create Directories 6ow create directories to store the +racle ,atabase 11g !elease 1 software and the database files. 8his guide adheres to the +#timal Ble*ible Crchitecture $+BC% for the naming conventions used in creating the directory structure. Bor more information on +BC standards4 see C##endi* , of the Oracle Database Installation Guide 11g Release 1 (11.1) for Linux. 8he following assumes that the directories are being created in the root filesystem. 8his is done for the sake of sim#licity and is not recommended as a general #ractice. 8hese directories would normally be created as se#arate filesystems. /ssue the following commands as root: mkdir -# :u)1:a##:oracle:#roduct:11.1.):dbD1 chown -! oracle:oinstall :u)1 chmod -! .. :u)1 Configuring the Linux Kernel Parameters +racle ,atabase 11g !elease 1 re"uires the kernel #arameter settings shown below. 8he values given are minimums4 so if your system uses a larger value4 don0t change it. 7inu* allows modification of most kernel #arameters while the system is u# and running4 so there0s no need to reboot the system after making kernel #arameter changes. <root=server >?# vi :etc:sysctl.conf kernel.shmall @ 2)E.1 2 ernel!shmmax " 4#$4$%&#$' kernel.shmmni @ 5)E6 kernel.sem @ 2 ) (2))) 1)) 128

fs.file-ma* @ 6 (6 net.i#v5.i#DlocalD#ortDrange @ 1)25 6 ))) net.core.rmemDdefault@51E5()5 net.core.wmemDdefault@262155 net.core.rmemDma*@51E5()5 net.core.wmemDma*@262155 <root=server >?# :sbin:sysctl -# net.i#v5.i#Dforward @ ) net.i#v5.conf.default.r#Dfilter @ 1 net.i#v5.conf.default.acce#tDsourceDroute @ ) kernel.sysr" @ ) kernel.coreDusesD#id @ 1 net.i#v5.tc#Dsyncookies @ 1 kernel.msgmnb @ 6 (6 kernel.msgma* @ 6 (6 kernel.shmma* @ 52E5E6.2E kernel.shmall @ 2685( 5 6 kernel.shmall @ 2)E.1 2 kernel.shmma* @ 52E5E6.2E kernel.shmmni @ 5)E6 kernel.sem @ 2 ) (2))) 1)) 128 fs.file-ma* @ 6 (6 net.i#v5.i#DlocalD#ortDrange @ 1)25 6 ))) net.core.rmemDdefault @ 51E5()5 net.core.wmemDdefault @ 262155 net.core.rmemDma* @ 51E5()5 net.core.wmemDma* @ 262155 <root=server >?# (etting shell limits for the oracle user +racle recommends setting limits on the number of #rocesses and o#en files each 7inu* account may use. 8o make these changes4 cut and #aste the following commands as root: cat FF :etc:security:limits.conf GG9+B oracle soft n#roc 2)5. oracle hard n#roc 16(85 oracle soft nofile 1)25 oracle hard nofile 6 (6 9+B cat FF :etc:#am.d:login GG9+B

session re"uired :lib:security:#amDlimits.so 9+B Change the default #rofile for bash and ksh as well as the default login scri#t for cshell. cat FF :etc:#rofile GG9+B if < HIJA9! @ 1oracle1 ?K then if < HIAL977 @ 1:bin:ksh1 ?K then ulimit -# 16(85 ulimit -n 6 (6 else ulimit -u 16(85 -n 6 (6 fi umask )22 fi 9+B cat FF :etc:csh.login GG9+B if $ HIJA9! @@ 1oracle1 % then limit ma*#roc 16(85 limit descri#tors 6 (6 umask )22 endif 9+B )osts *ile 8he :etc:hosts file must contain a fully "ualified name for the server: 12..).).1 localhost.localdomain localhost 1E2.168.1.1)) server.rhel .com server

7ogin as the oracle user and add the following lines at the end of the .bashD#rofile file: # +racle Aettings 832@:tm#K e*#ort 832 832,/!@I832K e*#ort 832,/! +!CC79D-CA9@:u)1:a##:oracleK e*#ort +!CC79D-CA9 +!CC79DL+39@I+!CC79D-CA9:#roduct:11.1.):dbD1K e*#ort +!CC79DL+39 +!CC79DA/,@orclK e*#ort +!CC79DA/, +!CC79D89!3@*termK e*#ort +!CC79D89!3 2C8L@:usr:sbin:I2C8LK e*#ort 2C8L 2C8L@I+!CC79DL+39:bin:I2C8LK e*#ort 2C8L 7,D7/-!C!MD2C8L@I+!CC79DL+39:lib::lib::usr:libK e*#ort 7,D7/-!C!MD2C8L

C7CAA2C8L@I+!CC79DL+39:N!9:I+!CC79DL+39:Olib: I+!CC79DL+39:rdbms:OlibK e*#ort C7CAA2C8L if < IJA9! @ 1oracle1 ?K then if < IAL977 @ 1:bin:ksh1 ?K then ulimit -# 16(85 ulimit -n 6 (6 else ulimit -u 16(85 -n 6 (6 fi fi <oracle=server >?I env&gre# +!C +!CC79DA/,@orcl +!CC79D-CA9@:u)1:a##:oracle +!CC79D89!3@*term +!CC79DL+39@:u)1:a##:oracle:#roduct:11.1.):dbD1 <oracle=server >?I 3ake Ataging ,irectory <root=server >?# mkdir -# :stage <root=server >?# chown -! oracle:oinstall :stage Co#y 11g database to staging directory #wd :stage:database <oracle=server database?I .:run/nstaller P

Chapter ' 9asy Connect AQ7F conn sys:oracle=server.rhel .com:1 21:orcl as sysdba Connected. AQ7F AQ7F def ,9B/69 D,C89 @ 1) -6+R-)E1 $CLC!% ,9B/69 DC+669C8D/,968/B/9! @ 1server.rhel .com:1 21:orcl1 $CLC!%

7ocal 6aming AQ7F conn scott:tiger=orcl Connected. AQ7F def ,9B/69 D,C89 @ 1) -6+R-)E1 $CLC!% ,9B/69 DC+669C8D/,968/B/9! @ 1orcl1 $CLC!%

Chapter $ AQ7F /6A9!8 /68+ em#loyees RC7J9A $EEEE40-ob040-uilder040bob=abc.net046J774AMA,C894 0/8D2!+;046J7746J7741))4E)%K

AQ7F J2,C89 em#loyees A98 AC7C!M@6))) SL9!9 9327+M99D/, @ EEEEK AQ7F ,97989 from em#loyees SL9!9 9327+M99D/, @EEEEK

Create Bunction
CREATE OR REPLACE FUNCTION compute_tax (salary NUMBER) RETURN NUMBER AS BEGIN IF salary<5000 THEN RETURN salary*.15; ELSE RETURN salary*.33; END IF; END; /

Create 2rocedure

C!9C89 2!+C9,J!9 1L!1.1;/R9D!C/A9D8+DC771 as begin u#date hr.em#loyees set salary @ salary T 1.) K endK Create 2ackage A#ecification and -ody C!9C89 2CCUC;9 1L!1.13+69M1 as #rocedure giveDraiseDtoDallK function com#uteDta* $salary in number% return numberK endK C!9C89 2CCUC;9 -+,M 1L!1.13+69M1 as function com#uteDta* $salary in number% return number as begin if salary G ))) then return salary T ).1 K else return salary T ).((K end ifK endK #rocedure giveDraiseDtoDall as begin u#date hr.em#loyees set salary @ salary T 1.) K endK endK /f you get an error dro# the #ackage body and create again. AQ7F dro# #ackage body moneyK AQ7F desc moneyK AQ7F A979C8 money.com#uteDta*$salary% B!+3 hr.em#loyees SL9!9 em#loyeeDid@1).K AQ7F A979C8 salary B!+3 hr.em#loyeesK
SQL> EXECUTE money.give_raise_to_all;

AQ7F A979C8 salary B!+3 hr.em#loyeesK

AQ7F desc dbmsDlockK

7ocks J2,C89 em#loyees A98 salary@salary'1)) SL9!9 em#loyeeDid@1)) J2,C89 em#loyees A98 salary@salaryT1.1 SL9!9 em#loyeeDid@1))K

select sid4 serial#4 username from vIsession where sid in $select blockingDsession from vIsession% C789! AMA893 U/77 A9AA/+6 012241())0 /339,/C89K ,eadlock J2,C89 em#loyees A98 salary@salary'1)) SL9!9 em#loyeeDid@1)) J2,C89 em#loyees A98 salary@salaryT1.1 SL9!9 em#loyeeDid@1))

Chapter 1+ J2,C89 em#loyees A98 salary@salary'1)) SL9!9 em#loyeeDid@1)) select T from vItransactionK commitK
SQL> ALTER TABLESPACE undotbs1 RETENTION GUARANTEE; SQL> ALTER TABLESPACE undotbs1 RETENTION NOGUARANTEE;

Chapter 11

show #arameter audit select T from ,-CDCJ,/8D8!C/7K C789! AMA893 A98 auditDtrail@VW37X AC+29@A2B/79K select T from RIW37DCJ,/8D8!C/7K show #arameter auditDsysDo#erations Chapter 1# AQ7F create table em#1 as select T from em#loyeesK A979C8 C+J68$T% B!+3 em#1K AQ7F A979C8 numDrows B!+3 dbaDtables SL9!9 owner@0L!0 C6, tableDname @ 093210K 6J3D!+SA ---------;ather Atats from s"l or 93 AQ7F 9W9C dbmsDstats.gatherDtableDstats$0L!04093210%K AQ7F A979C8 numDrows B!+3 dbaDtables SL9!9 owner@0L!0 C6, tableDname @ 093210K 6J3D!+SA ---------1).

Creating and ,esting an Alert C!9C89 A3C77B/79 8C-79A2CC9 1/6R968+!M1 ,C8CB/79 0:u)1:a##:oracle:oradata:orcl:inventory0 A/Y9 1)3 7+;;/6; 9W8968 3C6C;93968 7+CC7 A9;3968 A2CC9 3C6C;93968 CJ8+ ,9BCJ78 6+C+32!9AAK C!9C89 8C-79 1L!1.1B/779!1 8C-79A2CC9 1/6R968+!M1 A8+!C;9 $/6/8/C7 E3% CA A979C8 T B!+3 1L!1.19327+M99A1K

Create Performance pea s C!9C89 8C-79 dbDre#layDtestDtab $ id 6J3-9!4 descri#tion RC!CLC!2$ )%4 C+6A8!C/68 dbDre#layDtestDtabD#k 2!/3C!M U9M $id% %K AQ7F select T from userDobOectsK AQ7F select count$T% from ,-D!927CMD89A8D8C-K -9;/6 B+! i /6 1 .. 1 ))))) 7++2 /6A9!8 /68+ dbDre#layDtestDtab $id4 descri#tion% RC7J9A $i4 0,escri#tion for 0 && i%K 96, 7++2K C+33/8K 96,K AQ7F select count$T% from ,-D!927CMD89A8D8C-K Chapter 1'
SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE;

cd /u01/app/oracle/diag/rdbms/orcl/orcl/trace

Chapter 1% login to 93 as sysdba


SELECT name, error FROM v$datafile JOIN v$recover_file USING (file#);

rman target / nocatalog rman> list failure all;

CREATE SMALLFILE TABLESPACE "INVENTORY1" DATAFILE '/u01/app/oracle/oradata/orcl/inv1' SIZE 100M LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO DEFAULT NOCOMPRESS CREATE TABLE "HR"."FILLER3" TABLESPACE "INVENTORY1" STORAGE (INITIAL 9M) AS SELECT * FROM "HR"."EMPLOYEES"; Select * from hr.filler3;

Cd /u01/app/oracle/oradata/orcl

I rm -rf inv1 !3C6F list failure allK using target database control file instead of recovery catalog 7ist of ,atabase Bailures @@@@@@@@@@@@@@@@@@@@@@@@@ Bailure /, 2riority Atatus 8ime ,etected Aummary ---------- -------- --------- ------------- ------52 L/;L +296 11-6+R-)E +ne or more non-system datafiles are missing !3C6F AQ7F A979C8 name4 error B!+3 vIdatafile 2 N+/6 vIrecoverDfile JA/6; $file#%K 6C39 --------------------------------------------------------------------------------

9!!+! ----------------------------------------------------------------:u)1:a##:oracle:oradata:orcl:inv1 B/79 6+8 B+J6, Brom Checkers see ,- structure integrity check -ring datafile offline. # restore and recover datafile s"l 0alter database datafile 6 offline0K restore datafile 6K recover datafile 6K s"l 0alter database datafile 6 online0K !3C6F list failure allK AQ7F A979C8 name4 error B!+3 vIdatafile 2 N+/6 vIrecoverDfile JA/6; $file#%K AQ7F select T from RI/!DBC/7J!9K AQ7F select T from RI/!D3C6JC7DCL9CU7/A8K AQ7F select T from RI/!D!92C/!K AQ7F select T from RI/!DBC/7J!9DA98 C,R/A9D/, BC/7J!9D/, 3C6 ---------- ---------- --121 5 6+

Chapter 1& - 1. !un the labD)6D)1.sh scri#t that creates the ,-C1 user register dba1 in 93K Bor 1.-2 ,rill create user inventory identified by oracle default tables#ace usersK grant connect4 resource to inventoryK

create table #roductDmaster $#roductDid number$5%4 #roductDname char$ )%4 code char$1)%4 reorderDthreshold number$2%4 cost number$242%4 #rice number$242%4 #rimaryDsource char$ )%4 secondaryDsource char$ )%4 obsoleted date%K create table 2!+,JC8D+6DLC6, $warehouseDid number$(%4 #roductDid number$5%4 "uantity number$1%4 warehouseDcity char$()%4 lastDu#date date%K I s"lldr userid@inventory:oracle control@labD1.D)2D)2.ctl log@labD1.D)2D)2.log data@labD1.D)2D)2.dat

Bor Cha#ter 18 use the scri#t Corru#ted -locks to corru#t blocks. blockDcorru#t.sh e*#ort +!CC79DA/,@orcl s"l#lus sys:oracle as sysdbaGG9+B dro# tables#ace tbsbc including contents and datafilesK create tables#ace tbsbc datafile 0:u)1:a##:oracle:oradata:orcl:tbsbc12.dbf0 siZe 2)mK dro# user -C cascadeK create user -C identified by -C default tables#ace tbsbcK grant connect4resource4dba to -CK create table bc.em#loyees as select T from hr.em#loyeesK create table bc.de#artments as select T from hr.de#artmentsK create table bc.regions as select T from hr.regionsK

commitK alter system set dbDrecoveryDfileDdestDsiZe @ 6;K 9+B rman target : nocatalogGG9+B backu# tables#ace tbsbcK 9+B dd of@I+!CC79D-CA9:oradata:orcl:tbsbc12.dbf bs@81E2 conv@notrunc seek@12 GG 9+B C+!!J28 corru#t C+!!J28 corru#t C+!!J28 corru#t C+!!J28 corru#t C+!!J28 corru#t 9+B dd of@I+!CC79D-CA9:oradata:orcl:tbsbc12.dbf bs@81E2 conv@notrunc seek@2) GG 9+B C+!!J28 corru#t C+!!J28 corru#t C+!!J28 corru#t C+!!J28 corru#t C+!!J28 corru#t 9+B dd of@I+!CC79D-CA9:oradata:orcl:tbsbc12.dbf bs@81E2 conv@notrunc seek@28 GG 9+B C+!!J28 corru#t C+!!J28 corru#t C+!!J28 corru#t C+!!J28 corru#t C+!!J28 corru#t 9+B s"l#lus sys:oracle as sysdbaGG9+B alter system flush bufferDcacheK select T from bc.em#loyeesK select T from bc.de#artmentsK select T from bc.regionsK e*it 9+B

Potrebbero piacerti anche