Creating a Physical Standby Database (Doc ID 1475344.1)

Creating a Physical Standby Database (Doc ID 1475344.1)


In this Document

 Purpose
 Scope
 Details
 Prerequisites and Assumptions to get started
 Environment Information
 Preparing the Environment and Standby Instance
 Create the Physical Standby Database
 Creating a Standby Database via User Managed Backups
 Creating a Standby Database using RMAN (Backup based)
 Creating a Standby Database using RMAN without Backup (from active Database)
 Post-Creation Steps to make the Data Guard Environment operational
 Optional additional Steps
 References

Applies to:

Oracle Database - Enterprise Edition - Version 11.2.0.1 and later
Information in this document applies to any platform.

Purpose

This Document shows the various Possibilities to create a Physical Standby Database on Oracle Database 11.2.0.x.

It should be seen as an Addition and Clarification to the Documentation. You may also review

Oracle? Data Guard, Concepts and Administration, 11g Release 2 (11.2), E25608-0x

Chapter 3: Creating a Physical Standby Database

Appendix E: Creating a Standby Database with Recovery Manager

which is the Base for this Document. We take an Example Database and show the various Methods to create the Standby Database. Note that only the basic Concepts are shown. Further more complex Scenarios are possible as well, of course. Take a Look into the corresponding Documentation to get the deeper Insight.

 

Would you like to explore this Topic further with other Oracle Customers, Oracle Employees and Industry Experts ??

You can discuss this Note, show your Experiences or ask Questions about it directly right at the Bottom of this Note in the Discussion Thread about this Document.

If you want to discover Discussions about other Articles und Subjects or even post new Discussions you can access the My Oracle Support Community Page for High Availability Data Guard

 

Scope

This Document is intended for System Adminstrators planning to setup a Standby Database. Depending on the Needs and Prerequisites on the existing Environment you can choose any of the mentioned Ways to create the Standby Database and Data Guard Environment.

Note that this Note does not cover Setting up Log Transport and Log Apply Services in Detail - we take the basic default Setup here. The same is true for the RMAN Environment in Case where different Backup Types and Scenarios are possible. We just try to show the basic Concept here.

Details

 

Prerequisites and Assumptions to get started

 

-          There already exists a Primary Database you want to create your Standby Database for

-          Primary Database is in ARCHIVELOG-Mode and local Archiving is using Fast Recovery Area

-          FORCE LOGGING is enabled on the Primary Database

-          The Primary Database is using a SPFILE

-          On the Standby Site ORACLE_HOME is installed using the same Oracle Release and Patchlevel

-          The Platform of the Standby Database is the same as the Primary Site or a supported Combination as per Note 413484.1

-          There is Network Connectivity between the Primary and Standby System

-          Listener is configured and running on the Primary and Standby Site

-          We are creating a Standby Database using default Log Transport Services in Maximum Performance Mode

 

 

Environment Information

 

For all mentioned Possibilities we are using this Environment

 

OS:                                                                       Linux x64-64

Hostname (Primary):                                    TSTPRIM

Hostname (Standby):                                   TSTSTBY

Database Version:                                         11.2.0.x

DB_NAME (Primary and Standby):         prim_db

SID/DB_UNIQUE_NAME (Primary):       prim_db

SID/DB_UNIQUE_NAME (Standby):      stby_db

Listener Port (Primary and Standby):     1521

Primary Database Files Location:             /oracle/oradata/prim_db

Standby Database Files Location:            /oracle/oradata/stby_db

 

 

Preparing the Environment and Standby Instance

 

-          Create TNS-Alias to resolve the Standby Database later. The TNS-Alias to resolve the Primary and Standby Database must be present in the Primary and Standby Database TNSNAMES.ORA. Here it looks like that:

  

PRIM_DB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = TSTPRIM)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = prim_db.world)

    )

  )

 

STBY_DB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = TSTSTBY)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = stby.world)

    )

  )

  

-          Create Folders in ADMIN- and ORADATA-Folders to host the Database Files and Dumpfiles (can use $ORACLE_BASE/admin of the Primary as a Reference which Folders to create – typically those are the ‘adump’- and ‘dpdump’-Folders)

 

$ cd $ORACLE_BASE/admin

$ mkdir stby_db

$ cd stby_db

$ mkdir adump

$ mkdir dpdump

 

-          Create a PFILE from the Primary PFILE in the Format ‘init<Standby SID>.ora’

 

