Data guard-use RMAN to create a single-instance physical (physical) standby Database

Source: Internet
Author: User

Primary database:
192.168.8.251 centos10g.oracle.com centos10g

Standby database:
192.168.8.252 centos10g2.oracle.com centos10g2

1. Enable force logging on primary database
[Oracle @ centos10g ~] $ Sqlplus/As sysdba
SQL> alter database force logging;
Database altered.

2. Enable archivelog mode on primary database
[Oracle @ centos10g ~] $ Mkdir/u01/Arch

SQL> alter system set log_archive_dest_1 = 'location =/u01/arch 'scope = spfile;
System altered.

SQL> shutdown immediate;

SQL> startup Mount;

SQL> alter database archivelog;

SQL> archive log list
Database Log mode archive Mode
Automatic Archival Enabled
Archive destination/u01/Arch
Oldest online log sequence 10
Next log sequence to archive 12
Current Log sequence 12

3. Create an NFS shared directory to store the primary backup set
[Root @ centos10g ~] # Chown-r ORACLE: oinstall/backup
[Root @ centos10g ~] # Chmod-r 777/backup
[Root @ centos10g ~] # Vi/etc/exports
/Backup centos10g.oracle.com (RW, sync) centos10g2.oracle.com (RW, sync)
[Root @ centos10g ~] # Service NFS start
Starting NFS services: [OK]
Starting NFS quotas: [OK]
Starting NFS daemon: [OK]
Starting NFS mountd: [OK]
--------------------------------------------------------------------
-- Mount nfs sharing on the primary host on the standby host
[Root @ centos10g2 ~] # Chown-r ORACLE: oinstall/backup
[Root @ centos10g2 ~] # Chmod-r 777/backup
[Root @ centos10g2 ~] # Mount centos10g.oracle.com:/backup

[Root @ centos10g2 ~] # DF-H/backup
Filesystem size used avail use % mounted on
Centos10g.oracle.com:/backup
2.0g 36 m 1.9g 2%/backup

4. Back up the primary database (full backup) to NFS sharing

RMAN> run {
2> startup Mount;
3> allocate channel C1 type disk;
4> allocate channel C2 type disk;
5> Backup format = '/backup/% d _ % S _ % T. Bak' Database Plus archivelog;
6>}

5. Back up the standby control file on the primary database

RMAN> copy current controlfile for standby to '/backup/control01.ctl ';

6. Configure the listening and TNS of primary and standby.

[Oracle @ centos10g2 ~] $ More $ ORACLE_HOME/Network/admin/tnsnames. ora
Beijing =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = centos10g) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = prod)
)
)

Tianjin =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = centos10g2) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = standby)
)
)

[Oracle @ centos10g ~] $ More $ ORACLE_HOME/Network/admin/tnsnames. ora

Beijing =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = centos10g) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = prod)
)
)

Tianjin =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = centos10g2) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = standby)
)
)

7. Prepare the pfile of the standby Database
Create a pfile in the primary database, copy it to the $ ORACLE_HOME/DBS path of the standby database, and add the following parameters:
*. Db_unique_name = Tianjin
*. Log_archive_config = 'dg _ Config = (Beijing, Tianjin )'
*. Log_archive_dest_1 = 'location =/u01/arch valid_for = (online_logfiles, primary_role) db_unique_name = tianjin'
*. Log_archive_dest_2 = 'service = Beijing valid_for = (online_logfiles, primary_role) db_unique_name = Beijing'

*. Fal_server = Beijing
*. Fal_client = Tianjin
*. Db_file_name_convert = '/u01/APP/Oracle/oradata/prod'.'/u01/APP/Oracle/oradata/prod'
*. Log_file_name_convert = '/u01/APP/Oracle/oradata/prod'.'/u01/APP/Oracle/oradata/prod'
*. Standby_file_management = auto

8. create directories involved in initialization parameters on the standby Database Host
[Oracle @ centos10g2 DBS] $ mkdir-P/u01/APP/Oracle/admin/Prod/adump
[Oracle @ centos10g2 DBS] $ mkdir-P/u01/APP/Oracle/admin/Prod/bdump
[Oracle @ centos10g2 DBS] $ mkdir-P/u01/APP/Oracle/admin/Prod/cdump
[Oracle @ centos10g2 DBS] $ mkdir-P/u01/APP/Oracle/admin/Prod/udump
[Oracle @ centos10g2 DBS] $ mksdir-P/u01/APP/Oracle/oradata/Prod/
[Oracle @ centos10g2 DBS] $ mkdir-P/u01/APP/Oracle/flash_recovery_area

9. Use the backup set of the primary database to restore the standby Database
9.1 restore the controlfile of the primary database in the standby Database
[Oracle @ centos10g2 backup] $ CP control01.ctl/u01/APP/Oracle/oradata/Prod/control01.ctl
[Oracle @ centos10g2 backup] $ CP control01.ctl/u01/APP/Oracle/oradata/Prod/control02.ctl
[Oracle @ centos10g2 backup] $ CP control01.ctl/u01/APP/Oracle/oradata/Prod/control03.ctl
[Oracle @ centos10g2 ~] $ RMAN target/
RMAN> startup Mount
Connected to target database (not started)
Oracle instance started
Total system global area 285212672 bytes
Fixed size 1218992 bytes
Variable Size 100664912 bytes
Database buffers 180355072 bytes
Redo buffers 2973696 bytes

9.2 Restore database

RMAN> Restore database;

Starting restore at 23-sep-12
Allocated channel: ora_disk_1
Channel ora_disk_1: SID = 156 devtype = Disk

Channel ora_disk_1: Starting datafile backupset restore
Channel ora_disk_1: specifying datafile (s) to restore from backup set
Restoring datafile 00002 to. '/u01/APP/Oracle/oradata/prod'/undotbs01.dbf
Restoring datafile 00003 to. '/u01/APP/Oracle/oradata/prod'/sysaux01.dbf
Restoring datafile 00005 to. '/u01/APP/Oracle/oradata/prod'/example01.dbf
Channel ora_disk_1: reading from backup piece/backup/prod_20_794779912.bak
ORA-19870: Error reading backup piece/backup/prod_20_794779912.bak
ORA-19505: failed to identify file "/backup/prod_20_794779912.bak"
ORA-27054: NFS file system where the file is created or resides is not mounted with correct options
Additional information: 3
Channel ora_disk_1: Starting datafile backupset restore
Channel ora_disk_1: specifying datafile (s) to restore from backup set
Restoring datafile 00001 to. '/u01/APP/Oracle/oradata/prod'/system01.dbf
Restoring datafile 00004 to. '/u01/APP/Oracle/oradata/prod'/users01.dbf
Channel ora_disk_1: reading from backup piece/backup/prod_19_794779912.bak
ORA-19870: Error reading backup piece/backup/prod_19_794779912.bak
ORA-19505: failed to identify file "/backup/prod_19_794779912.bak"
ORA-27054: NFS file system where the file is created or resides is not mounted with correct options
Additional information: 3

The cause of the problem may be that Oracle considers NFS. In short, the command must be executed.
Alter system set events '10298 trace name context forever, level 32'
Or perform the following operations:

[Root @ centos10g2 ~] # Mount-T nfs-o rw, BG, hard, nointr, rsize = 32768, wsize = 32768, TCP, Vers = 3, timeo = 600, actimeo = 0 centos10g.oracle.com: /backup



For reprinting, please indicate the author, source, and original text links; otherwise, you will not be reprinted:

Source: http://blog.csdn.net/xiangsir/article/details/8606594

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.