Monday, March 19, 2018

Restore standard naming of network interfaces on Red Hat enterprise linux 7

Disabling consistent network device naming

To disable The consistent network device naming feature and create your own manual ma,ing scheme ,for example eth0,internet0 or lan0. Follow the below steps so that all network device names will be eth followed by an integer.

  • Log in as root, or as a user with superuser privileges.
  • Edit the GRUB 2 general settings file.
    1. Create a backup copy of the settings file.
      # cp /etc/default/grub /etc/default/grub.bak
    2. Open /etc/default/grub with a text editor.
    3. Add kernel boot arguments to the value of the GRUB_CMDLINE_LINUX variable.
      The arguments to add are biosdevname=0 and net.ifnames=0. Make sure the arguments are at the end and between the delimiter characters (").         .
      GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0"                                                                         
    4. Save the file, and then close the text editor 
  • Determine whether the host is configured for UEFI or legacy boot mode..
    # find /boot -maxdepth 1 -type d
  • If the output includes /boot/efi, the host is configured for UEFI boot mode.
  • If the output does not include /boot/efi, the host is configured for legacy boot mode.


  • Recreate the GRUB 2 boot configuration file.
          For UEFI boot mode:
# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
          For legacy boot mode:
# grub2-mkconfig -o /boot/grub2/grub.cfg

Found linux image: /boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-09377eb6cd424f3e802d04d64a5da531
Found initrd image: /boot/initramfs-0-rescue-09377eb6cd424f3e802d04d64a5da531.img
done

  • Change network device configurations.
    1. Change directory to /etc/sysconfig/network-scripts.
      # cd /etc/sysconfig/network-scripts
    2. List the network device configuration files.
      # ls ifcfg-* | grep -v ifcfg-lo
      ifcfg-enp0s3
      ifcfg-enp0s8
      ifcfg-enp0s9
      
      The ifcfg-lo file is excluded because it does not need to be changed.
    3. Rename and edit device files.
      For example, if you have a device file named ifcfg-eno16777736, use the mv command rename it to ifcfg-eth0
      # mv ifcfg-enp0s3 ifcfg-eth0 
      # mv ifcfg-enp0s8 ifcfg-eth1 
      # mv ifcfg-enp0s9 ifcfg-eth2
    4. change the values of the NAME and DEVICE variables inside the file to eth0/1/2..
    5. # vi ifcfg-eth0 
      TYPE=Ethernet
      BOOTPROTO=none
      DEFROUTE=yes
      IPV4_FAILURE_FATAL=no
      IPV6INIT=yes
      IPV6_AUTOCONF=yes
      IPV6_DEFROUTE=yes
      IPV6_FAILURE_FATAL=no
      NAME=enp0s3   ---> change to eth0
      UUID=54828c5b-65be-42b1-8b4e-07627c67487f
      DEVICE=enp0s3 ---> change to eth0
      ONBOOT=yes
      IPADDR=192.168.78.51
      PREFIX=24
      DNS1=192.168.78.51
      DNS2=192.168.78.52
      DOMAIN=evilcorp.com
      IPV6_PEERDNS=yes
      IPV6_PEERROUTES=yes
      IPV6_PRIVACY=no
      
      
      

  • Reboot the host.
    You can confirme the configuration by runing network manager user interface (nmtui) or
    the following commands : 
    # nmcli dev
    DEVICE  TYPE      STATE      CONNECTION
    eth0    ethernet  connected  eth0
    eth1    ethernet  connected  eth1
    eth2    ethernet  connected  eth2
    lo      loopback  unmanaged  --
    
    # nmcli con 
    NAME  UUID                                  TYPE            DEVICE
    eth0  54828c5b-65be-42b1-8b4e-07627c67487f  802-3-ethernet  eth0
    eth2  04583597-c715-4ac5-954e-13dc748991a9  802-3-ethernet  eth2
    eth1  2418c04d-4291-48e6-95d1-3de63cd58d6a  802-3-ethernet  eth1

Tuesday, March 13, 2018

12c Data Guard : Resolve Log gap Error: ORA-16724: "cannot resolve gap for one or more standby databases"

This error happened while my Lab standby server was unreachable for few days. Although my setup was built on top of a Windows environment, the resolution process stays the same here for fixing this error (using an RMAN incremental backup) .
For more details about the Data Guard setup used in this example please refer to my previous post >> Part I :  Implementation

• Note : mtldb = Primary        mtlstd = Standby

- Display of the DGMGRL “show configuration” output

DGMGRL> show configuration verbose
Configuration - dg12
  Protection Mode: MaxPerformance
  Members:
  mtldb  - Primary database
    Error: ORA-16724: cannot resolve gap for one or more standby databases
    mtlstd - Physical standby database

  - Check Primary DB SCN Number

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
  135966683

  - Check Standby DB SCN Number

@mtlsd> select current_scn from gv$database;

CURRENT_SCN
-----------
  114264654 

- Check  Standby checkpoint DB SCN Number

@mtlstd> select min (checkpoint_change#) from v$datafile_header;

MIN(CHECKPOINT_CHANGE#)
-----------------------
  114264655



STEP 1 STOP THE RECOVERY PROCESS (APPLY OFF)

DGMGRL> edit  DATABASE MTLSTD set STATE=APPLY-OFF;



STEP 2  PERFORM A INCREMENTAL BACKUP FROM PRIMARY DB to an SCN that is a bit behind that of the STANDBY

  RMAN> run
  {allocate channel ch1 type disk;
   backup incremental from scn 114264000 database format       
   'E:\MSSQL_backup\standby_%d_%t_%c_%p';
  }



STEP 3 RECOVER STANDBY DB

  A) Move the rman backup piece to the standby server => F:\Ora_Backup\standby

  B) Catalog backup piece on the standby server
      --- ON STANDBY SERVER 

$ rman target /   
RMAN> catalog start with 'F:\Ora_Backup\standby';
    List of Cataloged Files
    =======================
    File Name: F:\ORA_BACKUP\STANDBY\STANDBY_MTLDB_955116673_1_1
    File Name: F:\ORA_BACKUP\STANDBY\STANDBY_MTLDB_955116718_1_1



C) Recover the standby database using the backup piece which has taken from the PRIMARY DB

