Skip to main content

RMAN tips

Enable backup mode for all database files

1- Enable backup on entire database :


SQL> alter database begin backup;

Database altered.


2- Check that all file id status be in "ACTIVE"


SQL> select * from v$backup;

     FILE# STATUS                CHANGE# TIME
---------- ------------------ ---------- ---------
         1 ACTIVE             2.6814E+11 22-SEP-15
         2 ACTIVE             2.6814E+11 22-SEP-15
         3 ACTIVE             2.6814E+11 22-SEP-15
         4 ACTIVE             2.6814E+11 22-SEP-15
         5 ACTIVE             2.6814E+11 22-SEP-15
         6 ACTIVE             2.6814E+11 22-SEP-15
         7 ACTIVE             2.6814E+11 22-SEP-15
         8 ACTIVE             2.6814E+11 22-SEP-15
         9 ACTIVE             2.6814E+11 22-SEP-15
        10 ACTIVE             2.6814E+11 22-SEP-15
        11 ACTIVE             2.6814E+11 22-SEP-15


3- For disable backup on the entire database :


SQL> alter database end backup;

Database altered.


4- Check that all file id status be in "NOT ACTIVE".



SQL> select * from v$backup;

     FILE# STATUS                CHANGE# TIME
---------- ------------------ ---------- ---------
         1 NOT ACTIVE         2.6814E+11 22-SEP-15
         2 NOT ACTIVE         2.6814E+11 22-SEP-15
         3 NOT ACTIVE         2.6814E+11 22-SEP-15
         4 NOT ACTIVE         2.6814E+11 22-SEP-15
         5 NOT ACTIVE         2.6814E+11 22-SEP-15
         6 NOT ACTIVE         2.6814E+11 22-SEP-15
         7 NOT ACTIVE         2.6814E+11 22-SEP-15
         8 NOT ACTIVE         2.6814E+11 22-SEP-15
         9 NOT ACTIVE         2.6814E+11 22-SEP-15
        10 NOT ACTIVE         2.6814E+11 22-SEP-15
        11 NOT ACTIVE         2.6814E+11 22-SEP-15


Enable backup mode for tablespace



1- Check the tablespace that you want to set the backup mode.


set linesize 300
set pagesize 300
col FILE_NAME format a60
col file_id format 999999
col tablespace_name  format a25
select FILE_NAME,file_id,tablespace_name
from dba_data_files
where tablespace_name ='UNDOTBS1'
group by FILE_NAME,file_id,tablespace_name;


FILE_NAME                                                    FILE_ID TABLESPACE_NAME
------------------------------------------------------------ ------- -------------------------
/data1/oracle11/orapae11/undotbs01.dbf                             3 UNDOTBS1




2- In this case, we will set the UNDOTBS1 tablespace in backup mode :


SQL> alter  tablespace UNDOTBS1 begin backup;

Tablespace altered.


3- Check the status for all tablespace :


select *
from v$backup
where status='ACTIVE';

     FILE# STATUS                CHANGE# TIME
---------- ------------------ ---------- ---------
         3 ACTIVE             2.6814E+11 22-SEP-15


See that file_id 3 that belongs to UNDOTBS1 is in backup mode.


4- Disable the tablespace of backup mode.


SQL> alter tablespace UNDOTBS1  end backup;

Tablespace altered.


5- Finally check the status of all tablespaces.


select *
from v$backup
where status='ACTIVE';


no rows selected


Disable database archive log


1- shutdown database


SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

2- mount database


SQL> startup mount
ORACLE instance started.

Total System Global Area 6499344384 bytes
Fixed Size                  2171376 bytes
Variable Size            3271564816 bytes
Database Buffers         3204448256 bytes
Redo Buffers               21159936 bytes
Database mounted.


3- Disable archive log mode.


SQL> alter database noarchivelog;

Database altered.


4- Open the database.


SQL> alter database open;

Database altered.


5- Disable the automatic archiving.


SQL> alter system archive log stop;

System altered.

6- Check the archive log deactivation.


SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /oracle/TEST/oraarch/
Oldest online log sequence     1
Current log sequence           4


Enable database archive log


1- Check if log_archive_dest_1 parameter does have a location:


show parameter show parameter log_archive_dest_1

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1                   string      location=/oracle/TEST/oraarch/


