Oracle DBA FAQ
How to check if oracle instance is leaking memory
1] Use session statistics (to measure) The Oracle server maintains statistics that record the PGA and UGA memory consumption on a per session basis. If you suspect a memory leak then use SQL similar to that presented below to verify the amount of memory in use and re-issue it several times and monitor to confirm that memory is indeed growing. sql> select sid, substr(name,1,30), value , value/(1024*1024) "MB" from v$statname a, v$sesstat b where a.statistic# = b.statistic# and name like '%a memory' order by sid, name; Note that if you do not see one of these statistics increase yet the process still seems to increase in memory consumption from the operating system standpoint then perhaps the problem lies with the your application code where memory is allocated but not released/ 2] You may also experience ora-4031 / ora-4030 errors running your sql statements. Please note that getting these errors does not automatically indicate that you have a memory leak, because you may not have configured your system appropriately. Remember that old l0ogic truth - a bus is a motor vehicle, but not all motor vehicles are buses. --additional Info select b.sid, substr(name,1,30), value , value/(1024*1024) "MB", c.serial#,c.status,c.username,c.schemaname,c.osuser,c.machine,c.terminal,c.program,c.module,state,logon_time from v$statname a, v$sesstat b,v$session c where a.statistic# = b.statistic# and name like '%a memory' and b.sid=c.sid and osuser!='oracle' order by status,MB desc,sid, name; If you want to the SQL also join v$sqlarea table- This will give you how much memory is utilized by package/procedure and a simple/complex SQL text select b.sid, substr(name,1,30), value , value/(1024*1024) "MB", s.serial#,s.sid ssid, s.status,s.username,s.schemaname,s.osuser,s.machine,s.terminal,s.program,s.module,state,logon_time,substr(p.spid,1,8) spid, substr(sa.sql_text,1,2000) txt from v$statname a, v$sesstat b,v$session s, v$process p ,v$sqlarea sa where a.statistic# = b.statistic# and name like '%a memory' and b.sid=s.sid and osuser!='oracle' and p.addr = s.paddr and s.sql_address = sa.address(+) and s.sql_hash_value = sa.hash_value(+) order by status,MB desc,sid, name; |
Archive location filled - How to set the archive log location to new location?
conn "sys/pass as sysdba" show parameter log_archive_dest alter system set log_archive_dest_1="new loc" or alter system set db_recovery_file_dest="new loc"; alter system set log_archive_dest_1='location=/backup/DUPRPTDB/archive'; alter system switch logfile |
How to tar and untar files in UNIX?
To pack and compress (one step at a time): gzip packed_files.tar To pack and compress all at once: To create a tar from a directory and its subdirectories: To unpack tar files, use the following commands: To decompress and unpack one step at a time: To decompress and unpack all at once: To list the contents of a tar file, use the following command: Compression options To pack and compress: using bzip2: using compress: using some other arbitrary compression utility that works as a filter: To uncompress and unpack: Historical tricks tar -cf - one_directory | (cd another_directory && tar -xpf - ) |
How Network Address Translation Works?
There is a range for each of the three classes of IP addresses used for networking: * Range 1: Class A - 10.0.0.0 through 10.255.255.255 * Range 2: Class B - 172.16.0.0 through 172.31.255.255 * Range 3: Class C - 192.168.0.0 through 192.168.255.255 Although
each range is in a different class, your are not required to use any
particular range for your internal network. It is a good practice,
though, because it greatly diminishes the chance of an IP address
conflict. Multi-homing As businesses rely
more and more on the Internet, having multiple points of connection to
the Internet is fast becoming an integral part of their network
strategy. Multiple connections, known as multi-homing, reduces the
chance of a potentially catastrophic shutdown if one of the connections
should fail. In addition to maintaining a reliable
connection, multi-homing allows a company to perform load-balancing by
lowering the number of computers connecting to the Internet through any
single connection. Distributing the load through multiple connections
optimizes the performance and can significantly decrease wait times. Multi-homed
networks are often connected to several different ISPs (Internet
Service Providers). Each ISP assigns an IP address (or range of IP
addresses) to the company. Routers use BGP (Border Gateway Protocol), a
part of the TCP/IP protocol suite, to route between networks using
different protocols. In a multi-homed network, the router utilizes IBGP
(Internal Border Gateway Protocol) on the stub domain side, and EBGP
(External Border Gateway Protocol) to communicate with other routers. |
What is the Advantage/Disadvantage to have mutiple database in a same host/or different host INSTEAD of having mutiple schema's in a SINGLE database?
a.) Multiple
databases under a single binary and host require more resources and
could lead to contention for these resources, which may pique
performance problems, if you don't have enough resources on the host to
distribute evenly or share.
b.) Multiple databases, under single binary and host translate to a single point of failure. If you need to apply a patch, for example, or there is a problem with the binary. c.) Multiple databases with multiple binaries under a single or multiple host would require more planning, administration, maintenance, resources etc and could lead to performance problems if you don't have enough resources to distribute evenly. However, this guide against single point of failure in case you have problem with a single binary or host. d.) Multiple schemas in a single database, obviously under a single binary and host, makes management and administration tasks relatively cheaper and easier and would accord the database or schemas with enough resources which may translate to performance improvements. e.) Multiple schemas in a single database however translate to a single point of failure, that is, if a schema in the database has problems that means the rest of the schemas, by default, would be affected. To perform restore and recovery on a single schema, would most likely affect the rest of the schemas depending on the type of backup you have. f.) Multiple schemas in a single database could save you on Oracle licences and also makes it easier to have a RAC-enabled environment which will translate your application to Higher Availability. All in all, choosing the best method can't be made in silo, and will require bringing the architecture, the application(s), project scope, budget and business needs into the full picture. |
What are the various ways to manage a Data Guard environment
Oracle provides three ways to manage a Data Guard environment: 1. SQL*Plus and SQL Statements
2. Data Guard Broker GUI Interface (Data Guard Manager)
3. Data Guard Broker Command-Line Interface (CLI)
|
What is the main difference between physical and logical standby databases
The main difference between
physical and logical standby databases is the manner in which log apply
services apply the archived redo data. For physical standby databases, Data Guard uses Redo Apply technology, which applies redo data on the standby database using standard recovery techniques of an Oracle database. For logical standby databases, Data Guard uses SQL Apply technology, which first transforms the received redo data into SQL statements and then executes the generated SQL statements on the logical standby database |
What are Data Guard Protection Modes?
In
Oracle 10g we see an exciting new approach to Data Guard management
whereby we write the current redo log to a "standby redo log", allowing
complete recovery in cases of catastrophic instance failure. Maximum Protection—This
mode offers the highest level of data protection. Data is synchronously
transmitted to the standby database from the primary database and
transactions are not committed on the primary database unless the redo
data is available on at least one standby database configured in this
mode. If the last standby database configured in this mode becomes
unavailable, processing stops on the primary database. This mode ensures
no-data-loss. Maximum Availability—This mode is similar to the maximum protection mode, including zero data loss. However, if a standby database becomes unavailable (for example, because of network connectivity problems), processing continues on the primary database. When the fault is corrected, the standby database is automatically resynchronized with the primary database. Maximum Performance—This mode offers slightly less data protection on the primary database, but higher performance than maximum availability mode. In this mode, as the primary database processes transactions, redo data is asynchronously shipped to the standby database. The commit operation of the primary database does not wait for the standby database to acknowledge receipt of redo data before completing write operations on the primary database. If any standby destination becomes unavailable, processing continues on the primary database and there is little effect on primary database performance. |
How DBA can generate static HTML pages from SQL*Plus
One can generate static HTML pages from SQL*Plus
(8.1.6 and above) by setting the MARKUP option to HTML ON. This can be
done by specifying -MARKUP "HTML ON" from command line, or with the "SET
MARKUP HTML ON" command. Look at this example SQL Script: set markup HTML on spool index.html select * from tab; spool off set markup HTML off |
How can DBA pass operating system variables to sqlplus?
One can pass operating system variables to sqlplus using this syntax: select '&1' from &2;sqlplus username/password @cmdfile.sql var1 var2 var3 Parameter var1 will be mapped to SQL*Plus variable &1, var2 to &2, etc. Look at this example: sqlplus scott/tiger @x.sql '"test parameter"' dual Where x.sql consists of: exit 5; |