Showing posts with label Advanced DBA. Show all posts
Showing posts with label Advanced DBA. Show all posts

Monday, March 4, 2013

Oracle Proxy Users

If you don't have the password of an account and you need to connect with this user to test any thing, instead of resetting the password, Oracle starting from 10g allows you to connect as a proxy user.
This also allows you to have one schema, but allow many users to connect, meaning no need for grants, roles, or synonyms.

This also means that one named user can be a proxy for many different application schemas depending on the connect string.

Configuration:
1- allow oradba user to connect to scott as a proxy user
SQL> alter user scott grant connect through oradba;

2- connect to the scott account using the oradba password
SQL> sqlplus oradba[scott]/oradba_password

3- check the environment
SQL> show user
SQL> select user from dual;
SQL> select sys_context('USERENV','PROXY_USER') from dual;

Sunday, March 3, 2013

How to Clone Oracle Home to a Remote Server

1- Check the oracle home you will clone to the new server
bash-3.2$ ./opatch lsinventory

Invoking OPatch 11.2.0.1.7
Oracle Interim Patch Installer version 11.2.0.1.7
Copyright (c) 2011, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/11.2.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /var/opt/oracle/oraInst.loc
OPatch version : 11.2.0.1.7
OUI version : 11.2.0.3.0
Log file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2013-02-25_07-48-52AM.log
Lsinventory Output file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2013-02-25_07-48-52AM.txt
--------------------------------------------------------------------------------

Installed Top-level Products (1):
Oracle Database 11g 11.2.0.3.0
There are 1 products installed in this Oracle Home.
There are no Interim patches installed in this Oracle Home.
--------------------------------------------------------------------------------

OPatch succeeded.


2- Check the oracle home size

bash-3.2$ cd /u01/app/oracle/product/11.2.0/dbhome_1

bash-3.2$ du -sh .
4.2G .

3- Create the same directory tree on the remote server as the source server and change ownership to oracle user

bash-3.2# mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1

bash-3.2# chown -R oracle:oinstall /u01

4- On source server execute tar command to copy over the network the oracle home directories to the target server

bash-3.2$ cd /u01/app/oracle/product/11.2.0/dbhome_1

bash-3.2$ tar cvf - . ( ssh lnx2 "cd /u01/app/oracle/product/11.2.0/dbhome_1 ; tar xvf -" )

5- On the target server once the tar command finishes to copy on the target oracle home check the total size and must be the same as the source server

bash-3.2$ cd /u01/app/oracle/product/11.2.0/dbhome_1

bash-3.2$ du -sh .
4.2G

6- Before starting clone process we need to detach the inventory because the server was itself a clone of the source

bash-3.2$ cd /u01/app/oracle/product/11.2.0/dbhome_1/oui/bin

bash-3.2$ ./runInstaller -detachHome ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"

Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB. Actual 7917 MB Passed
The inventory pointer is located at /var/opt/oracle/oraInst.loc
The inventory is located at /u01/app/oraInventory
'DetachHome' was successful.
Using the OUI to finish the cloning process



7- Once the inventory was detached from the old server version I can run the cloning procedure

bash-3.2$ cd /u01/app/oracle/product/11.2.0/dbhome_1/oui/bin

bash-3.2$ ./runInstaller -clone -silent -ignorePreReq ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1" ORACLE_HOME_NAME="dbhome_11gR2" ORACLE_BASE="/u01/app/oracle" OSDBA_GROUP=dba OSOPER_GROUP=dba
Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB. Actual 7916 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-02-24_11-29-35AM. Please wait ...bash-3.2$ Oracle Universal Installer, Version 11.2.0.3.0 Production

Copyright (C) 1999, 2011, Oracle. All rights reserved.
You can find the log of this install session at:
/u01/app/oraInventory/logs/cloneActions2013-02-24_11-29-35AM.log
.................................................................................................... 100% Done.
Installation in progress (Sunday, February 24, 2013 11:31:04 AM EET)
............................................................................... 79% Done.
Install successful
Linking in progress (Sunday, February 24, 2013 11:31:40 AM EET)
Link successful
Setup in progress (Sunday, February 24, 2013 11:35:36 AM EET)
Setup successful
End of install phases.(Sunday, February 24, 2013 11:36:09 AM EET)

WARNING:
The following configuration scripts need to be executed as the "root" user.
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh

To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
The cloning of dbhome_11gR2 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2013-02-24_11-29-35AM.log' for more details.

