Oracle DataGuard 物理Standby 搭建
Oracle DataGuard 物理Standby 搭建
分类: Oracle
物理standby database 环境搭建
Arch asysnc
Oracle Dataguard
primary
host: primary
IP: 192.168.198.136
Oracle_sid: dgtest
DB_unique_name: dg_pd
FAL_server: dg_st
FAL_client: dg_pd
standby
host: standy
IP: 192.168.198.128
Oracle_sid: dgtest
DB_unique_name: dg_st
FAL_server: dg_pd
FAL_client: dg_st
一. Primary 端的配置
1. 主库设置为force logging 模式
SQL> alter database force logging;
2.修改归档日志存放路径:
mkidr -p /u01/archive/
chown -R oracle:oinstall /u01/archive/
chmod 775 /u01/archive/
SQL>alter system set log_archive_dest_1='location=/u01/archive/' scope=both;
3. 主库设为归档模式
SQL> archive log list;
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> archive log list;
4. 创建备库的密码文件和控制文件
SQL> alter database create standby controlfile as '$ORACLE_BASE/oradata/dgtest/standby01.ctl';
-- 说明: 判断一个数据库是Primary还是Standby,就是通过控制文件来判断的。
[oracle@localhostdbs]$ orapwd file=$ORACLE_HOME/dbs/orapwdgtest password=oracle
如果已经存在,就不用创建了。 缺省情况下,win下口令文件的格式是pwdsid.ora,unix下的格式是orapwSID(大小写敏感)
5. 修改初始化参数文件
*.DB_UNIQUE_NAME='dg_pd'
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(dg_pd,dg_st)'
*.log_archive_dest_1='location=/u01/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=dg_pd'
*.LOG_ARCHIVE_DEST_2='SERVICE=dg_st ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg_st '
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.standby_file_management='AUTO'
*.FAL_SERVER='dg_st'
*.FAL_CLIENT='dg_pd'
如果主库和备库的数据文件位置不同,还需要加如下2个参数:
*.log_file_name_convert='/u02/oradata/dgtest/','/u03/oradata/dgtest/'
*.db_file_name_convert='/u02/oradata/dgtest/','/u03/oradata/dgtest/'
-- 注意:orcl_st,orcl_pd 是在tnsnames文件中配置的
用'$ORACLE_HOME/dbs/initdgtest.ora' 这个pfile 启动数据库,并生成spfile。
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup pfile='$ORACLE_HOME/dbs/initdgtest.ora';
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 79694068 bytes
Database Buffers 83886080 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL> create spfile from pfile='$ORACLE_HOME/dbs/initdgtest.ora';
File created.
6. 修改listener.ora 和tnsnames.ora 文件
Listener.ora 文件:$ORACLE_HOME/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESC