Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ Oracle 11g R2 RAC RMAN backup script example     - CentOS 6 adds disk quota limit (Linux)

- Protect your files, modify the Linux value Umask (Linux)

- GNU / Linux enable Intel Rapid Start (Linux)

- Installation of network monitoring ntopng under CentOS 6.4 (Linux)

- Expert advice: Do not use the computer security IE browser (Linux)

- The correct way of logical backup mysqldump (Database)

- Ubuntu root user profiles (Programming)

- nginx.conf Optimization (Server)

- Syncthing: Private Security Synchronization tool to synchronize files between computers / folder (Linux)

- Can not empty the Recycle Bin to repair problems in Ubuntu 14.04 (Linux)

- Ubuntu install video conversion tool Selene (Linux)

- CentOS minimal network is unavailable resolved (Linux)

- Ubuntu 14.04 build Hadoop 2.5.1 standalone and pseudo-distributed environment (32-bit) (Server)

- To teach you a trick to find the real IP address (Linux)

- Python when automated operation and maintenance often used method (Programming)

- 30 Practical Linux system administrators will learn the command (Linux)

- SQL statement to repair SQL Server database (Database)

- Oracle data files deleted recover after physical (Database)

- Iptables use examples (Linux)

- printf PHP string operations () built-in function usage (Programming)

 
         
  Oracle 11g R2 RAC RMAN backup script example
     
  Add Date : 2018-11-21      
         
         
         
  First, the RAC will switch to archive mode

1. Modify the archive mode of the database, usually at the time of installation of the RAC will configure archiving and flashback district archive in the following manner already configured you can skip.

SQL> alter system set cluster_database = false scope = spfile sid = '*';

2. Close all instances (both sides have to shutdown)

SQL> shutdown immediate

Or close all instances
$ Srvctl stop database -d orcl

3. In any instance will start to mount the database state, modify the database archiving mode

SQL> startup mount;
SQL> alter database archivelog;
SQL> alter system set cluster_database = true scope = spfile sid = '*';
SQL> shutdown immediate;

4. Start all instances

$ Srvctl start database -d orcl

5. Verify that the archive mode on

SQL> archive log list;

Second, configure the NFS shared directory used to store RMAN backup data

1. Configure nfs service to ensure that both sides can access the backup directory, where test, using Node 1 provides nfs service.

node1 configuration:

# Cat / etc / exports

# Description two nodes also mount RMAN backup directory node.
/ Data / rman_bak db2 (rw, no_root_squash)

2. node2 configuration node 2 as nfs client mount, two directory consistent.

# Manually mount
# Mount -t nfs db1: / data / rman_bak / data / rman_bak

# Configure boot automatically mount
# Cat / etc / fstab
db1: / data / rman_bak / data / rman_bak nfs defaults 0 0

 


Three, Oracle 11g RAC database parameter modification

1. Modify the time to save the backup control file

Note: The default seven days, according to the situation changes.

SQL> show parameter control;
SQL> alter system set control_file_record_keep_time = 40 scope = both;

 


2. RMAN configuration parameters

Turn on automatic backup control file, then open the backup or data files (such as adding data files) have to modify the time automatically backup control file and spfile files in the database.
RMAN> configure controlfile autobackup on;
RMAN> configure retention policy to recovery window of 30 days;

3. Backup Strategies

Determine the database is running in archive mode, the database once a day to do a backup, you can store the backup time to decide according to the backup server disk space as well as self-defined strategy.
Sundays do Level 0 Level Backup
Every Monday, two, three, four, five, six do Level 1 Level Backup

Four, RMAN backup script configuration

1. Prepare Directory

# Su - oracle

Note: You can create the relevant directory according to the actual situation, pay attention to the directory permissions.
$ Mkdir -p / u01 / app / oracle / rman_bak / scripts
$ Mkdir -p / data / rman_bak / data
$ Mkdir -p / data / rman_bak / logs

Description: RAC backup if ASM, then backs up only one node in it. This means that this backup is stored on one of the nodes, and other nodes if NFS is the way you can achieve recovery.

2. Create a script contents

$ Vi /u01/app/oracle/rman_bak/scripts/rman_bak.sh
$ Chmod u + x /u01/app/oracle/rman_bak/scripts/rman_bak.sh

3. Add Scheduled Task

$ Crontab -e
# RMAN
00 1 * * 0 /u01/app/oracle/rman_bak/scripts/rman_bak.sh 0
00 1 * * 1,2,3,4,5,6 /u01/app/oracle/rman_bak/scripts/rman_bak.sh 1

4. Manually test channel

Manually add db1, db2 local service name configuration, 11g rac only scan ip default server, the local service name need to manually add the following:

# Su - oracle
$ Vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP) (HOST = scan-cluster) (PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

ORCL1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP) (HOST = db1-vip) (PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
      (INSTANCE_NAME = orcl1)
    )
  )

ORCL2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP) (HOST = db2-vip) (PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
      (INSTANCE_NAME = orcl2)
    )
  )

Manual test channel

rman target /

