首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Oracle11gR2 rac与+单机Dataguard安装详细说明

一、安装环境、

注意:standby数据库只安装数据库软件不需要创建数据库。

二、主库配置

1、/etc/hosts添加主库与备库信息

2、检查数据库有没有开归档

archive log list;

3、检查是否开强制写日志

select force_logging from v$database;

如果没有开启,我们打开

alter database force logging;

4、查看归档路径、设置归档路径和大小

show parameter recover

5、创建standby日志文件组

select * from v$logfile;

select * from v$log;

select * from v$standby_log;

日志比现有的多一组,每个文件比原有文件大2M;

主加,备在恢复时自动加

alter system setstandby_file_management=manual scope=both sid='*';

alter database add standby logfile thread 1group 9 '+GDDATA' size 202M;

alter database add standby logfile thread 1group 10 '+GDDATA' size 202M;

alter database add standby logfile thread 1group 11 '+GDDATA' size 202M;

alter database add standby logfile thread 1group 12 '+GDDATA' size 202M;

alter database add standby logfile thread 1group 13 '+GDDATA' size 202M;

alter database add standby logfile thread 2group 14 '+GDDATA' size 202M;

alter database add standby logfile thread 2group 15 '+GDDATA' size 202M;

alter database add standby logfile thread 2group 16 '+GDDATA' size 202M;

alter database add standby logfile thread 2group 17 '+GDDATA' size 202M;

alter database add standby logfile thread 2group 18 '+GDDATA' size 202M;

alter system setstandby_file_management=auto scope=both sid='*';

6、主库的原有参数不变,添加以下参数。

alter system setLOG_ARCHIVE_CONFIG='DG_CONFIG=(racdb,standbydb)' scope=both sid='*';

alter system setLOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DESTVALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdb' scope=both sid='*';

alter system set LOG_ARCHIVE_DEST_2='SERVICE=standbydbLGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standbydb'scope=both sid='*';

alter system setlog_archive_format='%t_%s_%r.arc' scope=spfile sid='*';

alter system set fal_client='racdb'scope=both sid='*';

alter system set FAL_SERVER='standbydb'scope=both sid='*';

alter system setDB_FILE_NAME_CONVERT='/oracle/oradata/racsys','+GDSYSTEM/racdb/datafile','/oracle/oradata/racdata','+GDDATA/racdb/datafile','/oracle/oradata/tempfile','+GDSYSTEM/racdb/tempfile'scope=spfile sid='*';

alter system setLOG_FILE_NAME_CONVERT='/oracle/oradata/onlinelog','+GDDATA/racdb/onlinelog'scope=spfile sid='*';

alter system setstandby_file_management=AUTO scope=both sid='*';

alter system reset DB_CREATE_FILE_DESTscope=spfile sid='*';

重启两个节点数据库

srvctl stop database –d racdb;

srvctl start database –d racdb;

select name from v$datafile;

select name from v$tempfile;

select * from v$logfile;

7、配置监听tnsnames.ora

rac和standby上的tnsname.ora相同

RACDB =

(DESCRIPTION =

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = racdb)

)

)

racdb1 =

(DESCRIPTION =

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

(CONNECT_DATA=

(SERVER = DEDICATED)

(SERVICE_NAME = racdb)

(SID=racdb1)

)

)

racdb2 =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = racdb)

(SID=racdb2)

)

)

standbydb =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVICE_NAME = standbydb)

)

)

拷贝到rac2上

8、配置静态监听

主增加:

Grid用户下:listener.ora

Rac1下的

SID_LIST_LISTENER=

(SID_LIST=

(SID_DESC=(GLOBAL_DBNAME=racdb)

(ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1)

(SID_NAME=racdb1)

)

)

Rac2下的

SID_LIST_LISTENER=

(SID_LIST=

(SID_DESC=(GLOBAL_DBNAME=racdb)

(ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db_1)

(SID_NAME=racdb2)

)

)

重新加载监听配置

lsnrctl reload

测试

tnsping standbydb

9、备份主库

rman target /

backup database format'/soft/racdbfull%u_%s_%p';

create pfile='/soft/standby.pfile' fromspfile;

三、备库的配置

1、拷贝数据库备份和参数文件(注意和主库的目录相同位置)

chown -R oracle:dba /soft

chmod -R 775 /soft

拷贝备份的数据文件和参数文件

根据备库参数文件,创建以下目录:

mkdir -p/oracle/app/oracle/admin/standbydb/adump

mkdir -p/oracle/app/oracle/diag/rdbms/standbydb

cd /oracle/app/oracle/diag/rdbms/standbydb