8- The last step is to execute the root.sh script on the target server as root user

bash-3.2$ su -

bash-3.2# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1
Creating /usr/local/bin directory...
Creating /var/opt/oracle/oratab file...
Entries will be added to the /var/opt/oracle/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Finished product-specific root actions.

9- Now,check the Cloned Oracle Home and it must give the same output as the source server

bash-3.2$ ./opatch lsinventory

Invoking OPatch 11.2.0.1.7
Oracle Interim Patch Installer version 11.2.0.1.7
Copyright (c) 2011, Oracle Corporation. All rights reserved.
Oracle Home : /u01/app/oracle/product/11.2.0/dbhome_1
Central Inventory : /u01/app/oraInventory
from : /var/opt/oracle/oraInst.loc
OPatch version : 11.2.0.1.7
OUI version : 11.2.0.3.0
Log file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2013-02-25_07-48-52AM.log

Lsinventory Output file location : /u01/app/oracle/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2013-02-25_07-48-52AM.txt
--------------------------------------------------------------------------------

Installed Top-level Products (1):
Oracle Database 11g 11.2.0.3.0
There are 1 products installed in this Oracle Home.
There are no Interim patches installed in this Oracle Home.
--------------------------------------------------------------------------------

OPatch succeeded.

Monday, December 31, 2012

Parallel Execution

Parallel execution divides the task of executing a SQL statement into multiple small units, each of which is executed by a separate process.
Also, the incoming data (tables, indexes, partitions) can be divided into parts called granules.
The user shadow process that wants to execute a query in parallel takes on the role as parallel execution coordinator or query coordinator.

The query coordinator does the following:

- Parses the query and determines the degree of parallelism
- Allocates one or two sets of slaves (threads or processes)
- Controls the query and sends instructions to the parallel query slaves
- Determines which tables or indexes need to be scanned by the parallel query slaves
- Produces the final output to the user.

If the running sessions on the database are using all parallel slaves assigned to the database using the parameter PARALLEL_MAX_SERVERS,
all new sessions using parallel execution will run in serial mode.


In Oracle 11g if you set the SGA_TARGET with MEMORY_TARGET parameter then all parallel execution sessions will use the Large Pool for its operations
and this will need to increase the LARGE_POOL_SIZE parameter to avoid ORA-4030 errors.
If the SGA_TARGET parameter is not set then all parallel execution sessions will be processed in the Shared Pool.


Using the Degree Of Parallelism (DOP) with objects:

- objects smaller than 200M should not use parallel
- objects between 200M and 5G should use a DOP of 4
- objects greater than 5G should use a DOP of 32

Friday, November 2, 2012

How To Find Datafiles With The Same Name


Sometimes you want to check for datafiles with the same name in your database when you have a major storage migration project or for any other reason.

Here is a little script to check if the database has datafiles with the same name in different directories.

1- To find the duplicated datafiles in the database:

SET LINE 140
SET PAGESIZE 2000
SET HEADING OFF

SELECT COUNT (*), SUBSTR (file_name, INSTR (file_name, '/', -1))
FROM dba_data_files
GROUP BY SUBSTR (file_name, INSTR (file_name, '/', -1))
HAVING COUNT (*) > 1;

2- To find the pathes for the duplicated datafiles:

SELECT file_name full_file_name,
SUBSTR (file_name, INSTR (file_name, '/', -1)) datafile_name
FROM dba_data_files
WHERE (SUBSTR (file_name, INSTR (file_name, '/', -1))) IN
( SELECT SUBSTR (file_name, INSTR (file_name, '/', -1))
FROM dba_data_files
GROUP BY SUBSTR (file_name, INSTR (file_name, '/', -1))
HAVING COUNT (*) > 1);

Tuesday, October 11, 2011

How to Determine the Blocking Session for Event: 'cursor: pin S wait on X'

Use this query to determine the Blocking Session for Event: 'cursor: pin S wait on X'

select s.username
, s.sid
, s.serial#
, p.spid pid
, last_call_et
, status
from V$SESSION s
, V$PROCESS p
where s.PADDR = p.ADDR
and sid in (
select to_number(substr(to_char(rawtohex(p2raw)),1,8),'XXXXXXXX') sid
from v$session
where event = 'cursor: pin S wait on X');

ORA-27301: OS failure message: No space left on device

After installing Oracle on Linux and creating a database,I tried to connect to sqlplus and startup the database instance I got this error:

