- 最后登录
- 2014-1-13
- 在线时间
- 2 小时
- 威望
- -5
- 金钱
- 17
- 注册时间
- 2014-1-2
- 阅读权限
- 0
- 帖子
- 8
- 精华
- 0
- 积分
- -5
- UID
- 1615
|
3#
发表于 2014-1-10 13:41:49
/* 创建文档资料时间:2013-12-26
搭建11gR2(11.2.0.):利用SQL设定单机&单机的参数配置--V1.0
#====================================================================================#
#配置环境: #
#OS version:Linux 5.8 64 #
#Lvm version:LVM & ASM #
#Oracle version: Oracle 11g[11.2.0.4/5] #
#====================================================================================#
#Environment Information
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
*/
====================================================================================================
#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
#===========================================================#
#Dataguard 配置过程步骤 #
#===========================================================#
Step 1、打开主库DB系统强制归档
===================================
--#Set the following Initialization Parameters on the Primary Database:
col DBID for 9999999999
col name for a30
col force_logging for a35
select dbid,name,force_logging from gv$database;
startup mount;
alter database force logging;
alter database open;
select force_logging,dataguard_brker,guard_status from V$database;
Step 2、在备库上安装与主库一样版本Oracle Software
==================================================
command:
opatch lsinventory
Step 3、在备库上使用NETCA配置好监听
===================================
Step 4、在主备库上配置TNSNAMES.ORA
===================================
command:
cd $ORACLE_HOME/network/admin/
Example Entries in the tnsnames.ora Files:
==========================================
Primary Net Service Names:
--------------------------
prim_db =
(description =
(address = (protocol = tcp)(host = 168.8.19.130)(port = 1521))
(connect_data =
(server = dedicated)
(service_name = prim_db)
(instance_name = prim_db)
)
)
Standby Net Service Name:
-------------------------
stby_db =
(description =
(address_list =
(address = (protocol = tcp)(host = 168.8.19.27)(port = 1521))
)
(connect_data =
(service_name = stby_db)
)
)
Step 5、修改主备DB上parameter参数
===================================
#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
command:
cd $ORACLE_BASE/admin/<SID>/pfile
export ORACLE_SID=<SID>
SQL>create pfile='<SID>_pfile.ora' from spfile;
# Primary Initialization parameters:
==================================
-- #设定使用FAST_BACKUP功能
alter system set db_recovery_file_dest_size= 400G scope=spfile sid='*';
alter system set db_recovery_file_dest='+ASMDATA' scope=spfile sid='*';
===============================================================================
/*#为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
*/
-- #设定Active Dataguard 相关参数
alter system set db_unique_name = 'prim_db' scope=spfile sid='*';
alter system set log_archive_config='dg_config=(prim_db,stby_db)' scope=spfile sid='*';
alter system set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=prim_db' scope=spfile sid='*';
alter system set log_archive_dest_2='service=stby_db lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=stby_db compression=enable' scope=spfile sid='*';
alter system set log_archive_format='prim_db_%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_dest_state_2='defer' scope=spfile sid='*';
alter system set log_archive_max_processes = 8 scope=spfile sid='*';
Standby Initialization parameters
===================================
#提前规划并设定好USE_DB_RECOVERY_FILE_DEST目录
-- #设定使用FAST_BACKUP功能
alter system set db_recovery_file_dest_size= 400G scope=spfile sid='*';
alter system set db_recovery_file_dest='+ASMDATA' scope=spfile sid='*';
/*
#Modify the following Initialization Parameters in the PFILE (initstby_db.ora) for the Standby Database we created before:
*.db_name='prim_db'
*.db_unique_name = 'stby_db'
*.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 = 'primary online redolog files','standby online redolog files'
*.db_file_name_convert = 'primary daafiles','standby datafiles'
*/
-- #设定Active Dataguard 相关参数
alter system set db_unique_name = 'stby_db' scope=spfile sid='*';
alter system set log_archive_config='dg_config=(prim_db,stby_db)' scope=spfile sid='*';
alter system set log_archive_format='stby_db_%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_max_processes = 8 scope=spfile sid='*';
alter system set fal_server = 'prim_db' scope=spfile sid='*';
alter system set log_file_name_convert = 'primary online redolog files','standby online redolog files' scope=spfile sid='*';
alter system set db_file_name_convert = 'primary daafiles','standby datafiles' scope=spfile sid='*';
Step 6、Copy database orapw口令文件
===================================
- Copy the orapw<sid>.ora file from the OH/dbs directory of the primary to the same location on the standby.
$ export ORACLE_SID=zhtfkb
$ cd $ORACLE_HOME/dbs
$ orapwd file=orapwzhtfkb password=oracle
也可以从生产系统上直接Copy到Standby Database服务器上,然后再根据实例名,重命名此orapw* 文件
cp $ORACLE_HOME/dbs/orapw<SID>* .
Step 7、Create the standby controlfile
=======================================
#Primary :
=========
sql>startup mount;
sql>alter database create standby controlfile as ‘/backup/control01.ctl’;
sql>alter database open;
- ftp / scp the stdby.ctl file to the standby site. we can multiplex this by making
copies of this stdby.ctl on different mountpoints on the standby and editing the
control_files parameter in the init.ora to reflect this.
dd if=/tmp/stdby_controlfile.ctl of=/dev/rzhtfkb_ctl01
dd if=/tmp/stdby_controlfile.ctl of=/dev/rzhtfkb_ctl02
dd if=/tmp/stdby_controlfile.ctl of=/dev/rzhtfkb_ctl03
也可以通过RMAN备份集,使用rman 恢复出standby controlfile
In RMAN, connect to primary database and create standby control file backup:
RMAN> backup current controlfile for standby;
将备库启动到nomount状态,并且确定好raw上的controlfile文件的位置。
sql> show parameter control_files
RMAN> restore standby controlfile from '................'
RMAN> alter database mount; |
|