configure channel 1 device type disk connect 'sys / oracle123 @ orcl1';
configure channel 2 device type disk connect 'sys / oracle123 @ orcl2';

4. Habitat program script step

$ Vi /u01/app/oracle/rman_bak/scripts/rman_bak.sh

#! / Bin / bash
export ORACLE_BASE = / u01 / app / oracle
export ORACLE_HOME = / u01 / app / oracle / product / 11.2.0 / db_1
export ORACLE_SID = orcl1
export NLS_LANG = AMERICAN_AMERICA.ZHS16GBK
export PATH = $ ORACLE_HOME / bin: $ PATH
LEVEL = $ @
DATE = `date +% w`
DATE_2 = `date +% Y% m% d`
BACKUP_PATH = "/ data / rman_bak"
BIN = $ ORACLE_HOME / bin

if [! $ # = 1]; then
echo "usage: rman_bak.sh n
where n is the rman backup level (Only 0,1 is permitted). "
exit 1
fi

if [$ @ -ne 0 -a $ @ -ne 1]; then
echo "usage: rman_bak.sh n
where n is the rman backup level (Only 0,1 is permitted). "
exit 2
fi

if [[$ LEVEL = 0]]; then
$ BIN / rman log $ BACKUP_PATH / logs / level. $ ORACLE_SID. $ LEVEL. $ DATE_2.log << EOF

connect target /;
run {
allocate channel c1 device type disk connect 'sys / oracle @ orcl1';
allocate channel c2 device type disk connect 'sys / oracle @ orcl2';
crosscheck backupset of archivelog all;
backup archivelog all format '$ BACKUP_PATH / data / archlog% d.level $ LEVEL% U_% T...' delete all input;
delete noprompt expired backupset of archivelog all;
release channel c1;
release channel c2;
}

run {
allocate channel c1 device type disk connect 'sys / oracle @ orcl1';
allocate channel c2 device type disk connect 'sys / oracle @ orcl2';
crosscheck backupset of database;
backup incremental level $ LEVEL database format '$ BACKUP_PATH / data / data% d.level $ LEVEL% U_% T...';
backup spfile tag = 'spfile' format '$ BACKUP_PATH / data / spfile_% U_% T';
backup current controlfile tag = 'control' format = '$ BACKUP_PATH / data / control_% U_% T';
delete noprompt expired backupset of database;
delete noprompt obsolete;
release channel c1;
release channel c2;
}
exit;
EOF

else

$ BIN / rman log $ BACKUP_PATH / logs / level. $ ORACLE_SID. $ LEVEL. $ DATE_2.log << EOF

connect target /;
run {
allocate channel c1 device type disk connect 'sys / oracle @ orcl1';
allocate channel c2 device type disk connect 'sys / oracle @ orcl2';
crosscheck backupset of archivelog all;
backup archivelog all format '$ BACKUP_PATH / data / archlog% d.level $ LEVEL% U_% T...' delete all input;
delete noprompt expired backupset of archivelog all;
release channel c1;
release channel c2;
}

run {
allocate channel c1 device type disk connect 'sys / oracle @ orcl1';
allocate channel c2 device type disk connect 'sys / oracle @ orcl2';
crosscheck backupset of database;
backup incremental level $ LEVEL database format '$ BACKUP_PATH / data / data% d.level $ LEVEL% U_% T...';
backup spfile tag = 'spfile' format '$ BACKUP_PATH / data / spfile_% U_% T';
backup current controlfile tag = 'control' format = '$ BACKUP_PATH / data / control_% U_% T';
delete noprompt expired backupset of database;
delete noprompt obsolete;
release channel c1;
release channel c2;
}

exit;
EOF

fi

5. The test is performed manually

$ /u01/app/oracle/rman_bak/scripts/rman_bak.sh 0

Test attention to detail:

1) Observation rman log log without exception error.
2) Is there a backup and observe archivelog delete.
     
         
         
         
  More:      
 
- Python developer of time-saving method (Programming)
- exp / imp Export Import version of the problem and the ORA-6550 error (Database)
- RedHat command line and graphical interface switching (Linux)
- Linux memory management (Linux)
- Share Practical Tutorial GitHub (Linux)
- Linux Shell Understanding and Learning (Linux)
- CentOS static IP network configuration (Linux)
- How to set the default Fedora from the command line (Linux)
- CentOS yum install LNMP PHP5.4 version (Server)
- ogg Oracle to SQL Server 2005 to achieve synchronization (Database)
- Spring-depth understanding of the various annotations (Programming)
- PXE + Kickstart automatically install CentOS 6.5 (Linux)
- Oracle 10g, 11g database silent installation of small differences (Database)
- Based Corosync + Pacemaker + DRBD + LNMP Web server to achieve high availability cluster (Server)
- Windows Server 2012 R2 Datacenter install SQL Server 2016 CTP (Database)
- Ubuntu achieve initialization iptables (Linux)
- Python KNN algorithm of actual realization (Programming)
- File sharing and fork function (Programming)
- 25 Git Advanced Skills (Linux)
- Copy and paste in Linux terminal and Vim (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.