Wednesday, 3 July 2019

Recover lost datafile on Standby with rman



Recover lost datafile on Standby with rman




Here we have same issue, I have lost one datafile file from my Standby database, this solution is diff from last one ,in this we use rman backup copy of lost datafile from Standby ,no need to change Standby_file_management to manual

Primary Database =AUS
Standby Database= AUSSTBY

Lost datafile no is 4;

On Primary :-

SQL>  select name from v$datafile_header;
NAME
--------------------------------------------------------------------------------
+DATA/data01.dbf
+DATA/undo.dbf
+DATA/data02.dbf
+DATA/tbs01.dbf

On Standby :-

SQL>  select name from v$datafile_header;
NAME
--------------------------------------------------------------------------------
+DATA01/data01.dbf
+DATA01/undo.dbf
+DATA01/data02.dbf

 tbs01.dbf it missing on Primary

contents of alert log from Standby :-


alter database recover managed Standby database disconnect from session
Sun Nov 11 00:09:40 2012
Attempt to start background Managed Standby Recovery process (AUSSTBY)
MRP0 started with pid=22, OS id=7842
Sun Nov 11 00:09:41 2012
MRP0: Background Managed Standby Recovery process started (AUSSTBY)
Managed Standby Recovery not using Real Time Apply
Sun Nov 11 00:09:46 2012
Errors in file /opt/oracle/database/AUSSTBY/bdump/AUSSTBY_dbw0_5501.trc:
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '+DATA01/tbs01.dbf'
ORA-17503: ksfdopn:2 Failed to open file +DATA01/tbs01.dbf
ORA-15173: entry 'tbs01.dbf' does not exist in directory '/'
MRP0: Background Media Recovery terminated with error 1110
Sun Nov 11 00:09:46 2012
Errors in file /opt/oracle/database/AUSSTBY/bdump/AUSSTBY_mrp0_7842.trc:
ORA-01110: data file 4: '+DATA01/tbs01.dbf'
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '+DATA01/tbs01.dbf'
Sun Nov 11 00:09:46 2012
Errors in file /opt/oracle/database/AUSSTBY/bdump/AUSSTBY_mrp0_7842.trc:
ORA-01110: data file 4: '+DATA01/tbs01.dbf'
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '+DATA01/tbs01.dbf'
Sun Nov 11 00:09:46 2012
MRP0: Background Media Recovery process shutdown (AUSSTBY)

on Primary :- connect with rman on Primary and take to backup of datafile 4 as copy

[oracle@Host1 ~]$ rman target sys/singh@AUS
Recovery Manager: Release 10.2.0.1.0 - Production on Sun Nov 11 04:06:57 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: AUS (DBID=980646045)
RMAN> backup as copy datafile 4 format='/opt/oracle/%U.bak' tag='lost file backup';

Starting backup at 11-NOV-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=28 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=+DATA/tbs01.dbf
output filename=/opt/oracle/data_D-AUS_I-980646045_TS-TBS_FNO-4_0rnq0qfj.bak tag=LOST FILE BACKUP recid=2 stamp=799042039
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 11-NOV-12

RMAN> 

Now copy this backup copy to Standby database :
[oracle@Host1 oracle]$ ls -la
total 10304
drwxrwxr-x  6 oracle oinstall     4096 Nov 11 04:07 .
drwxr-xr-x  6 root   root         4096 Oct 27 06:35 ..
drwxr-xr-x  2 oracle oinstall     4096 Nov 10 02:13 cdsbak
-rw-r-----  1 oracle oinstall    11003 Nov  3 00:29 AUS_lnsb_6593.trc
drwxr-xr-x  3 oracle oinstall     4096 Oct 27 21:55 database
-rw-r-----  1 oracle oinstall 10493952 Nov 11 04:07 data_D-AUS_I-980646045_TS-TBS_FNO-4_0rnq0qfj.bak
drwxrwx---  6 oracle oinstall     4096 Oct 27 06:34 oraInventory
drwxr-x--- 54 oracle oinstall     4096 Oct 28 01:07 product
[oracle@Host1 oracle]$ scp data_D-AUS_I-980646045_TS-TBS_FNO-4_0rnq0qfj.bak host2:/opt/oracle/
oracle@host2's password:
data_D-AUS_I-980646045_TS-TBS_FNO-4_0rnq0qfj.bak                                                                           100%   10MB 10.0MB/s   00:01   
[oracle@Host1 oracle]$


Now in Standby Database Connect  Cancel the redo apply first and then connect with rman on Standby:-

SQL> alter database recover managed Standby database cancel;
  
[oracle@Host2 ~]$ rman target sys/singh@AUSSTBY
Recovery Manager: Release 10.2.0.1.0 - Production on Sun Nov 11 04:08:31 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: AUS (DBID=980646045, not open)
RMAN> catalog datafilecopy '/opt/oracle/data_D-AUS_I-980646045_TS-TBS_FNO-4_0rnq0qfj.bak';