SQL> create pfile=’/tmp/initstby_db.ora’ from spfile;

 

 -          Set the following Initialization Parameters on the Primary Database:

  • log_archive_dest_1 = ‘location=USE_DB_RECOVERY_FILE_DEST’
  • log_archive_dest_2 = ’service=stby_db async valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=stby_db’
  • log_archive_dest_state_2 = ’defer’
  • log_archive_config= ’dg_config=(prim_db,stby_db)’
  • log_archive_max_processes = 8

 

-> Those Parameters prepare the Primary Database to support a Standby Database ’stby_db’. log_archive_dest_2 is responsible for transferring Redo to the Standby Site later – currently it is deferred, we will enable later once the Standby Database exists. log_archive_config records all db_unique_name’s participating in this Configuration.

 

-          Modify the following Initialization Parameters in the PFILE (initstby_db.ora) for the Standby Database we created before:

  • log_archive_dest_1 = ‘location=USE_DB_RECOVERY_FILE_DEST’
  • log_archive_config= ’dg_config=(prim_db,stby_db)’
  • log_archive_max_processes = 8
  • fal_server = ‘prim_db’
  • log_file_name_convert = ‘<absolute path or asm diskgroup name of primary online redo log files>’,’<absolute path or asm diskgroup name of standby online redo log files>’
  • db_file_name_convert = ‘<absolute path or asm diskgroup name of primary data files>’,’<absolute path or asm diskgroup name of standby data files>’
  • db_unique_name = ‘stby_db’

 

-> Those Parameters are required to be adjusted for the Standby Database. log_archive_dest_1 here defines the local Archive Destination where we will put ArchiveLogs arriving from the Primary Database later. log_archive_config and db_unique_name are required for the Data Guard Configuration (like on the Primary) and fal_server is required for Gap Resolution to be able to automatically fetch Archive Logs from the Primary again in Case there is a Gap. To automate the Substitution of Database File Locations we set db_file_name_convert and log_file_name_convert. Those Pairs of Values are a simple String Substitution. See Note 1367014.1 for further Details.

-> You may also adjust audit_file_dest and control_files to match with your Environment and Locations.

 

-          Copy prepared ‘initstby_db.ora’ together with the Passwordfile of the Primary Database (orapwprim_db in $ORACLE_HOME/dbs) to the Standby Site and place both into ‘$ORACLE_HOME/dbs’-Folder. Then you have to rename the Passwordfile to match with the Standby SID:

 

$ mv orapwprim_db orapwstby_db

  

Create the Physical Standby Database

 

In the previous Section we prepared the Environments and the Primary Database to support a Standby Database. Now we can proceed and create the Physical Standby Database itself. There are 3 common Ways to perform this which will be shown in the next Section. You can choose any Way most suitable for you:

  1. Creating manually via User-Managed Backups
  2. Using RMAN Backup-based Duplication
  3. Creating a Standby Database from the active Primary Database without a Backup using RMAN Duplicate
Creating a Standby Database via User Managed Backups

We can use a Hot or Cold Database Backup to create the Standby Database. It is only important to create the Standby Controlfile from the Primary after the Backup has completed.

For a Cold Backup we simply perform a clean shutdown of the Primary Database and copy all Datafiles to a temporary Location, then startup the Primary Database again:

 

SQL> shutdown immediate;