2- shutdown immediate


SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.


3- Mount the database.


SQL> startup mount
ORACLE instance started.

Total System Global Area 6499344384 bytes
Fixed Size                  2171376 bytes
Variable Size            3271564816 bytes
Database Buffers         3204448256 bytes
Redo Buffers               21159936 bytes
Database mounted.


4- Enable archive log mode.


SQL> alter database noarchivelog;

Database altered.


5- Open the database.


SQL> alter database open;


Database altered.


6- Active the automatic archiving


SQL> alter system archive log start;

System altered.

7- Check if archive log is enabled.


How to identify all the Corrupted Objects in the Database with RMAN


1- Clean the v$backup_corruption and v$copy_corruption views.


SQL> execute dbms_backup_restore.resetCfileSection(17);

PL/SQL procedure successfully completed.

SQL> execute dbms_backup_restore.resetCfileSection(18);

PL/SQL procedure successfully completed.



2- Export environtment variables (ORACLE_HOME, ORACLE_SID and PATH)



3- Perform rman scripts (This command may take many hours, depending on the speed of the hardware and the database volume)



run {
allocate channel d1 type disk;
allocate channel d2 type disk;
backup check logical validate database;
release channel d1;
release channel d2;


V$DATABASE_BLOCK_CORRUPTION is updated with the corrupt blocks.  In 11g RMAN generates a trace file with the details of the corruption description.  Example:

RMAN VALIDATE screen output:

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
6    FAILED 0              501          640             1950088  
  File Name: /oracle/dbs/users.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       9              9             
  Index      0              0              
  Other      0              130            

validate found one or more corrupt blocks
See trace file /oracle/log/diag/rdbms/orcl/orcl/trace/orcl_ora_28424.trc for details
Finished validate at <Date>



4- The trace file has output with the corruption description. This is an example for two of the corrupt blocks; one Physical corrupt block (file 6 block 9) one Logical corrupt block (file 6 block 10) respectively.



Corrupt block relative dba: 0x01000009 (file 4, block 9)
Bad check value found during validation
Data in bad block:
 type: 16 format: 2 rdba: 0x01000009
 last change scn: 0x0000.00000000 seq: 0xff flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x000010ff
 check value in block header: 0xb4e0
 computed block checksum: 0xa800
Reread of blocknum=9, file=/oracle/dbs/users.dbf found same corrupt data

Block Checking: DBA = 25165834, Block Type = KTB-managed data block
data header at 0x2b2deb49e07c
kdbchk: fsbo(144) wrong, (hsz 78)
Error backing up file 6, block 10: logical corruption


5- Corrupt blocks are listed in the view V$DATABASE_BLOCK_CORRUPTION:


SQL> select * from V$DATABASE_BLOCK_CORRUPTION;

          FILE#          BLOCK#          BLOCKS CORRUPTION_CHANGE# CORRUPTIO
--------------- --------------- --------------- ------------------ ---------
              6              10               1      8183236781662 LOGICAL
              6              42               1                  0 FRACTURED
              6              34               2                  0 CHECKSUM
              6              50               1      8183236781952 LOGICAL
              6              26               4                  0 FRACTURED


6- The following query will identify the corrupts segments.


sqlplus / as sysdba


set pagesize 2000
set linesize 280
SELECT e.owner, e.segment_type, e.segment_name, e.partition_name, c.file#
     , greatest(e.block_id, c.block#) corr_start_block#
     , least(e.block_id+e.blocks-1, c.block#+c.blocks-1) corr_end_block#
     , least(e.block_id+e.blocks-1, c.block#+c.blocks-1)
       - greatest(e.block_id, c.block#) + 1 blocks_corrupted
     , corruption_type description
  FROM dba_extents e, v$database_block_corruption c
 WHERE e.file_id = c.file#
   AND e.block_id <= c.block# + c.blocks - 1
   AND e.block_id + e.blocks - 1 >= c.block#
UNION
SELECT s.owner, s.segment_type, s.segment_name, s.partition_name, c.file#
     , header_block corr_start_block#
     , header_block corr_end_block#
     , 1 blocks_corrupted
     , corruption_type||' Segment Header' description
  FROM dba_segments s, v$database_block_corruption c
 WHERE s.header_file = c.file#
   AND s.header_block between c.block# and c.block# + c.blocks - 1
UNION
SELECT null owner, null segment_type, null segment_name, null partition_name, c.file#
     , greatest(f.block_id, c.block#) corr_start_block#
     , least(f.block_id+f.blocks-1, c.block#+c.blocks-1) corr_end_block#
     , least(f.block_id+f.blocks-1, c.block#+c.blocks-1)
       - greatest(f.block_id, c.block#) + 1 blocks_corrupted
     , 'Free Block' description
  FROM dba_free_space f, v$database_block_corruption c
 WHERE f.file_id = c.file#
   AND f.block_id <= c.block# + c.blocks - 1
   AND f.block_id + f.blocks - 1 >= c.block#
order by file#, corr_start_block#;


An output example is:
OWNER SEGMENT_TYPE       SEGMENT_NAME PARTITION_ FILE# CORR_START_BLOCK# CORR_END_BLOCK# BLOCKS_CORRUPTED DESCRIPTION
----- ------------------ ------------ ---------- ----- ----------------- --------------- ---------------- -------------
SCOTT TABLE              EMP                         6                10              10                1
SCOTT TABLE PARTITION    ORDER        ORDER_JAN      6                26              28                3
                                                     6                29              29                1 Free Block
SCOTT TABLE              BONUS                       6                34              34                1
                                                     6                35              35                1 Free Block
SCOTT TABLE              DEPT                        6                42              42                1 Segment Header
SCOTT TABLE              INVOICE                     6                50              50                1



RMAN unregister database from catalog
1- Connect to catalog database :

$ORACLE_HOME/bin/rman target dbuser/password catalog  catalog_dbuser/password_dbuser@db_catalog

2- RMAN> UNREGISTER DATABASE;


dbuser            :  Local database user.
catalog_dbuser :  Catalog database user
db_catalog     :  Database catalog.

RMAN register database in catalog database



1- Connect to catalog database :


$ORACLE_HOME/bin/rman target dbuser/password catalog  catalog_dbuser/password_dbuser@db_catalog

2- RMAN> REGISTER DATABASE;



dbuser            :  Local database user.
catalog_dbuser :  Catalog database user
db_catalog     :  Database catalog.


 Check rman status


There is several views to monitor the running jobs :

select sid,start_time,totalwork sofar, (sofar/totalwork) * 100 pct_done
from v$session_longops
where totalwork > sofar
AND opname NOT LIKE '%aggregate%'
AND opname like 'RMAN%';


select sid,spid,client_info,event,seconds_in_wait,p1, p2, p3
from v$process p, v$session s
where p.addr = s.paddr
and client_info like 'rman channel=%';


set lines 120
column sid format 9999
column spid format 99999
column client_info format a25
column event format a30
column secs format 9999
select SID, START_TIME,TOTALWORK, sofar, (sofar/totalwork) * 100 done,
sysdate + TIME_REMAINING/3600/24 end_at
from v$session_longops
where totalwork > sofar
AND opname NOT LIKE '%aggregate%'
AND opname like 'RMAN%';


Example of catalog user creation in rman



1- Create the tablespace that will use rman user.


CREATE TABLESPACE TS_RMAN DATAFILE  '/u01/oracle11/TEST/rman01.dbf' SIZE 1000M AUTOEXTEND ON NEXT 10M MAXSIZE 4G
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;


2- Create role that will use catalog user.


GRANT ALTER SESSION TO RECOVERY_CATALOG_OWNER;
GRANT CREATE CLUSTER TO RECOVERY_CATALOG_OWNER;
GRANT CREATE DATABASE LINK TO RECOVERY_CATALOG_OWNER;
GRANT CREATE PROCEDURE TO RECOVERY_CATALOG_OWNER;
GRANT CREATE SEQUENCE TO RECOVERY_CATALOG_OWNER;
GRANT CREATE SESSION TO RECOVERY_CATALOG_OWNER;
GRANT CREATE SYNONYM TO RECOVERY_CATALOG_OWNER;
GRANT CREATE TABLE TO RECOVERY_CATALOG_OWNER;
GRANT CREATE TRIGGER TO RECOVERY_CATALOG_OWNER;
GRANT CREATE VIEW TO RECOVERY_CATALOG_OWNER;

3- Create the catalog  user with the corresponding privilegies.


CREATE USER RMAN_USER
IDENTIFIED BY <password>
DEFAULT TABLESPACE TS_RMAN
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK;
 
-- 3 Roles for RMAN_USER
GRANT CONNECT TO RMAN_USER;
GRANT RECOVERY_CATALOG_OWNER TO RMAN_USER;
GRANT RESOURCE TO RMAN_USER;
ALTER USER RMAN_USER DEFAULT ROLE ALL;

-- 1 System Privilege for RMAN_USER
GRANT UNLIMITED TABLESPACE TO RMAN_USER;

-- 1 Tablespace Quota for RMAN_USER
ALTER USER RMAN_USER QUOTA UNLIMITED ON TS_RMAN;















Comments

Last Week Topics

How to break a bonded network interface red hat

1.- Bonding device called bond0 which aggregated by eth0 and eth1 # ifconfig bond0     Link encap:Ethernet  HWaddr 44:a8:42:5d:6d:5d           inet addr:192.168.1.51  Bcast:192.168.1.255  Mask:255.255.255.0           inet6 addr: fe80::5054:ff:fe4d:9004/64 Scope:Link           UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1 eth0      Link encap:Ethernet  HWaddr 44:a8:42:5d:6d:5d           UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1 eth2      Link encap:Ethernet  HWaddr 44:a8:42:5d:76:29           UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1           RX packets:6 errors:0 dropped:0 overruns:0 frame:0 # cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009) Bonding Mode: fault-tolerance (active-backup) Primary Slave: em1 (primary_reselect always) Currently Active Slave: em1 MII Status: up MII Polling Interval (ms): 50 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth0 MII Status: up Speed: 10000

HOW TO ADD A LINE WITH ANSIBLE WITH TAB SPACE IN A FILE

-bash-4.2# vi add_line_syslog.yml --- - name: script in order to add in the server list below with TAB spaces a Line in the SYSLOG CONF   hosts: oraking   tasks:     - name: Add a Line  in /etc/syslog.conf in order to delivery that information to another server       lineinfile:         path: /etc/syslog.conf         line: " *.err;auth.notice;auth.info;local0.info \t\t @10.10.10.200 "         insertbefore: ' \*.alert;kern.err;daemon.err '     - name: Restart system-log       command: /usr/sbin/svcadm restart svc:/system/system-log:default

How to configure publisher and install packages in Oracle Solaris 11

Connect to Oracle Support and Download the certificates Set proxy if you have one  #export https_proxy=https://usuario:password@191.118.2.110:8080  #export http_proxy=http://usuario:password@191.118.2.110:8080 You can add in the profile this information in order to have them configured in the login 1.-Download the ssl certicates in order to install them in the server 2.-Create a directory /var/pkg/ssl. #mkdir -p 755  /var/pkg/ssl 3.-Copy or Move the cerrtificates  # cd /var/pkg/ssl/  # ls -ltr total 53 -rw-r--r--   1 root     root        1679 Mar 27 13:36 Oracle_Solaris_11_Support.key.pem -rw-r--r--   1 root     root         932 Mar 27 13:36 Oracle_Solaris_11_Support.certificate.pem 4.- # pkg set-publisher \  -k /var/pkg/ssl/Oracle_Solaris_11_Support.key.pem \ -c /var/pkg/ssl/Oracle_Solaris_11_Support.certificate.pem \ -g https://pkg.oracle.com/solaris/support/ \ -G http://pkg.oracle.com/solaris/release/ solaris   5.-Verify the new publisher  # pkg publ

Updating Solaris 11.X to 11.3 and SRU to 11.3.2.4.0

Updating Solaris 11.X to 11.3 Download Repository Certificate s accessing with MOS user https://pkg-register.oracle.com/register/certificate/ Upload them to the server and rename as below pkg.oracle.com.certificate.perm pkg.oracle.com.key.perm root@:~# pkg unset-publisher This option below delete the currently repository and add the new one root@:~# pkg set-publisher -k  /root/pkg.oracle.com.key.pem -c /root/pkg.oracle.com.certificate.pem -G "*" -g https://pkg.oracle.com/solaris/support/ solaris root@:~# pkg publisher PUBLISHER                   TYPE     STATUS P LOCATION solaris                     origin   online F http://pkg.oracle.com/solaris/support/ root@# pkg update Validate previous boot environment root@:~# beadm list BE      Flags Mountpoint Space  Policy Created --      ----- ---------- -----  ------ ------- solaris NR    /          12.58G static 2016-03-15 07:11 root@:~# root@:~# PHASE             

What is PaaS, IaaS and SaaS?

  Infrastructure Platform as a Service (iPaaS) Integration Platform as a Service (iPaaS) is a suite of cloud services enabling the development, execution, and governance of integration flows connecting any combination of on-premises and cloud-based processes, services, applications, and data within individuals or across multiple organizations.   Ease of use Comprehensive integration of toolsets   Level of support   Readiness to support protocols Flexibility Ability to process, clean, and transform data in formats like XML and JSON; Performance when handling large-scale data operations and concurrent executions; Support for real-time processing and batch data integration; Monitoring for failures, latency, resource utilization, and workflow performance;   Security mechanisms for access control, data encryption, and single sign-on integrations   Infrastructure as a Service (IaaS)     I s a business model that delivers IT infrastructure like computing, storage, and network resources on a p

HOW TO SHARE WITH ZFS A FILE SYSTEM IN SOLARIS 11

As root execute the following Create the pool #zpool create ztemp c0d0 Create ZFS  #zfs create ztemp/temp Mount ZFS  #zfs set mountpoint=/temp ztemp/temp Share ZFS with the option "sharenfs=on" #zfs set sharenfs=on ztemp/temp Share and Select the PATH and SERVERS that you need that mount the ZFS from the NFS Server in our case the servers are oracle1,oracle2 and oracle3 with Read and Write Options #zfs set share=name=temp,path=/temporario,prot=nfs,anon=0,rw=oracle1:oracle2:oracle3 ztemp/temp

How to install Explorer Data Collector 8.11 Solaris 11

1.-Download from Oracle Support MOS the patch 22783063 and unzip and run the command below p22783063_8111638_SOLARIS64.zip #./install_stb.sh -verbose Extracting the STB payload ... Determining the check sums ... Sourcing STB library file ... List of Services Tool Bundle Components:    Oracle Explorer Data Collector 8.11    Oracle Serial Number in EEPROM (SNEEP) 8.11    Service Tag (ST) packages    Oracle Autonomous Crashdump Tool 8.17 (ACT) Would you like to (I)nstall, (X)tract, or (E)xit ? (I by default) X  <-----Select Extract (X) Extracting components for Solaris 11/sparc ...  Extracting IPS repository  Extracting SVR4 packages for Service Tag (ST) packages  - Package 5.11_sparc/SUNWsthwreg.sparc.5.10.pkg extracted Extraction to /var/tmp/stb/extract done Removing STB installation area ...   2.- Now you have in the directory "/var/tmp/stb/extract" de ipsrepo  # cd /var/tmp/stb/extract rwxr-xr-x   3 102      staff          4 Mar  8 11:28 ipsrepo -rw-r--r-- 

How to see all spfile parameters

SET LINESIZE 300 COLUMN name  FORMAT A30 COLUMN value FORMAT A60 COLUMN displayvalue FORMAT A60 SELECT sp.sid,        sp.name,        sp.value,        sp.display_value FROM   v$spparameter sp ORDER BY sp.name, sp.sid;

How to Reset the Root Password of RHEL-7 / systemd

1) Boot your system and wait until the GRUB2 menu appears. 2) In the boot loader menu, highlight any entry and press e . 3) Find the line beginning with linux. At the end of this line, append the following: init=/bin/sh Or if you face a panic, instead of "ro" change to "rw" to sysroot as example below: rw init=/sysroot/bin/sh 4) Press F10 or Ctrl+X to boot the system using the options you just edited. Once the system boots, you will be presented with a shell prompt without having to enter any user name or password: sh-4.2# 5) Load the installed SELinux policy: sh-4.2# /usr/sbin/load_policy -i 6) Execute the following command to remount your root partition: sh4.2# mount -o remount,rw / 7) Reset the root password: Raw sh4.2# passwd root 9) Reboot the system. From now on, you will be able to log in as the root user using the new password set up during this procedure.