practice 3: managing an oracle instance - wikispacespractice+3.docx · web viewlist the name and...

12
Oracle 11g DBA Practice 3: Managing an Oracle Instance

Upload: truongkhuong

Post on 08-Apr-2018

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Practice 3: Managing an Oracle Instance - Wikispacespractice+3.docx · Web viewList the name and size of the data files, online redo log files, and the name of the control files

Oracle 11g DBA

Practice 3: Managing an Oracle Instance

Page 2: Practice 3: Managing an Oracle Instance - Wikispacespractice+3.docx · Web viewList the name and size of the data files, online redo log files, and the name of the control files

1 Identify the database name, instance name, and size of the database blocks.2 List the name and size of the data files, online redo log files, and the name of the control files.3 List the installed options.4 Display the version numbers.5 Display the maximum number of operating system user processes that can simultaneously connect to the instance.6 Try to change the database block size. What happens?7 List the default initialization parameter.8 Open the database in read only mode. Connect as user SCOTT and add 10 percent to all salaries in the table EMP. What happens?Put the database back in read write mode.9 Enable and verify timing in trace files dynamically.10 Connect as user SCOTT and insert rows in the table EMP. Open second session and try to shut down the database transactional. What happens?11 Ensure that there are at least two sessions open, one session as user SCOTT and one as user SYS. Enable the restricted session, verify this and ensure that only the database administrator SYS is connected.12 Examine the following sample of an alert file to identify if internal errors or exceptions have occurred.

Page 3: Practice 3: Managing an Oracle Instance - Wikispacespractice+3.docx · Web viewList the name and size of the data files, online redo log files, and the name of the control files
Page 4: Practice 3: Managing an Oracle Instance - Wikispacespractice+3.docx · Web viewList the name and size of the data files, online redo log files, and the name of the control files

1 Identify the database name, instance name, and size of the database blocks.Hint: Query the dynamic performance views V$DATABASE,V$THREAD, and V$PARAMETER to display the database and instancename and the size of the database blocks.2 List the name and size of the data files, online redo log files, and the name of thecontrol files.Hint: Query the dynamic performance views V$DATAFILE,V$LOGFILE, and V$CONTROLFILE to display the data files, onlineredo log files, and the name of the control files.3 Which options are installed?Hint: Query the dynamic performance views V$OPTION to display theinstalled options.4 Display the version number.Hint: Query the dynamic performance views V$VERSION to displaythe version number.5 Display the maximum number of operating system user processes that cansimultaneously connect to the instance.Hint: Query the dynamic performance views V$PARAMETER or usethe SHOW PARAMETER command to display the maximum number ofoperating system user processes that can simultaneously connect to theinstance.6 Try to change the database block size. What happened?Hint: There is no hint for this question.7 List the default initialization parameter.Hint: Query the dynamic performance views V$PARAMETER todisplay the default initialization parameter.8 Open the database in read only mode. Connect as user SCOTT and add 10 percent toall salaries in the table EMP. What happens? Put the database back in read writemode.Hint: There is no hint for this question.9 Enable timing in trace files dynamically and verify it.Hint: Use the ALTER SYSTEM command to enable timing in trace filesdynamically and use the dynamic performance view V$PARAMETERto verify the result.10 Connect as user SCOTT and insert rows in the table EMP. Open second session andtry to shut down the database transactional. What happens?Hint: There is no hint for this question.11 Ensure that there are at least two sessions open, one session as user SCOTT and oneas user SYS. Enable the restricted session, verify this and ensure that only thedatabase administrator SYS is connected.Hint– Use the ALTER SYSTEM command to enable the restricted session and querythe dynamic performance views V$INSTANCE to verify the result.– Use the dynamic performance view V$SESSION to see the values of the SIDand SERIAL# column.– Execute the ALTER SYSTEM KILL SESSION command to terminate sessions.

Page 5: Practice 3: Managing an Oracle Instance - Wikispacespractice+3.docx · Web viewList the name and size of the data files, online redo log files, and the name of the control files