$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct 5 15:53:47 2011

Copyright (c) 1982, 2009, Oracle. All rights reserved.

Enter user-name: / as sysdba
Connected to an idle instance.

SQL> startup
ORA-27154: post/wait create failed
ORA-27300: OS system dependent operation:semget failed with status: 28
ORA-27301: OS failure message: No space left on device
ORA-27302: failure occurred at: sskgpsemsper

Solution:

As root user, edit the /etc/sysctl.conf file and edit the kernel parameters
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128


and then run this command

/sbin/sysctl -p

sqlplus: error while loading shared libraries: /u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1: cannot restore segment prot after reloc: Permission denied

After install Oracle 11g on Linux while the SELinux was enabled I tried to open sqlplus to start connecting to the database I got this error:

"sqlplus: error while loading shared libraries: /u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1: cannot restore segment prot after reloc: Permission denied"

Error Description:

SELinux is preventing sqlplus from loading /u0/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1 which requires text relocation.

To solve this error:
Configure SELinux to allow /u0/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1 using this command

chcon -t textrel_shlib_t '/u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1'

Monday, December 27, 2010

How To Reclaim Wasted Space In Tables

There are several ways to reclaim wasted space in a table but they work differently.

Create table As Select (CTAS)
This copies the table rows into a clean area, lowering the high-water-mark, packing the rows densely (as dictated by PCTFREE) and releasing free space.

Online re-organization
Using the dbms_redefinition package you can use parallel CTAS to reorganize tables, while the tables continue to accept updates.

Data pump (expdp, impdp)
Rarely used in high-speed production systems, except for backups.

Alter table move
The alter table xxx move command moves rows down into the un-used space and adjusts the HWM but does not adjust the segments extents, and the table size remains the same. The alter table move syntax also preserves the index and constraint definitions.

Alter table shrink space
Using the "alter table xxx shrink space compact" command will re-pack the rows, move down the HWM, and releases unused extents. With standard Oracle tables, you can reclaim space with the "alter table shrink space" command:

SQL> alter table mytable enable row movement;

SQL> alter table mytable shrink space;

Tuesday, December 7, 2010

Flushing Shared Pool

1-What does it do
Flushing the Shared Pool means clear all SQL statements that are in the
Shared Pool Area.

Oracle keeps track of each SQL statement that users execute.
It is stored parsed in memory so that if a SQL statement already has been
executed then Oracle does not need to re-parse it. The exception is if the Shared Pool Area is not large enough, then the least recently used SQL statements (except for pinned packages) will be removed from memory.
By flushing the Shared Pool, all SQL statements are removed from memory.
Flushing shared pool only gets rid of what it can, that which is in use will remain. any pinned objects will remain. any sql with shared cursors will remain.

2-How to Flush Shared Pool
By using this command ALTER SYSTEM FLUSH SHARED_POOL; you can flush the Shared Pool.
SQL> ALTER SYSTEM FLUSH SHARED_POOL;

And note that flushing the shared pool will NEVER empty out the v$sql view there will always be some stuff in there.

3-When should it be used
We use this command when the Shared Pool reaches a high limit like 90% of the shared pool size.

Monday, December 6, 2010

Oracle Undocumented Utility DBFSIZE

DBFSIZE is a hidden and undocumented Oracle utility.This utility is used to provide the exact size of Oracle database files like Datafiles,Controlfiles and Redolog files.

This Utility is not available for Windows platforms.

Using DBFSIZE Utility:

DBFSIZE provides number of blocks and size of block in output of Database file size

$ dbfsize USERS.dbf

Database file: USERS.dbf
Database file type: file system
Database file size: 4196 8192 bytes blocks

Where:
- The first number [4196]: stands for number of blocks.
- The second number [8192]: stands for size of each block.

$ dbfsize CONTROL01.ctl

Database file: CONTROL01.ctl
Database file type: file system
Database file size: 162 14324 bytes blocks

$ dbfsize REDO1.log

Database file: REDO1.log
Database file type: file system
Database file size: 20480 512 bytes blocks

DBFSIZE is helpful to when checking backup file size and current file size of Oracle database.

Thursday, November 11, 2010

Change Database DBID With DBNEWID Utility

To change the DBID for your database you need to use DBNEWID Utility

Steps:

1: Check the DBID and name of the database

SQL> select name,dbid from v$database;

NAME DBID
--------- ----------
TEST 2031038817