-- RUN FROM STANDBY SERVER 

RMAN> run
{allocate channel ch1 type disk;
  recover database noredo;}


STEP 4 Create standby control from primary DB

@mtldb> alter database create standby controlfile as 'E:\backup\standby.ctl';




STEP 5 Restore the Control file in the STANDBY DB

-- Below steps are in the standby server
A) STOP THE STANDBY DATABASE (if it’s a  RAC database run it on all instances)

$ srvctl stop database -d mtlstd

B) OPEN THE STANDBY INSTANCE in NoMount mode  (if it’s a  RAC database only one instance should be open)

   $ sqlplus / as sysdba
   SQL> startup nomount


C) IDENTIFY THE CONTROL FILE LOCATION

SQL> show parameter control_files


D) Past the copied standby control file from primary DB in STEP4

E) RESTORING CONTROL FILE TO STANDBY DATABASE

RMAN> restore controlfile from 'F:\Ora_Backup\standby\standby.ctl';
RMAN> alter database mount;


STEP 6 CHANGING CONTROLFILE CONFIGURATION (on standby DB)

$rman target /   
RMAN> CATALOG START WITH '+DATA/MTLSTD/DATAFILE/';

  
/*** STEP 7 (special case)  - If no Datafile has been added during the redo apply lag please skip to STEP9

Check for New Datafile added in primary DB

-- IN STANBDY DB

   SQL> SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# >      114264655;

   No rows ..

  NOTE: If any files available, we have to copy it from primary to the standby database using RMAN

  •    copy the datafile from the primary database (example here file 10 exist only in primary DB).
RMAN>
run
  {allocate channel a1 type disk; backup datafile 10 format 'E:\backup\datafile_%d_%U_%p_%c';}


  • Transfer the rman backup datafile to standby database location then catalog the backup piece in the standby database.
RMAN>
run
{allocate channel a1 type disk; Restore datafile 10;}



STEP 8 Switch the datafile USING RMAN
  This process will change the datafile details of the standby database in the controlfile

RMAN> SWITCH DATABASE TO COPY;

*****/

STEP 9 Clear the standby redo log files

SQL> ALTER DATABASE CLEAR LOGFILE GROUP 4;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 5;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 6;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 7;

  


STEP 10 START THE RECOVEY PROCESS ON STANDBY

$dgmgrl     ----- On standby server
DGMGRL> edit database 'mtlstd' set state='APPLY-ON';
Succeeded.

** FINAL RESULT

DGMGRL> show configuration
Configuration - dg12
  Protection Mode: MaxPerformance
  Members:
  mtldb  - Primary database
    mtlstd - Physical standby database

Fast-Start Failover: DISABLED


Configuration Status:

SUCCESS   (status updated 2 seconds ago)