Solutions1 Identify the database name, instance name, and size of the database blocks.Hint: Query the dynamic performance views V$DATABASE, V$THREAD, andV$PARAMETER.SQL> CONNECT system/[email protected]> SELECT name FROM v$database;NAME---------DB01SQL> SELECT instance FROM v$thread;INSTANCE----------------DB01SQL> SELECT value2 FROM v$parameter3 WHERE name = ’db_block_size’;VALUE-------------------------40962 List the name and size of the data files, online redo log files, and the name of thecontrol files.Hint: Query the dynamic performance views V$DATAFILE, V$LOGFILE, andV$CONTROLFILE.SQL> SELECT name FROM v$datafile;NAME-----------------------------------------/oracle/hrasmuss/DATA/DISK1/system01.dbf/oracle/hrasmuss/DATA/DISK2/rbs01.dbf/oracle/hrasmuss/DATA/DISK3/data01.dbf/oracle/hrasmuss/DATA/DISK2/temp01.dbf/oracle/hrasmuss/DATA/DISK2/indx01.dbf/oracle/hrasmuss/DATA/DISK3/oemrep01.dbf/oracle/hrasmuss/DATA/DISK1/query01.dbfSQL> SELECT member FROM v$logfile;MEMBER-----------------------------------------/oracle/hrasmuss/DATA/DISK3/redo0101.log/oracle/hrasmuss/DATA/DISK4/redo0102.log/oracle/hrasmuss/DATA/DISK3/redo0201.log/oracle/hrasmuss/DATA/DISK4/redo0202.logSQL> SELECT name FROM v$controlfile;NAME-----------------------------------------/oracle/hrasmuss/DATA/DISK1/control01.ctl3 List the installed options.Hint: Query the dynamic performance view V$OPTION.SQL> COL paramter FORMAT a40SQL> COL status FORMAT a10SQL> SELECT * from v$option;PARAMETER VALUE---------------------------------------- ----------Partitioning TRUEObjects TRUE

Page 6: Practice 3: Managing an Oracle Instance - Wikispacespractice+3.docx · Web viewList the name and size of the data files, online redo log files, and the name of the control files

Parallel Server FALSEAdvanced replication TRUEBit-mapped indexes TRUEConnection multiplexing TRUEConnection pooling TRUEDatabase queuing TRUEIncremental backup and recovery TRUEInstead-of triggers TRUEParallel backup and recovery TRUEParallel execution TRUEParallel load TRUEPoint-in-time tablespace recovery TRUEFine-grained access control TRUEN-Tier authentication/authorization TRUEFunction-based indexes TRUEPlan Stability TRUEOnline Index Build TRUECoalesce Index TRUEManaged Standby TRUEMaterialized view rewrite TRUEMaterialized view warehouse refresh TRUEDatabase resource manager TRUESpatial TRUEVisual Information Retrieval TRUEExport transportable tablespaces TRUETransparent Application Failover TRUEFast-Start Fault Recovery TRUESample Scan TRUEDuplexed backups TRUEJava TRUE4 Display the version numbers.Hint: Query the dynamic performance view V$VERSION.SQL> SELECT * FROM v$version;BANNER----------------------------------------------------------Oracle8i Enterprise Edition Release 8.1.5.0.0 - ProductionPL/SQL Release 8.1.5.0.0 - ProductionCORE Version 8.1.3.0.0 - ProductionTNS for Solaris: Version 8.1.5.0.0 - ProductionNLSRTL Version 3.4.0.0.0 – Production5 Display the maximum number of operating system user processes that cansimultaneously connect to the instance.Hint: Query the dynamic performance view V$PARAMETER or use the SHOWPARAMETER.SQL> SELECT value2 FROM v$parameter3 WHERE name = ’processes’;VALUE-------------------------------------------------------606 Try to change the database block size. What happens?SQL> connect sys/oracle@db01 as sysdbaConnected.SQL> shutdown immediate;Database closed.

Page 7: Practice 3: Managing an Oracle Instance - Wikispacespractice+3.docx · Web viewList the name and size of the data files, online redo log files, and the name of the control files

Database dismounted.ORACLE instance shut down.SQL> exita Edit initdb01.ora, and add the following line.DB_BLOCK_SIZE=8192b Then startup the database as follows:SQL> connect sys/oracle@db01 as sysdbaConnected.SQL> startup pfile=$HOME/initdb01.oraORACLE instance started.Total System Global Area 6315408 bytesFixed Size 64912 bytesVariable Size 5308416 bytesDatabase Buffers 409600 bytesRedo Buffers 532480 bytesORA-00209: control file blocksize mismatch, check alert log formore infoSQL> shutdown immediate;SQL> exitc Edit init<SID>.ora file to undo the db_block_size change made above.SQL> connect sys/oracle as sysdbaSQL> startup pfile=$HOME/initDB01.ora7 List the default initialization parameter.Hint: Query the dynamic performance view V$PARAMETER.SQL> SELECT name2 FROM v$parameter3 WHERE isdefault=’TRUE’;NAME-------------------------------------------------------spin_countsessions...session_max_open_filesaq_tm_processeshs_autoregister174 rows selected.8 Open the database in read-only mode. Connect as user SCOTT and add 10 percent toall salaries in the table EMP. What happens?a Put the database back in read-write mode.SQL> connect sys/oracle@db01 as sysdbaConnected.SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> exitb Then Startup the database as follows:SQL> connect sys/oracle@db01 as sysdbaConnectedSQL> startup pfile=$HOME/initDB01.ora mount;ORACLE instance started.Total System Global Area 6315408 bytesFixed Size 64912 bytesVariable Size 5308416 bytesDatabase Buffers 409600 bytes