2: Shutdown the instance and then Startup in mount mode

SQL> shutdown immediate

SQL> startup mount

3: Run DBNEWID Utility to change the DBID

D:\>nid TARGET=SYS/syspassword@TEST

DBNEWID: Release 10.2.0.3
(c) Copyright 2002 Oracle Corporation. All rights reserved.
Connected to database TEST (DBID= 2031038817)

Control Files in database:
D:\oracle\product\10.2.0\oradata\test\CONTROL01.CTL
D:\oracle\product\10.2.0\oradata\test\CONTROL02.CTL
D:\oracle\product\10.2.0\oradata\test\CONTROL03.CTL

Change database id of database TEST? (Y/[N]) => y
Proceeding with operation

Control file D:\oracle\product\10.2.0\oradata\test\CONTROL01.CTL - dbid changed
Control file D:\oracle\product\10.2.0\oradata\test\CONTROL02.CTL - dbid changed
Control file D:\oracle\product\10.2.0\oradata\test\CONTROL03.CTL - dbid changed
Datafile D:\oracle\product\10.2.0\oradata\test\EXAMPLE01.DBF - dbid changed
Datafile D:\oracle\product\10.2.0\oradata\test\REDO01.LOG - dbid changed
Datafile D:\oracle\product\10.2.0\oradata\test\REDO02.LOG - dbid changed
Datafile D:\oracle\product\10.2.0\oradata\test\REDO03.LOG - dbid changed
Datafile D:\oracle\product\10.2.0\oradata\test\SYSAUX01.DBF - dbid changed
Datafile D:\oracle\product\10.2.0\oradata\test\SYSTEM01.DBF - dbid changed
Datafile D:\oracle\product\10.2.0\oradata\test\TEMP01.DBF - dbid changed
Datafile D:\oracle\product\10.2.0\oradata\test\UNDOTBS01.DBF - dbid changed
Datafile D:\oracle\product\10.2.0\oradata\test\USERS01.DBF - dbid changed
Instance shutdown

New DBID for database TEST is 2032942459.
All previous backups and archived redo logs for this database are unusable
Proceed to shutdown database and open with RESETLOGS option.
DBNEWID completed successfully.



4: Startup mount the database

SQL> startup mount

5: open database with resetlogs option

SQL> alter database open resetlogs;

6: Now check the DBID and name of the database after the change

SQL> select name,dbid from v$database;

NAME DBID
--------- ----------
TEST 2032942459

Wednesday, November 3, 2010

Convert from Oracle Standard Edition to Enterprise Edition

The following steps need to be taken to convert your SE database to an EE

1- Take Offline Backup of your database.
2- De-install the Standard Edition software.
3- Install the Enterprise Edition software and check that the release version of your Standard Edition software is the same as the Enterprise Edition software.
4- Create a new database with the same name of your old database.
5- Restore the backup of your old database to the new one.
6- Startup the database
7- Run the "catalog.sql" and "catproc.sql" scripts.
Your database is now using the Enterprise Edition (EE) version of the software.

Monday, June 21, 2010

Purge Old Snapshots From SYSAUX Tablespace

Sometimes you find that SYSAUX tablespace has grown in space so you need to free space from the tablespace.

one of the things you may need to remove from SYSAUX tablespace is the old Snapshots.

Using the following PL/SQL code you will be able to purge the no longer needed Snapshots From SYSAUX Tablespace

DECLARE
V_DBID NUMBER;
V_MIN_SNAP NUMBER;
V_MAX_SNAP NUMBER;
BEGIN
SELECT DBID INTO V_DBID FROM V$DATABASE;

SELECT MIN (SNAP_ID), MAX (SNAP_ID) - 20
INTO V_MIN_SNAP, V_MAX_SNAP
FROM DBA_HIST_SNAPSHOT;

DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE (LOW_SNAP_ID => V_MIN_SNAP,
HIGH_SNAP_ID => V_MAX_SNAP,
DBID => V_DBID);
END;
/

Monday, June 14, 2010

Change The Database Character Set

In some cases, you may need to change the character set for an existing database.
For example, you may find that the number of languages that need to be supported in your database have increased.

Before,we had to do a full export/import to convert all data to the new character set. And now, if and only if, the new character set is a strict superset of the current character set, it is possible to use the ALTER DATABASE CHARACTER SET to change the database character set.