using target database control file instead of recovery catalog
cataloged datafile copy
datafile copy filename=/opt/oracle/data_D-AUS_I-980646045_TS-TBS_FNO-4_0rnq0qfj.bak recid=7 stamp=799042153

RMAN> report schema;


List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    300      SYSTEM               ***     +DATA01/data01.dbf
2    20       UNDOCDS01            ***     +DATA01/undo.dbf
3    200      SYSAUX               ***     +DATA01/data02.dbf
4    0        TBS                  ***     +DATA01/tbs01.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMPCDS01            20          +DATA01/temp.dbf

RMAN> switch datafile 4 to copy;

datafile 4 switched to datafile copy "/opt/oracle/data_D-AUS_I-980646045_TS-TBS_FNO-4_0rnq0qfj.bak"

RMAN> report schema;

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    300      SYSTEM               ***     +DATA01/data01.dbf
2    20       UNDOCDS01            ***     +DATA01/undo.dbf
3    200      SYSAUX               ***     +DATA01/data02.dbf
4    10       TBS                  ***     /opt/oracle/data_D-AUS_I-980646045_TS-TBS_FNO-4_0rnq0qfj.bak

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMPCDS01            20          +DATA01/temp.dbf

RMAN> copy datafile 4 to '+DATA01/tbs01.dbf';

Starting backup at 11-NOV-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=18 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/opt/oracle/data_D-AUS_I-980646045_TS-TBS_FNO-4_0rnq0qfj.bak
output filename=+DATA01/tbs01.dbf tag=TAG20121111T041116 recid=8 stamp=799042278
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 11-NOV-12

RMAN> report schema;

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    300      SYSTEM               ***     +DATA01/data01.dbf
2    20       UNDOCDS01            ***     +DATA01/undo.dbf
3    200      SYSAUX               ***     +DATA01/data02.dbf
4    10       TBS                  ***     /opt/oracle/data_D-AUS_I-980646045_TS-TBS_FNO-4_0rnq0qfj.bak

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMPCDS01            20          +DATA01/temp.dbf

RMAN> switch datafile 4 to copy;

datafile 4 switched to datafile copy "+DATA01/tbs01.dbf"

RMAN> report schema;
List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    300      SYSTEM               ***     +DATA01/data01.dbf
2    20       UNDOCDS01            ***     +DATA01/undo.dbf
3    200      SYSAUX               ***     +DATA01/data02.dbf
4    10       TBS                  ***     +DATA01/tbs01.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMPCDS01            20          +DATA01/temp.dbf

RMAN>exit  


Now start redo apply on Standby :-
On Standby now:-

SQL> select name from v$datafile_header;


NAME
--------------------------------------------------------------------------------
+DATA01/data01.dbf
+DATA01/undo.dbf
+DATA01/data02.dbf
+DATA01/tbs01.dbf

Thursday, 30 August 2018

RMAN backup in NOARCHIVELOG Mode



Taking full database backup using RMAN when database is in NOARCHIVELOG Mode


When the database is running in NOARCHIVELOG mode then you can take only offline full database backups. i.e. you cannot take online backups.
To take full backup using RMAN when the database is in NOARCHIVELOG mode, the database should not be opened but it should be in the mounted state
To take offline full database backup using RMAN do the following
Step 1
Assuming the database is not started. Set the ORACLE_SID environment variable  to your database SID and start RMAN by typing the following command
$export ORACLE_SID=test
$rman target system/manager nocatalog
When you type the above command, RMAN will start with the following messages and you will get the RMAN prompt

Start RMAN
Step 2
Start the instance and mount the database by typing the following command at RMAN prompt
RMAN> startup mount;

Start and mount the database using RMAN
Step 3
To take full database backup type the following command
RMAN> backup full database tag 'myfullbackup';

backup full database using rman
The above the command will backup the full database and it will create the backupsets in the directory which is set in theDB_RECOVERY_FILE_DEST parameter. In our case the parameter is set to the following path "/u02/oracle/testdb/flash"
If you want to create the backupsets in other directory path then, you have to include the FORMAT option in the above command. For example the following command will create backupsets in the "/u02/oracle/mybackup" directory
 RMAN> backup full database format '/u02/oracle/mybackup/%U' tag 'myfullbackup'
The %U means RMAN should generate unique filenames for backupsets
Step 4
That's it the backup is over. We can start the database by typing the following
RMAN> alter database open;
If you want, you can view the back upsets by going into the following directory using O/s commands

listing rman backup sets


Bonding in RHEL 6









NIC Bonding in RHEL6

 Solution
Red Hat Enterprise Linux allows administrators to bind multiple network interfaces together into a single channel using the bonding kernel module and a special network interface called a channel bonding interface. Channel bonding enables two or more network interfaces to act as one, simultaneously increasing the bandwidth and providing redundancy. The behavior of the bonded interfaces depends upon the mode, either hot standby or load balancing service.

           
Steps for configuring bonding
In this document we are configuring bond0 with interfaces eth0 and eth1

