Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ Oracle 11g R2 RAC RMAN backup script example     - CentOS iptables firewall enabled (Linux)

- LAMP environment to build Apache, MySQL, PHP under Ubuntu (Server)

- Raspberry Pi configuration wireless hotspot (Linux)

- Bootstrap 3.3.5 release download, Web front-end UI framework (Linux)

- WebLogic administrator account and reset the password (Database)

- Java-- get the reflection object information (Programming)

- CentOS replaces update source and Linux kernel compilation summary (Linux)

- Linux installed Cisco Packet Tracer (Linux)

- Android custom ViewPager create kaleidoscopic image transition effects (Programming)

- Ubuntu 14.04 Solution login interface infinite loop (Linux)

- Shell scripts quickly deploy Tomcat project (Server)

- 12 kinds of detection of CPU information on a Linux system tools (Linux)

- Python programming style (Programming)

- Specifies the open ports of the SUSE firewall settings (Linux)

- Oracle Data Pump Example (Database)

- Zabbix monitoring of the switch (Server)

- Use Hexo quickly build and deploy a blog to Github (Server)

- CentOS 6 compiling httpd-2.4.10 (Server)

- KVM virtualization nested configuration (Server)

- Use apt-p2p up a local Debian package cache (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:      
 
- Quick paging ROW_NUMBER conducted (Database)
- 2016, the new Node project Precautions (Programming)
- 64-bit Oracle Linux recompiled Hadoop-2.2.0 (Server)
- ActiveMQ5.11.1 and JDK version matching relation (Linux)
- Java deserialization test (Programming)
- C # get the current screenshot (Programming)
- CentOS 6.4 dial-up Raiders (Linux)
- Ubuntu deploying Solr (4.4) to Tomcat (7.0.53) (Server)
- Use preseed script to install Ubuntu 14.04 (Linux)
- Linux awk text analysis tool (Linux)
- The free command in Linux (Linux)
- Applications Linux leap second problem caused (Linux)
- Java String type time compare the size (Programming)
- Compare Swift achieve rapid sorting and sorted Methods (Programming)
- Oracle 11g RAC root.sh execution error second node failure example (Database)
- Android engineers interview questions (Programming)
- Give your photos Instagram style filters plus program in ubuntu (Linux)
- Use Python to perform system commands common usage (Programming)
- Java-based data source database access (Programming)
- CentOS 7 install Hadoop-cdh-2.5 on Mesos (Server)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.