The target character set is a strict superset if and only if each and every codepoint in the source character set is available in the target character set, with the same corresponding codepoint value. For instance the following migration scenarios can take advantage of the ALTER DATABASE CHARACTER SET command since US7ASCII is astrict subset of WE8ISO8859P1,AL24UTFFSS, and UTF8:

WARNING: Attempting to change the database character set to a character set that is not a strict superset can result in data loss and data corruption. To ensure data integrity, whenever migrating to a new character set that is not a strict superset, you must use export/import. It is essential to do a full backup of the database before using the ALTER DATABASE [NATIONAL] CHARACTER SET statement, since the command cannot be rolled back. The syntax is:

ALTER DATABASE [] CHARACTER SET ;
ALTER DATABASE [] NATIONAL CHARACTER SET
;

The database name is optional. The character set name should be specified without quotes, for example:

ALTER DATABASE CHARACTER SET WE8ISO8859P1;

To change the database character set, perform the following steps. Not all
of them are absolutely necessary, but they are highly recommended:

SQL> CONN / AS SYSDBA
SQL> SHUTDOWN IMMEDIATE;
Take offline backup from your database
SQL> STARTUP MOUNT;
SQL> ALTER SYSTEM ENABLE RESTRICED SESSION;
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
SQL> ALTER DATABASE OPEN;
SQL> ALTER DATABASE CHARACTER SET ;
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP;

To change the national character set, replace the ALTER DATABASE CHARACTER
SET statement with ALTER
DATABASE NATIONAL CHARACTER SET. You can issue both commands together if
desired.

Thursday, March 25, 2010

Partitioning A Huge Table

1-Rename the current table from TBL_SE_XREF to TBL_SE_XREF_OLD


2-Create a partitioned table:
-----------------------------
CREATE table TBL_SE_XREF
(
ID NUMBER,
G_ID NUMBER,
COM_ID NUMBER,
SE_PN VARCHAR2(256 BYTE),
SE_MAN_ID NUMBER(10),
SE_TYPE_ID NUMBER,
COMMENTS VARCHAR2(256 BYTE),
SOURCE VARCHAR2(50 BYTE),
NAN_PARTNUM VARCHAR2(256 BYTE),
INSERT_DATE DATE,
REPLACEMENT NUMBER
)
PARTITION BY HASH (SE_MAN_ID,NAN_PARTNUM)
(PARTITION P1_TBL_SE_XREF TABLESPACE XREF_PART01,
PARTITION P2_TBL_SE_XREF TABLESPACE XREF_PART02,
PARTITION P3_TBL_SE_XREF TABLESPACE XREF_PART03,
PARTITION P4_TBL_SE_XREF TABLESPACE XREF_PART04,
PARTITION P5_TBL_SE_XREF TABLESPACE XREF_PART05,
PARTITION P6_TBL_SE_XREF TABLESPACE XREF_PART06,
PARTITION P7_TBL_SE_XREF TABLESPACE XREF_PART07,
PARTITION P8_TBL_SE_XREF TABLESPACE XREF_PART08,
PARTITION P9_TBL_SE_XREF TABLESPACE XREF_PART09,
PARTITION P10_TBL_SE_XREF TABLESPACE XREF_PART10)
ENABLE ROW MOVEMENT;


3-insert data from TBL_SE_XREF_OLD to TBL_SE_XREF:
--------------------------------------------------
insert into TBL_SE_XREF
select * from TBL_SE_XREF_OLD;
commit;


4-Create Partitioned Index on the table TBL_SE_XREF:
----------------------------------------------------

CREATE INDEX MANID_NANPART_IDX ON TBL_SE_XREF
(SE_MAN_ID, NAN_PARTNUM)
NOLOGGING
LOCAL (
PARTITION P1_TBL_SE_XREF
TABLESPACE SE_PART_IDX_1,
PARTITION P2_TBL_SE_XREF
TABLESPACE SE_PART_IDX_2,
PARTITION P3_TBL_SE_XREF
TABLESPACE SE_PART_IDX_3,
PARTITION P4_TBL_SE_XREF
TABLESPACE SE_PART_IDX_4,
PARTITION P5_TBL_SE_XREF
TABLESPACE SE_PART_IDX_5,
PARTITION P6_TBL_SE_XREF
TABLESPACE SE_PART_IDX_6,
PARTITION P7_TBL_SE_XREF
TABLESPACE SE_PART_IDX_7,
PARTITION P8_TBL_SE_XREF
TABLESPACE SE_PART_IDX_8,
PARTITION P9_TBL_SE_XREF
TABLESPACE SE_PART_IDX_9,
PARTITION P10_TBL_SE_XREF
TABLESPACE SE_PART_IDX_10
)
NOPARALLEL
COMPUTE STATISTICS;

