ORACLE11gRAC-RACDGDuplicate搭建(生产操作文档)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
ORACLE11gRAC-RACDGDuplicate搭建(⽣产操作⽂档)环境:
rhel 6.7 64位
源库:ORACLE 11204 RAC 未打PSU
备库:ORACLE 11204 RAC PSU 20170718
⼀、停⽌中间件并做全库备份
1、在节点2做全备
2、⾸先要规划主、备库db_unique_name
主库:备库:
============================================================
db_name mgrdb db_name mgrdb
db_unique_name mgrdb db_unique_name mgrdbdg
============================================================
3、vi /etc/hosts 修改主、备共计4个节点
=========================================================
#主库
由于是⽣产系统IP 省略
#备库
由于是⽣产系统IP 省略
============================================================
⼆、源库参数设置
1、检查源库每个节点⾄少3组redo
select group#,thread#,bytes/1024/1024,members,status from v$log;
GROUP# THREAD# BYTES/1024/1024 MEMBERS STATUS
---------- ---------- --------------- ---------- ----------------
5 1 500 2 INACTIVE
6 1 500 2 INACTIVE
7 1 500 2 INACTIVE
8 1 500 2 CURRENT
9 1 500 2 INACTIVE
10 1 500 2 INACTIVE
11 2 500 2 CURRENT
12 2 500 2 INACTIVE
13 2 500 2 INACTIVE
14 2 500 2 INACTIVE
15 2 500 2 INACTIVE
GROUP# THREAD# BYTES/1024/1024 MEMBERS STATUS
---------- ---------- --------------- ---------- ----------------
16 2 500 2 INACTIVE
1节点\2节点
alter database add logfile thread 1 group 5 ('+DATA1') size 500m;
alter database add logfile thread 2 group 6 ('+DATA1') size 500m;
2、添加Standby Redo Log
如果主库是Rac数据库,standby redo log组数=(所有节点中⽇志组数最⼤值+1)*RAC节点数;
#################################################################################################
--1节点
alter database add standby logfile thread 1 group 21('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 1 group 22('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 1 group 23('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 1 group 24('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 1 group 25('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 1 group 26('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 1 group 27('+DATA1','+DATA1') size 500m;
--2节点
alter database add standby logfile thread 2 group 31('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 2 group 32('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 2 group 33('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 2 group 34('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 2 group 35('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 2 group 36('+DATA1','+DATA1') size 500m;
alter database add standby logfile thread 2 group 37('+DATA1','+DATA1') size 500m;
################################################################################################## select group#,thread#,sequence#,BYTES/1024/1024,archived,used,status from v$standby_log;
GROUP# THREAD# SEQUENCE# BYTES/1024/1024 ARC USED STATUS
---------- ---------- ---------- --------------- --- ---------- ----------
21 1 0 500 YES 0 UNASSIGNED
22 1 0 500 YES 0 UNASSIGNED
23 1 0 500 YES 0 UNASSIGNED
24 1 0 500 YES 0 UNASSIGNED
25 1 0 500 YES 0 UNASSIGNED
26 1 0 500 YES 0 UNASSIGNED
27 1 0 500 YES 0 UNASSIGNED
31 2 0 500 YES 0 UNASSIGNED
32 2 0 500 YES 0 UNASSIGNED
33 2 0 500 YES 0 UNASSIGNED
34 2 0 500 YES 0 UNASSIGNED
GROUP# THREAD# SEQUENCE# BYTES/1024/1024 ARC USED STATUS
---------- ---------- ---------- --------------- --- ---------- ----------
35 2 0 500 YES 0 UNASSIGNED
36 2 0 500 YES 0 UNASSIGNED
37 2 0 500 YES 0 UNASSIGNED
3、判断DG软件是否安装
select * from v$option where parameter = 'Oracle Data Guard';
4、允许Forced Logging
alter database force logging;
select INST_ID,name,force_logging from gv$database;
--备份原始参数⽂件
create pfile='/home/oracle/pfile0908.bak' from spfile;
!ls -ltr /home/oracle
5、设置主库初始化参数
################################################################################################## select name,db_unique_name from v$database;
--alter system set db_unique_name=mgrdb scope=spfile sid='*';
alter system set log_archive_config='dg_config=(mgrdb,mgrdbdg)' scope=spfile sid='*';
alter system set log_archive_dest_1='LOCATION=+DATA1 valid_for=(ALL_LOGFILES, ALL_ROLES) db_unique_name=mgrdb' scope=spfile sid='*';
alter system set log_archive_dest_2='SERVICE=standby OPTIONAL LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILE, PRIMARY_ROLE) DB_UNIQUE_NAME=mgrdbdg' scope=spfile sid='*';
alter system set log_archive_format = '%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_dest_state_1=enable scope=spfile sid='*';
alter system set log_archive_dest_state_2=enable scope=spfile sid='*';
alter system set remote_login_passwordfile=EXCLUSIVE scope=spfile sid='*';
alter system set log_archive_max_processes = 10 scope=spfile sid='*';
--Primary Database:Standby Role initialization parameters FAL参数定义的数据库名同样取⾃本地tnsnames.ora⾥配置的Oracle Net Service Name.
alter system set fal_server=standby scope=spfile sid='*';
alter system set standby_file_management=auto scope=spfile sid='*';
alter system set db_file_name_convert='+DATA1','+DATA1' scope=spfile sid='*'; --备端的磁盘组写前⾯
alter system set log_file_name_convert='+DATA1','+DATA1' scope=spfile sid='*'; --备端的磁盘组写前⾯
##################################################################################################
#为使修改⽣效,重启Primary Database:
alter system archive log current;
alter system archive log current;
alter system checkpoint;
alter system checkpoint;
ps -ef|grep LOCAL=NO
set pages 999
set lines 200
col machine for a30
select MACHINE,ERNAME, SID,s.SERIAL#,p.spid from v$session s,v$process p
where s.paddr = p.addr and ername is not null
order by spid;
ps -ef|grep LOCAL=NO|grep -v grep|cut -c 9-15|xargs kill -9
#分别关闭2节点
shut immediate;
#srvctl stop database -d mgrdb
#srvctl start database -d mgrdb
#重启完后,可通过下⾯语句查看修改地⽅:
set lines 500 pages 0
col value for a90
col name for a50
select name,value
from v$parameter
where name in('db_name','db_unique_name',
'log_archive_config',
'log_archive_dest_1','log_archive_dest_2',
'log_archive_dest_1',
'log_archive_dest_2',
'remote_login_passwordfile',
'log_archive_format',
'log_archive_max_processes',
'fal_server',
'db_file_name_convert',
'log_file_name_convert',
'standby_file_management')
/
6、将数据库备份、备份控制⽂件、备份参数⽂件
su - oracle
mkdir backup
rman target /
run
{allocate channel c1 type disk;
allocate channel c2 type disk;
backup filesperset 3 database format '/home/oracle/backup/full_%d_%T_%s_%p';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup archivelog from time 'sysdate-1/24' format '/home/oracle/backup/arch_%d_%T_%s_%p';
backup current controlfile for standby format '/home/oracle/backup/ctl_std';
}
7、创建备库的pfile
su - oracle
mkdir backup
sqlplus / as sysdba
CREATE PFILE='/home/oracle/backup/initstandby.ora' FROM SPFILE;
--查看备份出来的参数⽂件
cat /home/oracle/backup/initstandby.ora
#################################################################################
mgrdb1.__db_cache_size=14629732352
mgrdb2.__db_cache_size=14361296896
mgrdb1.__java_pool_size=939524096
mgrdb2.__java_pool_size=939524096
mgrdb1.__large_pool_size=134217728
mgrdb2.__large_pool_size=402653184
mgrdb1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
mgrdb2.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
mgrdb1.__pga_aggregate_target=39996882944
mgrdb2.__pga_aggregate_target=39460012032
mgrdb1.__sga_target=24427626496
mgrdb2.__sga_target=24964497408
mgrdb1.__shared_io_pool_size=0
mgrdb2.__shared_io_pool_size=0
mgrdb1.__shared_pool_size=7784628224
mgrdb2.__shared_pool_size=8321499136
mgrdb1.__streams_pool_size=268435456
mgrdb2.__streams_pool_size=268435456
*.audit_file_dest='/u01/app/oracle/admin/mgrdb/adump'
*.audit_trail='db'
*.cluster_database=true
*.compatible='11.2.0.4.0'
*.control_files='+DATA1/mgrdb/controlfile/current.260.834178123','+DATA1/mgrdb/controlfile/current.3076.947956273'
*.db_block_size=8192
*.db_create_file_dest='+DATA1'
*.db_domain=''
*.db_file_name_convert='+DATA1','+DATA1'
*.db_name='mgrdb'
*.diagnostic_dest='/u01/app/oracle'
*.fal_server='STANDBY'
mgrdb1.instance_number=1
mgrdb2.instance_number=2
*.job_queue_processes=1000
*.log_archive_config='dg_config=(mgrdb,mgrdbdg)'
*.log_archive_dest_1='LOCATION=+DATA1 valid_for=(ALL_LOGFILES, ALL_ROLES) db_unique_name=mgrdb'
*.log_archive_dest_2='SERVICE=standby OPTIONAL LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILE, PRIMARY_ROLE) DB_UNIQUE_NAME=mgrdbdg'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=10
*.log_buffer=306790400
*.log_file_name_convert='+DATA1','+DATA1'
*.memory_max_target=64424509440
*.memory_target=64424509440
*.open_cursors=300
*.parallel_force_local=FALSE
*.pga_aggregate_target=25769803776
mgrdb2.pga_aggregate_target=0
mgrdb1.pga_aggregate_target=0
*.processes=1000
*.remote_listener='scanip:1521'
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=1600
*.sga_max_size=38654705664
mgrdb2.sga_max_size=64424509440
mgrdb1.sga_max_size=64424509440
*.sga_target=38654705664
mgrdb1.sga_target=0
mgrdb2.sga_target=0
*.shared_pool_reserved_size=288568115
mgrdb2.shared_pool_reserved_size=524288000
mgrdb1.shared_pool_reserved_size=524288000
*.shared_pool_size=805306368
mgrdb1.shared_pool_size=0
mgrdb2.shared_pool_size=0
*.standby_file_management='AUTO'
*.streams_pool_size=268435456
mgrdb2.thread=2
mgrdb1.thread=1
*.undo_retention=86400
mgrdb2.undo_tablespace='UNDOTBS2'
mgrdb1.undo_tablespace='UNDOTBS1'
*.undo_tablespace='UNDOTBS2'
################################################################################# 8、修改主库tnsnames.ora 【两个节点都要修改】
#修改1节点:
vi $ORACLE_HOME/network/admin/tnsnames.ora
#拷贝到2节点
scp $ORACLE_HOME/network/admin/tnsnames.ora HOSTNAME:$ORACLE_HOME/network/admin ########################################################################33 primary =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = public ip )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mgrdb)
)
)
primary1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = vip1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mgrdb)
(SID = mgrdb1)
)
)
primary2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = vip2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mgrdb)
(SID = mgrdb2)
)
)
########################################################################
三、准备备库RAC Database
1、复制参数⽂件
从主库备份出来的参数拷贝到备库上,选择⼀个节点
在主库上:
scp /home/oracle/backup/initstandby.ora hostname:/app/u01/oracle/product/11.2.0/db_1/dbs/initstandby.ora
2、复制源端密码⽂件
配置DG需要两边数据库密码保持⼀致,把主库的密码⽂件分别拷贝到【备库两个节点】
在主库上:
cd $ORACLE_HOME/dbs/
scp orapwmgrdb1 hostname:/app/u01/oracle/product/11.2.0/db_1/dbs/
scp orapwmgrdb1 hostname:/app/u01/oracle/product/11.2.0/db_1/dbs/
拷贝完后修改【备库第⼆节点】的密码⽂件名:
在备库2节点:
cd $ORACLE_HOME/dbs/
mv orapwmgrdb1 orapwmgrdb2
3、将主库备份⽂件拷贝到备端【因为⽤DUPLICATE⽅式,此步不做】
#scp -r /home/oracle/backup hostname:/home/oracle
4、按照参数⽂件中指定的⽬录去创建相关⽬录
【备端1节点】:
su - oracle
mkdir -p /app/u01/oracle/admin/mgrdbdg/adump
chmod 775 /app/u01/oracle/admin/mgrdbdg/adump
【备端2节点】:
mkdir -p /app/u01/oracle/admin/mgrdbdg/adump
chmod 775 /app/u01/oracle/admin/mgrdbdg/adump
5、【修改备库参数⽂件】
加注释的为修改的地⽅,其他保留即可
cd $ORACLE_HOME/dbs
vi initstandby.ora
##################################################################################################
*.audit_file_dest='/app/u01/oracle/admin/mgrdbdg/adump' =============
*.audit_trail='db'
*.cluster_database=true
*.compatible='11.2.0.4.0'
*.control_files='+DATA1/mgrdbdg/controlfile/control01.ctl' =============
*.db_block_size=8192
*.db_create_file_dest='+DATA1' =============
*.db_domain=''
*.db_file_name_convert='+DATA1','+DATA1' =============
*.db_name='mgrdb'
*.db_unique_name='mgrdbdg' =============
*.diagnostic_dest='/oracle/app/oracle' =============
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orcldbXDB)'
*.fal_server='primary' =============
orcldb2.instance_number=2
orcldb1.instance_number=1
*.log_archive_config='dg_config=(mgrdb,mgrdbdg)'
*.log_archive_dest_1='LOCATION=+DATA1 valid_for=(ALL_LOGFILES, ALL_ROLES) db_unique_name=mgrdbdg' ============= *.log_archive_dest_2='SERVICE=primary OPTIONAL LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILE, PRIMARY_ROLE) DB_UNIQUE_NAME=mgrdb' =============
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=10
*.log_file_name_convert='+DATA1','+DATA1' =============
*.open_cursors=300
*.pga_aggregate_target=545259520 =============
*.processes=150
*.remote_listener='scanip:1521' =============
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=817889280
*.standby_file_management='AUTO'
orcldb2.thread=2
orcldb1.thread=1
orcldb2.undo_tablespace='UNDOTBS2'
orcldb1.undo_tablespace='UNDOTBS1'
##################################################################################################
*.audit_file_dest='/app/u01/oracle/admin/mgrdbdg/adump'
*.audit_trail='db'
*.cluster_database=true
*.compatible='11.2.0.4.0'
*.control_files='+DATA1/mgrdbdg/controlfile/control01.ctl','+DATA1/mgrdbdg/controlfile/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='+DATA1'
*.db_domain=''
*.db_file_name_convert='+DATA1','+DATA1'
*.db_name='mgrdb'
*.diagnostic_dest='/app/u01/oracle'
*.fal_server='primary'
mgrdb1.instance_number=1
mgrdb2.instance_number=2
*.job_queue_processes=1000
*.log_archive_config='dg_config=(mgrdb,mgrdbdg)'
*.log_archive_dest_1='LOCATION=+DATA1 valid_for=(ALL_LOGFILES, ALL_ROLES) db_unique_name=mgrdbdg'
*.log_archive_dest_2='SERVICE=primary OPTIONAL LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILE, PRIMARY_ROLE) DB_UNIQUE_NAME=mgrdb'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=10
*.log_buffer=306790400
*.log_file_name_convert='+DATA1','+DATA1'
*.memory_max_target=64424509440
*.memory_target=64424509440
*.open_cursors=300
*.parallel_force_local=FALSE
*.pga_aggregate_target=25769803776
mgrdb2.pga_aggregate_target=0
mgrdb1.pga_aggregate_target=0
*.processes=1000
*.remote_listener='scanip:1521'
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=1600
*.sga_max_size=38654705664
mgrdb2.sga_max_size=64424509440
mgrdb1.sga_max_size=64424509440
*.sga_target=38654705664
mgrdb1.sga_target=0
mgrdb2.sga_target=0
*.shared_pool_reserved_size=288568115
mgrdb2.shared_pool_reserved_size=524288000
mgrdb1.shared_pool_reserved_size=524288000
*.shared_pool_size=805306368
mgrdb1.shared_pool_size=0
mgrdb2.shared_pool_size=0
*.standby_file_management='AUTO'
*.streams_pool_size=268435456
mgrdb2.thread=2
mgrdb1.thread=1
*.undo_retention=86400
mgrdb2.undo_tablespace='UNDOTBS2'
mgrdb1.undo_tablespace='UNDOTBS1'
*.undo_tablespace='UNDOTBS2'
################################################################################################## 6、【备库1节点】创建ASM路径
通过grid⽤户进⼊到asmcmd,在备库磁盘组下创建db_unique_name⽬录
su - grid
asmcmd
ASMCMD> mkdir DATA1/mgrdbdg
7、修改备库tnanames.ora 两个节点都要修改
修改【备库1、2节点】tnanames.ora
vi $ORACLE_HOME/network/admin/tnsnames.ora
scp $ORACLE_HOME/network/admin/tnsnames.ora hostname:$ORACLE_HOME/network/admin
################################################################################################## standby =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = scan-ip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mgrdbdg)
)
)
standby1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = vip1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mgrdbdg)
(SID = mgrdb1)
)
)
standby2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = vip2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = standby)
(SID = mgrdb2)
)
)
primary =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = scan-ip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mgrdb)
)
)
--标注的primary服务名必须添加,否则启动mrp时⽇志会报如下错误:
Error 12154 received logging on to the standby
FAL[client, MRP0]: Error 12154 connecting to orcldb fro fetching gap sequence
FAIL_CLIENT 和 FAIL_SERVER 这两个参数值都需指定⽹络服务器,并⾮是db_unique_name
FAL_SERVER=net_service_name
FAL_CLIENT=net_service_name
##################################################################################################
四、创建物理备库
1、使⽤修改好的参数备库实例启动到nomount
连接到oracle⽤户,使⽤上⾯已修改好的参数⽂件将备库实例启动到nomount
仅在【备库的1节点】操作:
echo $ORACLE_SID
mgrdb1
sqlplus / as sysdba
startup nomount pfile = '$ORACLE_HOME/dbs/initstandby.ora'
2、RMAN Duplicate复制数据库
使⽤Rman Duplicate ⽅式,须先配置监听,添加静态服务名。
Oracle 11gR2开始,所有⾼可⽤架构,如oracle restart,rac等,监听器的创建和管理都是由grid⽤户完成。
在【备库1节点】:
su - grid
cd $ORACLE_HOME/network/admin
cp listener.ora listener.ora.bak
cp endpoints_listener.ora endpoints_listener.ora.bak
vi listener.ora
【添加】以下⾏:
===================================================
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = ANYTHING))
(ADDRESS = (PROTOCOL = TCP)(HOST = public ip)(PORT = 1521))
) )
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = mgrdbdg)
(ORACLE_HOME = /app/u01/oracle/product/11.2.0/db_1)
(SID_NAME = mgrdb1)
) )
===================================================
#重启监听器并查看:
su - grid
grid> srvctl stop listener -n mgrdb1
grid> srvctl start listener -n mgrdb1
grid> lsnrctl status --正常应该显⽰如下信息
Service "mgrdbdg" has 1 instance(s).
Instance "mgrdb1", status UNKNOWN, has 1 handler(s) for this service... Instance "mgrdb1", status BLOCKED, has 1 handler(s) for this service...
#在【主库1节点】 tnsnames.ora 中【添加】下⾯信息
su - oracle
cd $ORACLE_HOME/network/admin
vi tnsnames.ora
添加如下内容:
======================================================== STANDBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = public ip)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mgrdbdg)
)
========================================================
启动监听,【主备库】共计4个节点都要测试
主库1节点
tnsping standby 3
tnsping primary 3
在主库1节点测试
sqlplus 'sys/"XXXX"'@standby as sysdba
在进制Rman Duplicate操作之前,我们还要修改oracle⼆进制命令的权限,参考下⾯:
----------------------------------------------------------------------------------
During 11.2 Gird Infrastructure installation, it prompts to select ASM admin group and AS
M dba group. Assume asmadmin is used for ASM admin group and asmdba is used for
ASM dba group.
Only users that are members of the asmadmin group have direct access to ASM disks an
d maintenance. For other databas
e users (software owners or dba group users), the acce
ss is gained via the oracle executable ($ORACLE_HOME/bin/oracle). It should have a setg
id bit with group set to "asmadmin".
The 11.2 "oracle" binary is changed automatically via setasmgidwrap when the instance i
s started by the CRS daemon (e.g. srvctl start database/instance). But for earlier release,
the "oracle" binary group and ownership need to be set manually.
----------------------------------------------------------------------------------
#在【备库1节点】操作:
su - grid
ls -lrt /app/u01/oracle/product/11.2.0/db_1/bin/oracle
-rwsr-s--x 1 oracle oinstall 239626641 Dec 29 2015 /app/u01/oracle/product/11.2.0/db_1/bin/oracle /app/u01/11.2.0/grid/bin/setasmgidwrap -o=/app/u01/oracle/product/11.2.0/db_1/bin/oracle
[grid@mgrdb1 ~]$ ls -l /app/u01/oracle/product/11.2.0/db_1/bin/oracle
-rwsr-s--x 1 oracle asmadmin 239869951 Sep 8 10:20 /app/u01/oracle/product/11.2.0/db_1/bin/oracle 如果从主库连备库
sqlplus 'sys/"XXX"'@standby as sysdba
报ORA-12537: TNS:connection closed
是因为$ORACLE_HOME/bin/oracle权限有问题,使⽤下⾯命令修改:
chmod u+s oracle
chmod g+s oracle
显⽰如下:
[oracle@mgrdb1 bin]$ pwd
/app/u01/oracle/product/11.2.0/db_1/bin
[oracle@mgrdb1 bin]$ ls -l oracle
-rwsr-x--x 1 oracle asmadmin 239869951 Sep 8 10:20 oracle
如果不做上⾯的操作,在进⾏下⾯ DUPLICATE 复制操作时候会报 ASMLib 驱动错误:
---------------------------------------------------------------------------
ORA-15183: ASMLIB initialization error [driver/agent not installed]
WARNING: FAILED to load library: /opt/oracle/extapi/64/asm/orcl/1/libasm.so
Errors in file /u01/app/oracle/diag/rdbms/standby/standby1/trace/standby1_rbal_13010.trc:
ORA-15183: ASMLIB initialization error [driver/agent not installed]
Mon Sep 03 09:30:10 2012
SUCCESS: diskgroup SDATA was mounted
Errors in file /u01/app/oracle/diag/rdbms/standby/standby1/trace/standby1_ora_13390.trc (incident=305):
ORA-00600: internal error code, arguments: [kfioTranslateIO03], [], [], [], [], [], [], [],
[], [], [], []
Incident details in: /u01/app/oracle/diag/rdbms/standby/standby1/incident/incdir_305/standb
y1_ora_13390_i305.trc
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Mon Sep 03 09:30:18 2012
Dumping diagnostic data in directory=[cdmp_20120903093018], requested by (instance=1,
osid=13390), summary=[incident=305].
Errors in file /u01/app/oracle/diag/rdbms/standby/standby1/trace/standby1_ora_13390.trc
(incident=306):
ORA-00600: internal error code, arguments: [17090], [], [], [], [], [], [], [], [], [], [], []
Incident details in: /u01/app/oracle/diag/rdbms/standby/standby1/incident/incdir_306/standb
y1_ora_13390_i306.trc
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
ERROR: unrecoverable error ORA-600 raised in ASM I/O path; terminating process 13390
Dumping diagnostic data in directory=[cdmp_20120903093019], requested by (instance=1,
osid=13390), summary=[incident=306].
Mon Sep 03 09:30:20 2012
---------------------------------------------------------------------------
#正式开始 RAMN DUPLICATE 复制
在【主库1节点上】操作【************⼀定要⽤后台脚本执⾏************】:
#su - oracle
#rman target / auxiliary sys/XXX@standby
#RMAN> DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE NOFILENAMECHECK;
#查看⾮OMF类型的⽂件,然后加到脚本⾥:
select file#,name from v$datafile;
⾃动传输脚本:dup-mgrdb.sh
注意,如果⽂件名不是ASM ⾃动命令格式,需要SET newname。
su - root
cd /home/oracle
touch dup-mgrdb.sh
chmod +x dup-mgrdb.sh
=================================================================
su - oracle -c "
rman target / auxiliary 'sys/"XXXX"'@standby << EOF
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
allocate channel d5 type disk;
allocate channel d6 type disk;
allocate channel d7 type disk;
set newname for datafile 3 to '+DATA1';
set newname for datafile 5 to '+DATA1';
set newname for datafile 6 to '+DATA1';
set newname for datafile 7 to '+DATA1';
set newname for datafile 8 to '+DATA1';
set newname for datafile 9 to '+DATA1';
set newname for datafile 10 to '+DATA1';
set newname for datafile 11 to '+DATA1';
set newname for datafile 12 to '+DATA1';
set newname for datafile 16 to '+DATA1';
DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER NOFILENAMECHECK; }
EOF
"
=================================================================
nohup ./dup-mgrdb.sh > dup-mgrdb.log 2>&1 &
-----------------------------------------------------------------------------
完整输出内容:
Starting Duplicate Db at 2017-09-01 05:08:21
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=33 instance=orcldb1 device type=DISK
contents of Memory Script:
{
backup as copy reuse
targetfile '/oracle/app/oracle/product/11.2.0/db_1/dbs/orapworcldb1' auxiliary format
'/oracle/app/oracle/product/11.2.0/db_1/dbs/orapworcldb1' ;
}
executing Memory Script
Starting backup at 2017-09-01 05:08:22
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 instance=orcldb1 device type=DISK
Finished backup at 2017-09-01 05:08:23
contents of Memory Script:
{
backup as copy current controlfile for standby auxiliary format '+DATA1/standby/controlfile/control01.ctl';
}
executing Memory Script
Starting backup at 2017-09-01 05:08:23
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/oracle/app/oracle/product/11.2.0/db_1/dbs/snapcf_orcldb1.f tag=TAG20170901T050824 RECID=1 STAMP=953528905 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 2017-09-01 05:08:28
contents of Memory Script:
{
sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.
contents of Memory Script:
{
set newname for tempfile 1 to
"+stdatadg";
switch clone tempfile all;
set newname for datafile 1 to
"+stdatadg";
set newname for datafile 2 to
"+stdatadg";
set newname for datafile 3 to
"+stdatadg";
set newname for datafile 4 to
"+stdatadg";
set newname for datafile 5 to
"+stdatadg";
set newname for datafile 6 to
"+stdatadg";
backup as copy reuse
datafile 1 auxiliary format
"+stdatadg" datafile
2 auxiliary format
"+stdatadg" datafile
3 auxiliary format
"+stdatadg" datafile
4 auxiliary format
"+stdatadg" datafile
5 auxiliary format
"+stdatadg" datafile
6 auxiliary format
"+stdatadg" ;
sql 'alter system archive log current';
}
executing Memory Script。