2、从rac主库拷贝密码文件$ORACLE_HOME/dbs/orapwracdb1到备库对应位置

修改密码文件的名字

mv orapwracdb1 orapwstandbydb(orapw+实例名standbydb)与环境变量中的sid相同

3、修改备份的参数文件

*.audit_file_dest='/oracle/app/oracle/admin/standbydb/adump'

*.audit_trail='db'

*.compatible='11.2.0.4.0'

*.control_files='/oracle/oradata/control01.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_name='racdb'

*.db_unique_name='standbydb'

*.db_recovery_file_dest='/oracle/oradata'

*.diagnostic_dest='/oracle/app/oracle'

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='exclusive'

*.standby_file_management='AUTO'

4、配置监听文件

从主库拷贝tnsname.ora到备库对应位置

5、配置静态监听listener.ora

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = standbydb)

(ORACLE_HOME = /oracle/product/11.2.0/dbhome_1)

(SID_NAME = standbydb)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

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

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

)

)

ADR_BASE_LISTENER = /oracle

重新加载监听文件

lsnrctl reload

lsnrctl status

测试监听

sqlplus sys/oracle@standbydb as sysdba;

6、环境变量中添加

ORACLE_UNQNAME=standbydb

7、创建spfile

startuppfile='/oracle/oradata/standby.pfile' nomount;

create spfile frompfile='/oracle/oradata/standby.pfile'

shutdown immediate;

startup nomount;

检查spfile文件是不是创建了。

show parameter spfile。确认用的是不是对应位置的spfile。

8、创建对应目录

mkdir -p /oracle/oradata/standbydb

mkdir -p /oracle/oradata/racdata

mkdir -p /oracle/oradata/tempfile'

mkdir -p /oracle/oradata/onlinelog

9、修改备库参数

alter system setLOG_ARCHIVE_CONFIG='DG_CONFIG=(standbydb,racdb)' scope=both sid='*';

alter system setLOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES)DB_UNIQUE_NAME=standbydb' scope=both sid='*';

alter system setLOG_ARCHIVE_DEST_2='SERVICE=racdb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdb'scope=both sid='*';

alter system setlog_archive_format='%t_%s_%r.arc' scope=spfile sid='*';

alter system set FAL_SERVER='racdb'scope=both sid='*';

alter system set fal_client='standbydb'scope=both sid='*';

alter system set DB_FILE_NAME_CONVERT='+GDSYSTEM/racdb/datafile','/oracle/oradata/standbydb','+GDDATA/racdb/datafile','/oracle/oradata/racdata','+GDSYSTEM/racdb/tempfile','/oracle/oradata/tempfile'scope=spfile sid='*';

alter system setLOG_FILE_NAME_CONVERT='+GDDATA/racdb/onlinelog','/oracle/oradata/onlinelog'scope=spfile sid='*';

alter system setstandby_file_management=AUTO scope=both sid='*';

修改备库初始化参数文件,最终是这样:

注意点有:

db_file_name_convert时,因为使用ASM,DATAFILE和TEMPFILE的都要写上。

log_file_name_convert时,因为使用了在不同磁盘组的多镜像,也需要都写上。

audit_file_dest指定的目录要手动去创建。

control_files尽量写一个,少出错。可以在STANDBY备库创建好后再增加镜像。

log_archive_dest_1指定的目录要创建一下。.log_archive_dest_2是为了SWITCHOVER或FAILOVER时备库切换为主库用的。

db_unique_name需要手动添加上。

10、检查归档

show parameter recover

alter system set db_recovery_file_dest=’/oracle/oradata’;

重启数据库

shutdown immediate;

startup nomount;

四、创建物理Dataguard(ADG)

1、备库操作

rman target sys/oracle@racdb1 auxiliarysys/oracle@standbydb

rman target sys/oracle@racdb1 auxiliary /

恢复备份片

duplicate target database for standby;

2、检查备库的运行状态

select open_mode from v$database;

select member from v$logfile;

select * from v$standby_log;

select name from v$datafile;

select name from v$tempfile;

show parameter control

show parameter recover

检查物理文件

ls -lsR

查看归档目录

查看当前数据库的运行状态

select open_mode,protection_mode,activation#,database_role,switchover#,switchover_statusfrom v$database;

3、启动mrp

alter database recover managed standbydatabase disconnect from session;

关闭mrp

alter database recover managed standbydatabase cancel;

检查后台日志

4、先停止mrp进程,在启动adg模式

alter database recover managed standbydatabase cancel;

alter database open;

alter database recover managed standbydatabase disconnect from session;

5、切换日志测试

alter system switch logfile;

欢迎关注“自学Oracle”

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20180829G0IJKS00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券