5-you can now drop TBL_SE_XREF_OLD table

Monday, December 14, 2009

Rename Listener Log File While The Listener Is Running

1-Open Command Prompt and type "lsnrctl"
D:\>lsnrctl
this will open the Listener Control Command Line

2-From Listener Control Command Line type "set log_status off"
LSNRCTL> set log_status off

3-Rename Listener Log File to something else

4-From Listener Control Command Line type "set log_status on"
LSNRCTL> set log_status on

Sunday, April 12, 2009

Add New Controlfile To Database

1-conn / as sysdba
2-create pfile='d:\pfile.txt' from spfile;
3-shutdown immediate
4-copy one of the controlfiles in your database with another name like control04.ctl
5-edit the pfile pfile.txt and add the new created controlfile (control04.ctl)
6-startup pfile='d:\pfile.txt'
7-create spfile from pfile='d:\pfile.txt';
8-shutdown immediate
9-startup

database will start with the new created controlfile

Wednesday, November 21, 2007

Checkpoint not complete

The "checkpoint not complete" messages are generated because the logs are switching so fast that the checkpoint associated with the log switch isn't complete. During that time, Oracle's LGWR process has filled up the other redo log groups and is now waiting for the first checkpoint to successfully execute. It can't overwrite the contents of the redo log until the information covered by that log is flushed to the data files. Oracle will stop processing until the checkpoint completes successfully.

Performance can be improved by increasing the log sizes so that logs switches occur at the recommended interval of 15 to 30 minutes. Identify the current size of the redo log members from V$LOG, record the number of log switches per hour and increase the size of the log to allow Oracle to switch at the recommended rate of one switch per 15 to 30 minutes.
For example, if the database log size is 1 megabyte and you are switching logs every 1 minute, you will need to increase the log size to 30 megabytes in size to allow it to switch every 30 minutes.

The problem is that many applications have workloads that vary throughout each 24-hour time-period. In addition, application-processing workloads may vary according to the days of the calendar month. Month-end and mid-month processing may increase the number of changes occurring in the database. This higher level of activity may cause the redo logs to be filled much more quickly than during off-peak times. The DBA must make sure that the on-line redo logs don't switch too often during periods of high activity and switch often enough during times of low processing workloads. In addition, administrators must also be concerned about how the size of the online redo logs affect instance recovery. The less checkpoints taken, the longer instance recovery will take.

Sunday, November 18, 2007

How To Shrink Undo Tablespace

If you want to shrink the Undo Tablespace ,you will shrink the Datafile to free disk space.

1-you will need to create another Tablespace with a smaller Datafile size
SQL> create undo tablespace UNDO_TBS1
datafile 'd:\oracle\oradata\orcl\undorbs1.dbf' size 100m;

2-Let the new tablespace to be the default Undo Tablespace
SQL> alter system set undo_tablespace=UNDO_TBS1;

3-Check that there's no active Undo Segments in your Database using this query
SQL> SELECT a.name,b.status FROM v$rollname a, v$rollstat b WHERE a.name IN ( SELECT segment_name FROM dba_segments WHERE tablespace_name = 'UNDOTBS0') AND a.usn = b.usn;
if the query returns no rows then there's no active Undo segments

4- Drop the old Tablespace
SQL> drop tablespace UNDO_TBS0 including contents.

Thursday, November 15, 2007

Change Windows Hostname and Keep Oracle 10g Running

Step 1 – Create Hosts Entry for Old Hostname add entry to the file WINNT\system32\drivers\etc\hosts
Step 2 – Uninstall Enterprise Manager Console emca -deconfig dbcontrol db -repos drop
Step 3 – Stop All Oracle Services
Step 4 – Update listener.ora and tnsnames.ora with the new Hostname
Step 5 – Rename Host and Restart DELETE THE OLD SERVICE FROM THE REGISTRY
Step 6 – Ensure Oracle Instance is running
Step 7 - Start windows to remove Enterprise Manager service
Step 8 – Reinstall Enterprise Manager Console emca -config dbcontrol db -repos create
Step 9 – Validate Enterprise Manager Console Installation http://:1158/em