Page 8: Practice 3: Managing an Oracle Instance - Wikispacespractice+3.docx · Web viewList the name and size of the data files, online redo log files, and the name of the control files

Redo Buffers 532480 bytesDatabase mounted.SQL> alter database open read only;SQL> Database altered.SQL> connect scott/tiger@db01SQL> update emp set sal=sal*1.1;0 rows updated.SQL> connect sys/oracle@db01 as sysdbaConnectedSQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> exitc Then start up the database as follows:SQL> connect sys/oracle@db01 as sysdbaConnectedSQL> startup pfile=$HOME/initDB01.ora;ORACLE instance started.Total System Global Area 6315408 bytesFixed Size 64912 bytesVariable Size 5308416 bytesDatabase Buffers 409600 bytesRedo Buffers 532480 bytesDatabase mounted.Database opened.9 Enable and verify timing in trace files dynamically.Hint: Use the ALTER SYSTEM command. Use the dynamic performance viewV$PARAMETER to verify the result.SQL> SELECT value, isdefault, ismodified2 FROM v$parameter3 WHERE name = ’timed_statistics’;VALUE ISDEFAULT ISMODIFIED------------------------------ --------- ----------FALSE TRUE FALSE1 row selected.SQL> ALTER SYSTEM SET timed_statistics=true;System altered.SQL> SELECT value, isdefault, ismodified2 FROM v$parameter3 WHERE name =’timed_statistics’;VALUE ISDEFAULT ISMODIFIED------------------------------ --------- ----------TRUE TRUE SYSTEM_MOD10 Connect as user SCOTT and insert rows in the table EMP. Open a second sessionand try to shut down the database transactional. What happens?Hint: There is no hint for this question.SQL> connect scott/[email protected]> INSERT INTO emp (empno, ename, deptno)2 VALUES (1,’Vijay’,10);1 row created.a In the second session,SQL> connect sys/oracle@db01 as sysdbaSQL> shutdown transactional

Page 9: Practice 3: Managing an Oracle Instance - Wikispacespractice+3.docx · Web viewList the name and size of the data files, online redo log files, and the name of the control files

The Oracle server waits for SCOTT’s transaction to end before shutting down.Wait for the instance to shut down at the second session. Then bring it back up.SQL> startup pfile=$HOME/initDB01.ora11 Ensure that there are at least two sessions open; one session as user SCOTT and oneas user SYS. Enable the restricted session, verify this, and ensure that only thedatabase administrator SYS is connected.Hints:– Use the ALTER SYSTEM command to enable the restricted session and querythe dynamic performance views V$INSTANCE to verify the result.– Use the dynamic performance view V$SESSION to see the values of the SIDand SERIAL# column.– Execute the ALTER SYSTEM KILL SESSION command to terminatesessions.SQL> connect scott/[email protected] In the first session,SQL> INSERT INTO emp (empno, ename, deptno)2 VALUES (1,’Vijay’,10);1 row inserted.b In the second session,SQL> connect sys/oracle@db01 as sysdbaConnected.SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;System altered.SQL> SELECT logins FROM v$instance;LOGINS----------RESTRICTEDSQL> SELECT sid, serial#,username2 FROM v$session3 WHERE username!= ’SYS’;SID SERIAL# USERNAME---------- ---------- ------------------------------7 3 SCOTTSQL> ALTER SYSTEM2 KILL SESSION ’7,3’;System altered.SQL> SELECT username, status2 FROM v$session3 WHERE type=’USER’;USERNAME STATUS------------------------------ --------SCOTT KILLEDSYS ACTIVEc In the first session,SQL> SELECT user2 FROM dual;Your session has been killed.12 Examine the following sample of an alert file to identify if internal errors orexceptions have occurred.

Page 10: Practice 3: Managing an Oracle Instance - Wikispacespractice+3.docx · Web viewList the name and size of the data files, online redo log files, and the name of the control files

There is a block corruption message as shown above. Also note other usefulmessages, such as:• Startup time• Nondefault initialization parameters and background processes• Tablespace creation and log switches