Step 1- Load Kernel module
For a channel bonding interface to be valid, the kernel module must be loaded. To ensure that the module is loaded when the channel bonding interface is brought up, create a new file as root named <bonding>.conf in the /etc/modprobe.d/ directory. Note that we can name this file anything but it should with ends with a .conf extension. Insert the following line in this new file alias bond<N> bonding
Replace <N> with the interface number, such as 0. If we want to configure  configuring more than on bonding interface, For  each configured channel bonding interface, there must be a corresponding entry in  /etc/modprobe.d/<bonding>.conf file
In this example we are configuring bond0 and  file name is bonding.conf
  [root@praji2 modprobe.d]# cat /etc/modprobe.d/bonding.conf
  alias bond0 bonding

Step2- create channel bonding interface
We  need to create a channel bonding interface configuration file on /etc/sysconfig/network-scripts/ directory called ifcfg-bond<N> , replacing <N> with the number for the interface, such as 0 and specify the bonding parameters on the file. Here we are creating ifcfg-bond0 file with following contents
[root@praji2 network-scripts]# cat ifcfg-bond0
DEVICE=bond0
IPADDR=172.16.1.207
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
BONDING_OPTS="mode=0 miimon=1000"

Step 3- Configure Network interfaces
After the channel bonding interface is created, the network interfaces to be bound together must be configured by adding the MASTER= and SLAVE= directives to their configuration files. The configuration files for each of the channel-bonded interfaces can be nearly identical. For example, if two Ethernet interfaces are being channel bonded, both eth0 and eth1 may look like the following example
Interface eth0 configuration
 [root@praji2 network-scripts]# cat ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
USERCTL=no
TYPE=Ethernet
Interface eth1 configuration
[root@praji2 network-scripts]# cat ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
TYPE=Ethernet
USERCTL=no
After configuring the interfaces we have to bring up the bond by using command
[root@praji2 network-scripts]# ifconfig bond0 up
If the bonding is correctly configured we can view the configuration using ifconfig command
[root@praji2 network-scripts]# ifconfig
bond0     Link encap:Ethernet  HWaddr 00:0C:29:69:31:C4
          inet addr:172.16.1.207  Bcast:172.16.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe69:31c4/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:19676 errors:0 dropped:0 overruns:0 frame:0
          TX packets:342 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1623240 (1.5 MiB)  TX bytes:42250 (41.2 KiB)

eth0      Link encap:Ethernet  HWaddr 00:0C:29:69:31:C4
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:10057 errors:0 dropped:0 overruns:0 frame:0
          TX packets:171 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:832257 (812.7 KiB)  TX bytes:22751 (22.2 KiB)
          Interrupt:19 Base address:0x2000

eth1      Link encap:Ethernet  HWaddr 00:0C:29:69:31:C4
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:9620 errors:0 dropped:0 overruns:0 frame:0
          TX packets:173 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:791043 (772.5 KiB)  TX bytes:20207 (19.7 KiB)
          Interrupt:19 Base address:0x2080


lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:104 (104.0 b)  TX bytes:104 (104.0 b)

To view all existing bonds we can run following command, it will list bond0
[root@praji2 network-scripts]# cat /sys/class/net/bonding_masters
bond0
To view the existing mode of bonding we can use following command
[root@praji2 network-scripts]# cat /sys/class/net/bond0/bonding/mode
balance-rr 0
For verifying bonding , we can use following command. It will list bonding details
[root@praji2 network-scripts]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.5.0 (November 4, 2008)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 1000
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:69:31:c4

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:69:31:ce
  
 bonding modes
Several policies are available in bonding, this mode can be set using directive mode=<value>
The <value> can be one of:
balance-rr or 0 — Sets a round-robin policy for fault tolerance and load balancing. Transmissions are received and sent out sequentially on each bonded slave interface beginning with the first one available.
active-backup or 1 — Sets an active-backup policy for fault tolerance. Transmissions are received and sent out via the first available bonded slave interface. Another bonded slave interface is only used if the active bonded slave interface fails.
balance-xor or 2 — Sets an XOR (exclusive-or) policy for fault tolerance and load balancing. Using this method, the interface matches up the incoming request's MAC address with the MAC address for one of the slave NICs. Once this link is established, transmissions are sent out sequentially beginning with the first available interface.
broadcast or 3 — Sets a broadcast policy for fault tolerance. All transmissions are sent on all slave interfaces.
802.3ad or 4 — Sets an IEEE 802.3ad dynamic link aggregation policy. Creates aggregation groups that share the same speed and duplex settings. Transmits and receives on all slaves in the active aggregator. Requires a switch that is 802.3ad compliant.
balance-tlb or 5 — Sets a Transmit Load Balancing (TLB) policy for fault tolerance and load balancing. The outgoing traffic is distributed according to the current load on each slave interface. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed slave.
balance-alb or 6 — Sets an Active Load Balancing (ALB) policy for fault tolerance and load balancing. Includes transmit and receive load balancing for IPV4 traffic. Receive load balancing is achieved through ARP