Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ Oracle 11g R2 RAC RMAN backup script example     - Oracle 11g on Linux system boot from the startup settings (Database)

- Fun music library in Linux using command line (Linux)

- Install Ubuntu open source drawing program MyPaint 1.2.0 (Linux)

- Applications Linux leap second problem caused (Linux)

- MySQL 5.6 use GTIDs build the master database (Database)

- Fedora 8 configured Heartbeat (Linux)

- Hadoop2.4.0 Eclipse plug-in making (Server)

- Git commands (Linux)

- Linux system monitoring, top command of the diagnostic tool Detailed (Linux)

- PostgreSQL Stream Configuration (Database)

- Android engineers interview questions (Programming)

- MogileFS system installation configuration example (Server)

- Linux account related documents Interpretation (Linux)

- Single-node Hadoop installation notes distributed pseudo & (Server)

- CentOS7 installation hardware monitoring for Zabbix enterprise applications (Server)

- Git remote repository Explanation (Linux)

- Mind mapping software installed in CentOS 7 in XMind (Linux)

- How to manage KVM virtual environments with command-line tools in Linux (Server)

- Java collections series (Programming)

- CentOS 7 server environment to quickly build Linux (Server)

 
         
  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:      
 
- CKEditor + SWFUpload achieve a more powerful editor (Linux)
- To get Java class / jar package path (Programming)
- Ubuntu 14.10 How to install office suite Calligra Suite 2.8.7 (Linux)
- Install the system cleaning software under Linux: BleachBit 1.4 (Linux)
- Oracle View Object Information (Database)
- Install MATE desktop environment adjustment tools Mate Tweak 3.3.6 (Linux)
- Linux data recovery software efficiently practical application extundelete (Linux)
- Linux Network Programming --epoll model Detailed principles and examples (Programming)
- Security measures under Unix multi-user operating system (Linux)
- Java deserialization test (Programming)
- Linux system started to learn: the Linux syslog (Linux)
- RedHat Performance Tuning (Server)
- XP virtual machine under VirtualBox solve occupy 100% CPU problem (Linux)
- Build ASP.NET 5 development environment in Ubuntu (Server)
- Oracle data files deleted recover after physical (Database)
- Linux command execution judge sentences -;, &&, || (Linux)
- CentOS terminal display Chinese (Linux)
- New experience Budgie (Budgerigar) desktop environment (Linux)
- Build and verify MongoDB3.0.7 version (shard + replica) Cluster (Database)
- C # function (Programming)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.