$ cp /oracle/oradata/prim_db/*.dbf /backup/

SQL> startup

  

-          If you want to use a Host Backup, we have to put the Primary Database into Backup Mode and copy the Datafiles:

 

SQL> alter database begin backup;

$ cp /oracle/oradata/prim_db/*.dbf /backup/

SQL> alter database end backup;

  

-          We can create the Standby Controlfile since the Backup is complete (either Hot or Cold Backup)

 

SQL> alter database create standby controlfile as ‘/backup/control01.ctl’;

  

-          Now the required Files for the Standby Database are complete and we can transfer those to the Standby Database and place them into the Standby Database File-Folder (in our Example to ‘/oracle/oradata/stby_db/’)

-          Once the Datafiles are there we can set the Environment and first mount the Standby Database

 

$ export ORACLE_SID = stby_db

SQL> connect / as sysdba

SQL> startup mount

  

-          When the Database is mounted proceed with the Post-Creation Steps below

 

 

Creating a Standby Database using RMAN (Backup based)

Instead of creating a User-Managed Backup we can also use a RMAN Backup to create the Standby Database.

-          In this Case we have to create a RMAN Backup of the Primary Database first:

 

RMAN> connect target /

RMAN> backup database plus archivelog format ‘/backup/STBY_%U’;

 

-          Since the Backup already includes the Controlfile, there is no Need to backup or create a Standby Controlfile separately

-          Transfer all Backuppieces created by the RMAN Backup to the exact same Folder (in our Case ‘/backup/’) on the Standby Database

-          Startup nomount the Standby Database

 

$ export ORACLE_SID = stby_db

SQL> startup nomount

 

 -          At this Point we can now start the RMAN Duplicate to create the Standby Database

 

$ export ORACLE_SID = stby_db

RMAN> connect target sys/<Password>@prim_db

RMAN> connect auxiliary /

RMAN> duplicate target database for standby nofilenamecheck;

  

-> The RMAN Duplicate now extracts the Controlfile and Datafiles from the Backup to build the Standby Database. Once done it mounts the Standby Database.  So we can now proceed with the Post-Creation Steps below.

 

Creating a Standby Database using RMAN without Backup (from active Database)

It is now possible to create a Physical Standby Database from the active Primary Database, ie. It is not necessary to create a Backup first. The Blocks are transferred to the Standby Database via the Network during the RMAN Duplicate. Before you decide to use this Option to create your Standby Database you should ensure you sufficient Bandwith available to transfer all Database Blocks of the Primary to the Standby. Depending on the Size of your Primary Database and the Bandwith available it might take long Time to complete this Task. If you have a large Database or a slow Network Connection you may consider to use another Option to create your Standby Database.

The Steps to create the Standby Database that Way are similar to a Backup-based RMAN Duplicate, but we don’t have to take the Backup, we can directly start the RMAN Duplicate from the Standby Site:

 

$ export ORACLE_SID = stby_db

SQL> startup nomount

RMAN> connect target sys/<Password>@prim_db

RMAN> connect auxiliary /

RMAN> duplicate target database for standby from active database nofilenamecheck;

 

-> The RMAN Duplicate first copies the Controlfile from the Primary Database as a Standby Controlfile, then mounts the Standby Database with this Conrolfile and creates the Datafiles/copies the Database Blocks from the Primary. Once done the Duplicate finishes and leaves the Database in mount-Status. So we can now proceed with the Post-Creation Steps below.

 

 

Post-Creation Steps to make the Data Guard Environment operational

 

In the previous Chapters we prepared and created the Physical Standby Database. Now we can start the Log Transport and Log Apply Services to have the Data Guard Environment completely operational.

-          First of all we should now add Standby RedoLogs to the new created Standby Database to collect the current Redo arriving from the Primary Database. We can add those using

 

SQL> alter database add standby logfile <group #> (‘<Member>’) size <size>;

 

You should add at least one more Standby RedoLogs Group than corresponding Online RedoLog Group. See Note 219344.1 for further Details and Examples.

 

-          Next we can enable Log Transport Services on the Primary Database which have been prepared initially – performing a Logfile Switch afterwards will finally enable it (all changes to log_archive_dest_and log_archive_dest_state_n become active after the next Log Switch once set).

 

SQL> alter system set log_archive_dest_state_2 = ‘enable’ scope=both;

SQL> alter system switch logfile;

  

To verify if Standby RedoLogs get allocated on the Standby Database and so Log Transport Services are running query v$standby_log on the Standby Database:

 

SQL> select * from v$standby_log;

  

-          Assuming that Log Transport Services are running now, we can finally start Log Apply Services (Managed Recovery):

 

SQL> alter database recover managed standby database using current logfile disconnect;

 

Query v$managed_standby to monitor the Progress of the Managed Recovery:

 

SQL> select * from v$managed_standby where process = ‘MRP0’;

 

Most likely there will now be a FAL Gap Request first to ship and apply all ArchiveLogs created since we took the Backup. Depending on the Time and Amount of Redo generated on the Primary meanwhile it may take a while.

Note that starting Managed Recovery will also attempt to clear/create the Online RedoLogs on the Standby Database proactive to reduce Switchover/Failover Time.

 

Optional additional Steps

 

Basically we have now an active Data Guard Configuration. Depending on your Requirements you can proceed performing those Steps:

-          Create an SPFILE from the current PFILE on the Standby Database

-          Enable Flashback to be able to Flashback this Database (eg. instead of the Primary Database to get historical Data or avoid having to recreate the Standby Data in Case of a RESETLOGS-Operation on the Primary Database)

-          Setup and enable a Data Guard Broker Configuration – the Data Guard Broker is an Offset to Data Guard in order to make monitoring and administering of a Data Guard Configuration much easier. Note that using a Data Guard Configuration with Cloud Control (formerly Grid Control) requires the Data Guard Broker

-          Raise Protection Mode to Maximum Availability or Maximum Protection

-          Proactive setup Log Transport Services from Standby Database to the Primary and create Standby RedoLogs on the Primary for Switchover Purposes is used

-          Open the Standby Database READ ONLY and restart Managed Recovery (Active Data Guard). Note that this requires Licensing of the ‘Active Data Guard’-Option. However you can open the Standby Database open READ ONLY without Apply Services; this does not require this Option to be licensed

-          Setup Fast-Start Failover (requires the Data Guard Broker, too)

-          Add additional Standby Database(s)

-          Turn the just created Physical Standby Database into a Logical Standby Database


References

NOTE:219344.1 - Usage, Benefits and Limitations of Standby Redo Logs (SRL)
NOTE:1367014.1 - Usage and Limitation of db_file_name_convert and log_file_name_convert

在使用Python来安装geopandas包时,由于geopandas依赖于几个其他的Python库(如GDAL, Fiona, Pyproj, Shapely等),因此安装过程可能需要一些额外的步骤。以下是一个基本的安装指南,适用于大多数用户: 使用pip安装 确保Python和pip已安装: 首先,确保你的计算机上已安装了Python和pip。pip是Python的包管理工具,用于安装和管理Python包。 安装依赖库: 由于geopandas依赖于GDAL, Fiona, Pyproj, Shapely等库,你可能需要先安装这些库。通常,你可以通过pip直接安装这些库,但有时候可能需要从其他源下载预编译的二进制包(wheel文件),特别是GDAL和Fiona,因为它们可能包含一些系统级的依赖。 bash pip install GDAL Fiona Pyproj Shapely 注意:在某些系统上,直接使用pip安装GDAL和Fiona可能会遇到问题,因为它们需要编译一些C/C++代码。如果遇到问题,你可以考虑使用conda(一个Python包、依赖和环境管理器)来安装这些库,或者从Unofficial Windows Binaries for Python Extension Packages这样的网站下载预编译的wheel文件。 安装geopandas: 在安装了所有依赖库之后,你可以使用pip来安装geopandas。 bash pip install geopandas 使用conda安装 如果你正在使用conda作为你的Python包管理器,那么安装geopandas和它的依赖可能会更简单一些。 创建一个新的conda环境(可选,但推荐): bash conda create -n geoenv python=3.x anaconda conda activate geoenv 其中3.x是你希望使用的Python版本。 安装geopandas: 使用conda-forge频道来安装geopandas,因为它提供了许多地理空间相关的包。 bash conda install -c conda-forge geopandas 这条命令会自动安装geopandas及其所有依赖。 注意事项 如果你在安装过程中遇到任何问题,比如编译错误或依赖问题,请检查你的Python版本和pip/conda的版本是否是最新的,或者尝试在不同的环境中安装。 某些库(如GDAL)可能需要额外的系统级依赖,如地理空间库(如PROJ和GEOS)。这些依赖可能需要单独安装,具体取决于你的操作系统。 如果你在Windows上遇到问题,并且pip安装失败,尝试从Unofficial Windows Binaries for Python Extension Packages网站下载相应的wheel文件,并使用pip进行安装。 脚本示例 虽然你的问题主要是关于如何安装geopandas,但如果你想要一个Python脚本来重命名文件夹下的文件,在原始名字前面加上字符串"geopandas",以下是一个简单的示例: python import os # 指定文件夹路径 folder_path = 'path/to/your/folder' # 遍历文件夹中的文件 for filename in os.listdir(folder_path): # 构造原始文件路径 old_file_path = os.path.join(folder_path, filename) # 构造新文件名 new_filename = 'geopandas_' + filename # 构造新文件路径 new_file_path = os.path.join(folder_path, new_filename) # 重命名文件 os.rename(old_file_path, new_file_path) print(f'Renamed "{filename}" to "{new_filename}"') 请确保将'path/to/your/folder'替换为你想要重命名文件的实际文件夹路径。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值