|
|
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/gmp-4.1.4-10.el5.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/readline-5.1-1.1.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/python-2.4.3-19.el5.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/libxml2-2.6.26-2.1.2.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/libxml2-python-2.6.26-2.1.2.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/expat-1.95.8-8.2.1.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/sqlite-3.3.6-2.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/python-sqlite-1.1.7-1.2.1.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/elfutils-0.125-3.el5.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/rpm-4.4.2-47.el5.i386.rpm --force
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/rpm-libs-4.4.2-47.el5.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/m2crypto-0.16-6.el5.1.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/rpm-python-4.4.2-47.el5.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/python-urlgrabber-3.1.0-2.noarch.rpm
rpm -uVh http://mirror.centos.org/centos/5/os/i386/CentOS/yum-metadata-parser-1.0-8.fc6.i386.rpm
rpm -Uvh http://mirror.centos.org/centos/5/os/i386/CentOS/yum-3.0.5-1.el5.centos.5.noarch.rpm
yum -y update
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/gmp-4.1.4-3.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/readline-4.3-13.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/python-2.3.4-14.4.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/libxml2-2.6.16-10.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/libxml2-python-2.6.16-10.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/expat-1.95.7-4.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/python-elementtree-1.2.6-5.el4.centos.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/python-sqlite-1.1.7-1.2.1.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/elfutils-0.97.1-4.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/rpm-python-4.3.3-22_nonptl.i386.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/python-urlgrabber-2.9.8-2.noarch.rpm
rpm -Uvh http://mirror.centos.org/centos-4/4/os/i386/CentOS/RPMS/yum-2.4.3-3.el4.centos.noarch.rpm
yum -y update
$ORACLE_HOME/dbs — hc_<sid>.dat
HC stands for a health check monitoring. It contains information used to monitor the instance health, and to determine why it went down if the instance isn’t up. The file will be recreated at every instance startup. You don’t need to back it up.
$ORACLE_HOME/dbs — lk_<sid>
It’s a lock file which means that the Oracle shared memory segment is locked by a process or processes.if you shut down you db and this file still exists, you won’t be able to restart the db until the file is gone.And an Oracle process(s) is not releasing it’s lock on shared memory, not really normal behaviour if the file lock doesn’t clean up by itself, then you might have to run ipcs to see what s being held.
$ORACLE_HOME/dbs — snapcf_<sid>
Oracle takes snapshot and store it in snapcf_SID.f file.The faster way to restore control file is restoring from this snapshot than rman and cold backup restoration controlfile from this snap shot restore controlfile, restores the snapshot controlfile (all versions) restore controlfile from autobackup (9i and higher) takes the autobackup controlfile.
1.Install Oracle RDBMS Server Software on destination host.
2.Patch it to same release which is installed on source host.
3.Copy Datafile Backups , Archivelog Backups , Controlfile backup and spfile backup on to destination host ( test2 ) to same location as source host ( test1 )
4.Restore spfile from autobackup using following command.
$export ORACLE_SID=DEV
$export ORACLE_HOME=/apps1/oracle01/u11/app/oracle/product/10.2.0/db_1
$rman target / nocatalog
RMAN>set DBID=00000000 ( You can get DB ID for source db by querying v$database view )
RMAN>startup nomount;
RMAN>restore spfile from ‘/var/backups1/DEV/autobackup/2009_10_04/o1_mf_s_699336061_5dj3zg47_.bkp’;
Spfile will be restored in $ORACLE_HOME/dbs folder.
RMAN>shutdown immediate;
$sqlplus / as sysdba
SQL>create pfile from spfile;
pfile will be restored in $ORACLE_HOME/dbs folder.
Open pfile ( initDEV.ora ) and modify adump,bdump,cdump,udump and db_recovery_file_dest parameter.Also modify control_files parameter according to new path.
$sqlplus / as sysdba
SQL>startup nomount pfile=’$ORACLE_HOME/dbs/initDEV.ora’
SQL>create spfile from pfile;
SQL>startup nomount force;
5.Restore controlfile from autobackup using following command.
$rman target / nocatalog
RMAN>set DBID=00000000
RMAN>restore controlfile from ‘/var/backups1/DEV/autobackup/2009_10_04/o1_mf_s_699336061_5dj3zg47_.bkp’;
RMAN>alter database mount;
6.Restore datafiles.
If the directory structure is different than you need to use “set newname” command to change file name location else its not required.
Create RMAN script for restoring DB.
RUN
{
SET NEWNAME FOR DATAFILE 1 TO ‘/apps1/DEV/system01.dbf’;
SET NEWNAME FOR DATAFILE 2 TO ‘/apps1/DEV/undotbs01.dbf’;
SET NEWNAME FOR DATAFILE 3 TO ‘/apps1/DEV/sysaux01.dbf’;
SET NEWNAME FOR DATAFILE 4 TO ‘/apps1/DEV/users01.dbf’;
SET NEWNAME FOR DATAFILE 5 TO ‘/apps1/DEV/cs_dev_owner_01.dbf’;
SET NEWNAME FOR DATAFILE 6 TO ‘/apps1/DEV/admin_01.dbf’;
SET UNTIL TIME = “to_date(‘2019-11-03:41:54:00′,’YYYY-MM-DD:HH24:MI:SS’)”;
RESTORE DATABASE;
SWITCH DATAFILE ALL;
}
EXIT
7.Recover database to point in time.
$rman target / nocatalog
RMAN>recover database until time “to_date(”2019-11-03:41:54:00”,’YYYY-MM-DD:HH24:MI:SS’)”;
8.Rename redo logfile name before opening DB with resetlogs option.
$sqlplus / as sysdba
SQL>alter database rename file ‘/apps1/u14/oradata/DEV/redo01a.log’ to ‘/apps1/DEV/redo01a.log’;
Do same for all the redo files.( run select member from v$logfile to get list of redo logs )
9.Open DB with resetlogs option.
$sqlplus / as sysdba
SQL>alter database open resetlogs;
10.Create TEMP tablespace.
$sqlplus / as sysdba
SQL>create temporary tablespace temp1 tempfile ‘/apps1/DEV/temp.dbf’ size 10M;
SQL>alter database default temporary tablespace temp1;
step 1 : Create procedure
=========================
create or replace procedure ssas_externalalertlog(in_instance in varchar2) as
path_bdump varchar2(4000);
name_alert varchar2(100) := 'alert_' || in_instance || '.log';
begin
select
value into path_bdump
from
sys.v_$parameter
where
name = 'background_dump_dest';
--select
--'alert_' || value || '.log' into name_alert
--from
--sys.v_$parameter
--where
--name = 'db_name';
execute immediate 'create or replace directory ssas_BDUMP as ''' ||
path_bdump || '''';
execute immediate
'create table ssas_ALERTLOG ' ||
' (MSG_line varchar2(4000) ) ' ||
' organization external ' ||
' (type oracle_loader ' ||
' default directory ssas_BDUMP ' ||
' access parameters ( ' ||
' records delimited by newline ' ||
' nobadfile ' ||
' nologfile ' ||
' nodiscardfile ' ||
' skip 0 ' ||
' READSIZE 1048576 ' ||
' FIELDS LDRTRIM ' ||
' REJECT ROWS WITH ALL NULL FIELDS ' ||
' (MSG_LINE (1:1000) CHAR(1000)) ' ||
' ) ' ||
' location (''' || name_alert || ''') )' ||
' reject limit unlimited ' ||
' noparallel nomonitoring ';
end;
/
step 2 : execute the procedure
==============================
execute ssas_externalalertlog('ORACLE_SID')
step 3 : issue this sql statement
=================================
col lineno noprint
col ora_error noprint
col msg_line format a132
set pages 0 lines 300 trimspool on trim on
alter session set nls_date_format='dd/mm/yyyy hh24:mi:ss';
alter session set sql_trace=false;
break on thedate
prompt
prompt ERROR IN ALERT LOG FILE - LAST 3 DAYS
prompt =====================================
select "LINENO","THEDATE","ORA_ERROR","MSG_LINE"
from (
select *
from (
select lineno,
msg_line,
thedate,
max( case when (ora_error like 'ORA-%' or ora_error like 'PLS-%')
then rtrim(substr(ora_error,1,instr(ora_error,' ')-1),':')
else null
end ) over (partition by thedate) ora_error
from (
select lineno,
msg_line,
max(thedate) over (order by lineno) thedate,
lead(msg_line) over (order by lineno) ora_error
from (
select rownum lineno,
substr( msg_line, 1, 132 ) msg_line,
case when msg_line like '___ ___ __ __:__:__ ____'
then to_date( msg_line, 'Dy Mon DD hh24:mi:ss yyyy' )
else null
end thedate
from ssas_alertlog
)
)
)
)
where ora_error is not null
and thedate >= (trunc(sysdate) - 3)
order by thedate
/
step 4 : drop the external table
================================
drop table ssas_alertlog
/
SELECT * FROM (
SELECT * FROM (
SELECT TO_CHAR(FIRST_TIME, 'DD/MM') AS "DAY"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '00', 1, 0)), '99') "00:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '01', 1, 0)), '99') "01:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '02', 1, 0)), '99') "02:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '03', 1, 0)), '99') "03:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '04', 1, 0)), '99') "04:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '05', 1, 0)), '99') "05:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '06', 1, 0)), '99') "06:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '07', 1, 0)), '99') "07:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '08', 1, 0)), '99') "08:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '09', 1, 0)), '99') "09:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '10', 1, 0)), '99') "10:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '11', 1, 0)), '99') "11:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '12', 1, 0)), '99') "12:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '13', 1, 0)), '99') "13:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '14', 1, 0)), '99') "14:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '15', 1, 0)), '99') "15:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '16', 1, 0)), '99') "16:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '17', 1, 0)), '99') "17:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '18', 1, 0)), '99') "18:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '19', 1, 0)), '99') "19:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '20', 1, 0)), '99') "20:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '21', 1, 0)), '99') "21:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '22', 1, 0)), '99') "22:00"
, TO_NUMBER(SUM(DECODE(TO_CHAR(FIRST_TIME, 'HH24'), '23', 1, 0)), '99') "23:00"
FROM V$LOG_HISTORY
WHERE extract(year FROM FIRST_TIME) = extract(year FROM sysdate)
GROUP BY TO_CHAR(FIRST_TIME, 'DD/MM')
) ORDER BY TO_DATE(extract(year FROM sysdate) || DAY, 'YYYY DD/MM') DESC
) WHERE ROWNUM < 8
/
DDL commands require exclusive locks on internal structures. If these locks are not available the commands return with an "ORA-00054: resource busy" error message. This can be especially frustrating when trying to modify objects that are accessed frequently. To get round this Oracle 11g includes the DDL_LOCK_TIMEOUT parameter, which can be set at instance or session level using the ALTER SYSTEM and ALTER SESSION commands respectively.
The DDL_LOCK_TIMEOUT parameter indicates the number of seconds a DDL command should wait for the locks to become available before throwing the resource busy error message. The default value is zero. To see it in action, create a new table and insert a row, but don’t commit the insert.
CREATE TABLE lock_tab (
id NUMBER
);
INSERT INTO lock_tab VALUES (1);
Leave this session alone and in a new session, set the DDL_LOCK_TIMEOUT at session level to a non-zero value and attempt to add a column to the table.
ALTER SESSION SET ddl_lock_timeout=30;
ALTER TABLE lock_tab ADD (
description VARCHAR2(50)
);
The session will wait for 30 seconds before failing.
ALTER TABLE lock_tab ADD (
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
If we repeat the ALTER TABLE command and commit the insert in the first session within 30 seconds, the ALTER TABLE will return a successful message.
ALTER TABLE lock_tab ADD (
description VARCHAR2(50)
);
Table altered.
SQL>
Often DBAs are needed to import the data of one table of first database to another table of another database.
With 10G DBAs had to export the table and import it to destination DB then rename the table.
But with 11G you can simply REMAP the table to new table name of destination Database.
As for Example,
Source DB : CHICAGO
$sqlplus dev/oracle@CHICAGO
SQL>create table dev as select rownum num from dual connect by rownum <= 1000000;
Check the size of table after its creating using following SQL.
col segment_name format a20 select segment_name,bytes “SIZE_BYTES”,ceil(bytes / 1024 / 1024) “SIZE_MB” from dba_segments where segment_name = ‘DEV’;
SEGMENT_NAME ?SIZE_BYTES? ?SIZE_MB? ——————– ———— ———- DEV 13631488 13
- Export DEV table from DEV schema.
expdp userid=dev/oracle dumpfile=DATA_PUMP_DIR:exp.dmp tables=dev reuse_dumpfiles=y
Reuse_dumpfiles will re-create the dumpfile if the same file exists.This is mostly helpful in case of ASM where you need remove the dumpfile from SQLPLUS if you don’t have access to ASMCMD.
Export: Release 11.2.0.1.0 – Production on Tue Sep 8 12:01:23 2009
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "DEV"."SYS_EXPORT_TABLE_01": userid=dev/******** dumpfile=DATA_PUMP_DIR:exp.dmp tables=dev reuse_dumpfiles=y Estimate in progress using BLOCKS method… Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 13 MB Processing object type TABLE_EXPORT/TABLE/TABLE . . exported "DEV"."DEV" 8.568 MB 1000000 rows Master table "DEV"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for DEV.SYS_EXPORT_TABLE_01 is: /u01/app/dev/admin/CHICAGO/dpdump/exp.dmp Job "DEV"."SYS_EXPORT_TABLE_01" successfully completed at 12:01:33
Destination DB : DUP
- Import the Dev table to Het table.Please note that Het table must not exists before you import it.
impdp userid=dev/oracle dumpfile=DATA_PUMP_DIR:exp.dmp remap_table=dev.dev:het
Import: Release 11.2.0.1.0 – Production on Tue Sep 8 12:07:33 2009
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "DEV"."SYS_IMPORT_FULL_01" successfully loaded/unloaded Starting "DEV"."SYS_IMPORT_FULL_01": userid=dev/******** dumpfile=DATA_PUMP_DIR:exp.dmp remap_table=dev.dev:het Processing object type TABLE_EXPORT/TABLE/TABLE Processing object type TABLE_EXPORT/TABLE/TABLE_DATA . . imported "DEV"."HET" 8.568 MB 1000000 rows Job "DEV"."SYS_IMPORT_FULL_01" successfully completed at 12:07:38
Notice that the REMAP_TABLE option is designated as
[schema.]old_tablename[.partition]:new_tablename.
- Check Het table created or not.
dev@shetal:~$ sqlplus dev/oracle@DUP
SQL*Plus: Release 11.2.0.1.0 Production on Tue Sep 8 12:08:10 2009
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> desc het Name Null? Type —————————————– ——– —————————- NUM NUMBER
SQL> select count(*) from het;
COUNT(*) ———- 1000000
Enjoy Madi…
SQL>create table dev as select rownum num from dual connect by rownum <= 1000000;
Check the size of table after its creating using following SQL.
col segment_name format a20
select segment_name
, bytes “SIZE_BYTES”
, ceil(bytes / 1024 / 1024) “SIZE_MB”
from dba_segments
where segment_name like ‘DEV’
/
SEGMENT_NAME SIZE_BYTES SIZE_MB
——————– ———- ———-
DEV 12582912 12
|
|
Popular Posts