标签:
虚拟机系统
ORACLE11g R2 RAC+DG FOR OEL6.5安装实施报告
目录
shutdown immediate; startup mount; alter system archive log; |
alter database force logging; |
查看日志和数据文件的位置,便于数据文件的目录转换。
select name from v$datafile; select group#,member from v$logfile; show parameter controlfile; |
Vi /etc/hosts 192.168.0.61 rac1 192.168.0.62 rac2 192.168.0.63 rac1-vip 192.168.0.64 rac2-vip 192.168.0.65 scan-ip 192.168.0.66 scan-ip 192.168.1.11 rac1-priv1 192.168.2.11 rac1-priv2 192.168.1.12 rac2-priv1 192.168.2.12 rac2-priv2
192.168.0.104 dg1 |
ORACLE = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.66)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORACLE) ) ) ORCLDG= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.104)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCLDG) ) ) |
3)拷贝密码文件到目标机(改名字)
4)双机访问。是否成功
sqlplus sys/123@orcldg as sysdba
sqlplus sys/123@oracle as sysdba
1)使用命令行配置参数:(主库)
alter system set fal_client=oracle ; alter system set fal_server=orcldg; alter system set log_archive_config=‘DG_CONFIG=(oracle,orcldg)‘; alter system set log_archive_dest_1=‘LOCATION=/u01/app/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=oracle‘; alter system set log_archive_dest_2=‘SERVICE=orcldg LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcldg‘; alter system set db_file_name_convert=‘/u01/app/orcl/oradata/orcl‘,‘+DATA2/ORACLE/DATAFILE‘ scope=spfile; alter system set log_file_name_convert=‘/u01/app/orcl/oradata/orcl‘,‘+DATA2/ORACLE/ONLINELOG‘ scope=spfile; alter system set STANDBY_FILE_MANAGEMENT=AUTO alter system set DB_UNIQUE_NAME=‘oracle‘ scope=spfile; |
注意:
db_file_name_convert,和log_file_name_convert 最后路径不要添加‘/‘,要么全部加上/,要么全都不加
主库参数展示:
oracle1.__sga_target=268435456 oracle2.__sga_target=264241152 oracle2.__shared_io_pool_size=0 oracle1.__shared_io_pool_size=0 oracle2.__shared_pool_size=155189248 oracle1.__shared_pool_size=155189248 oracle2.__streams_pool_size=0 oracle1.__streams_pool_size=0 *.audit_file_dest=‘/u01/app/oracle/admin/oracle/adump‘ *.audit_trail=‘db‘ *.cluster_database=true *.compatible=‘11.2.0.4.0‘ *.control_files=‘+DATA2/oracle/controlfile/current.260.860701683‘,‘+DATA/oracle/controlfile/current.256.860701683‘ *.db_block_size=8192 *.db_create_file_dest=‘+DATA2‘ *.db_domain=‘‘ *.db_name=‘oracle‘ *.db_recovery_file_dest=‘+DATA‘ *.db_recovery_file_dest_size=4621074432 *.diagnostic_dest=‘/u01/app/oracle‘ *.dispatchers=‘(PROTOCOL=TCP) (SERVICE=oracleXDB)‘ oracle2.instance_number=2 oracle1.instance_number=1 *.log_archive_format=‘%t_%s_%r.dbf‘ *.memory_target=340787200 *.open_cursors=300 *.processes=150 *.remote_listener=‘scan-ip:1521‘ *.remote_login_passwordfile=‘exclusive‘ oracle2.thread=2 oracle1.thread=1 oracle2.undo_tablespace=‘UNDOTBS2‘ oracle1.undo_tablespace=‘UNDOTBS1‘ #ADD *.fal_client=‘oracle‘ *.fal_server=‘orcldg‘ *.log_archive_config=‘DG_CONFIG=(oracle,orcldg)‘ oracle1.log_archive_dest_1=‘LOCATION=/u01/app/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=oracle‘ oracle2.log_archive_dest_1=‘LOCATION=/u01/app/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=oracle‘ *.log_archive_dest_2=‘SERVICE=orcldg LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcldg‘ *.log_archive_dest_state_1=‘ENABLE‘ *.log_archive_dest_state_2=‘ENABLE‘ *.db_file_name_convert=‘+DATA2/ORACLE/DATAFILE‘,‘/u01/app/orcl/oradata/orcl‘ *.log_file_name_convert=‘+DATA2/ORACLE/ONLINELOG‘,‘/u01/app/orcl/oradata/orcl‘ *.STANDBY_FILE_MANAGEMENT=AUTO *.DB_UNIQUE_NAME=‘oracle‘ |
2)备库参数展示
*.audit_trail=‘db‘ *.compatible=‘11.2.0.4.0‘ *.db_block_size=8192 *.db_domain=‘‘ *.db_name=‘oracle‘ *.db_recovery_file_dest=‘/u01/app/orcl/fast_recovery_area‘ *.db_recovery_file_dest_size=4621074432 *.diagnostic_dest=‘/u01/app/orcl‘ *.log_archive_format=‘%t_%s_%r.dbf‘ *.memory_target=340787200 *.open_cursors=300 *.processes=150 *.control_files=‘/u01/app/orcl/oradata/orcl/standby.ctl‘ *.fal_client=‘orcldg‘ *.fal_server=‘oracle‘ *.log_archive_config=‘DG_CONFIG=(oracle,orcldg)‘ *.log_archive_dest_1=‘LOCATION=/u01/app/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcldg‘ *.log_archive_dest_2=‘SERVICE=oracle OPTIONAL LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=oracle‘ *.log_archive_dest_state_1=‘ENABLE‘ *.log_archive_dest_state_2=‘ENABLE‘ *.db_file_name_convert=‘+DATA2/ORACLE/DATAFILE‘,‘/u01/app/orcl/oradata/orcl‘ *.log_file_name_convert=‘+DATA2/ORACLE/ONLINELOG‘,‘/u01/app/orcl/oradata/orcl‘ *.STANDBY_FILE_MANAGEMENT=AUTO *.DB_UNIQUE_NAME=‘orcldg‘ |
3)备库的参数文件修改后。传输到目标机,主库的参数文件修改后能否启动。
4)检查参数:
Show parameter log; Show parameter control; Show parameter |
1)备份主库:
2)关闭数据库:
srvctl start database -d oracle
srvctl stop database -d oracle
或者登录到sqlplus 上关闭。
3)启动一个实例,关闭实例。
4)运行备份脚本。
run { crosscheck archivelog all; delete expired archivelog all; allocate channel c1 device type disk; allocate channel c2 device type disk; allocate channel c3 device type disk; backup incremental level 0 format ‘/home/oracle/backup/db_full_%U.bkp‘ tag ‘2015-02-027-FULL‘ database include current controlfile for standby plus archivelog; release channel c1; release channel c2; release channel c3; } |
5)备份控制文件
backup current controlfile format ‘/home/oracle/backup/control20150227.bak‘; |
6)备份参数文件
backup spfile format ‘/home/oracle/backup/spfile20150227.bak‘; |
7)产生备库使用的控制文件
alter database create standby controlfile as ‘/home/oracle/backup/standby.ctl‘ |
8) 出现的错误:
加上plus archivelog 备份归档日志报这个错误
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of backup plus archivelog command at 05/05/2014 01:00:04 RMAN-06059: expected archived log not found, loss of archived log compromises recoverability ORA-19625: error identifying file /oracle/PRD/oraarch/PRDarch1_16336_840558852.dbf ORA-27037: unable to obtain file status IBM AIX RISC System/6000 Error: 2: No such file or directory Additional information: 3 |
a)原因:归档日志会用 rm 命令定期清除
b)原理(从网上查的资料):
在controlfile中记录着每一个archivelog的相关信息,当我们在OS下把这些物理文件delete掉或异常变动后,在controlfile中仍然记录着这些archivelog的信息,当我们手工清除archive目录下的文件后,这些记录并没有被我们从controlfile中清除掉,也就是oracle并不知道这些文件已经不存在了!这时候我们要做手工的清除。 crosscheck archivelog all;的作用就是检查控制文件和实际物理文件的差别。
delete expired archivelog all;就是同步控制文件的信息和实际物理文件的信息。如果单独执行crosscheck而没有执行delete那么备份还是失败的,原因是那些控制文件的信息和实际的信息还是不同。 crosscheck backupset crosscheck backupset 是检查备份集和实际的文件 1 备份集有两种状态A(Available,RMAN认为该项存在于备份介质上)X(Expired,备份存在于控制文件或恢复目录中,但
是并没有物理存在于备份介质上)
c) crosscheck 的目的是检查RMAN 的目录以及物理文件,如果物理文件不存在于介质上,将标记为Expired。如果物理文件
存在,将维持Available。如果原先标记为Expired的备份集再次存在于备份介质上(如恢复了损坏的磁盘驱动器后),
crosscheck将把状态重新从Expired标记回Available。
d)解决方法:在脚本中加入
crosscheck archivelog all; |
1)传输备份文件和控制文件到目标机。
注意:备份文件要传输到跟源机目录一样的位置。否则会识别不到。、
Scp * oracledg:/home/oracle/backup/ |
2)使用rman连接主库和备库
alter database mount standby database; |
4)还原数据文件。
run { allocate channel c1 type disk; allocate channel c2 type disk; allocate channel c3 type disk; allocate auxiliary channel stby1 type disk; duplicate target database for standby dorecover nofilenamecheck ; release channel c1; release channel c2; release channel c3; release channel stby1; } |
5)查看配置的正确与否
远程归档目录查看
col dest_name for a20 col status for a20 col error for a20 select dest_name,status,error from v$archive_dest
说明: 出现log_archive_dest_1 valid log_archive_dest_2 valid 这样的提示说明已经连通。 |
6)如果没有问题则应用日志:
alter database recover managed standby database disconnect from session; |
7)查看当前的数据库角色
select database_role,protection_level,open_mode from v$database; select switchover_status from v$database; |
8)查看当前数据库是否有gap.
select thread#, low_sequence#, high_sequence# from v$archive_gap; |
9)查看当前日志序列号
select group#,members,bytes/1024/1024,status from v$log; select group# ,thread#, sequence#,archived from v$log; |
10)切换日志文件
alter system switch logfile; alter system checkpoint; |
11)查看当前日志应用情况
select sequence#,applied from v$archived_log; |
9.1 连接主库和备库:
rman target sys/123@oracle auxiliary sys/123@orcldg |
9.2 运行复制数据库命令
run { allocate channel prmy4 type disk; allocate auxiliary channel stby type disk; duplicate target database for standby dorecover nofilenamecheck from active database; release channel prmy4 ; release channel stby; } |
9.3 这步出的错误:
1)共享空间不足:
RMAN-03002: failure of Duplicate Db command at 04/10/2014 11:51:19 RMAN-05501: aborting duplication of target database RMAN-03015: error occurred in stored script Memory Script RMAN-04014: startup failed: ORA-00845: MEMORY_TARGET not supported on this system |
原因:duplicate过程报错,执行失败。
从分析看,应该是Oracle运行和内部共享内存分配有关。Linux中的/dev/shm对应tmpfs,也就是临时共享内存结构。当前大小为:
[root@SimpleLinux ~]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda2 48G 13G 33G 28% / tmpfs 448M 160M 288M 36% /dev/shm
当前系统中包括两个实例对象,消耗的共享内存要超过一个实力的情况。所以需要调节增大这部分大小。
[root@SimpleLinux ~]# vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=2G 0 0 |
在存储空间允许的情况下,调节tmpfs方法就是在fstab中增加size参数,直接指定大小。
[root@SimpleLinux ~]# mount /dev/shm [root@SimpleLinux ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 48G 13G 33G 28% / tmpfs 2.0G 0 2.0G 0% /dev/shm |
9.3控制文件指定地方要正确,要提前建好目录.
mkdir –p /u01/app/orcl/oradata/orcl/ |
9.3日志转换目录要正确。
+DATA/oracle/onlinelog, /u01/app/orcl/oradata/orcl, +DATA2/oracle/onlinelog, /u01/app/orcl/oradata/orcl |
9.4如果备份不在原来的位置,则需要注册备份:
catalog backuppiece ‘/backup/full_level0_0sni49k9_1_1_20120808‘; catalog backuppiece ‘/backup/full_level0_0rni49jq_1_1_20120808‘; catalog backuppiece ‘/backup/ARC_0oni2f44_1_1_20120807‘; catalog backuppiece ‘/backup/ARC_0tni49kc_1_1_20120808‘; |
注意: 添加standby 日志的数目=主库日志数目+1。
如果是RAC环境则是日志数目=实例日志*2 +1。
日志大小要一样。
1)主库的standby日志:
alter database add standby logfile group 5 (‘+DATA/oracle/onlinelog/stdbyredo05.log‘) SIZE 50m; alter database add standby logfile group 6 (‘+DATA/oracle/onlinelog/stdbyredo06.log‘) SIZE 50m; alter database add standby logfile group 7 (‘+DATA/oracle/onlinelog/stdbyredo07.log‘) SIZE 50m; alter database add standby logfile group 8 (‘+DATA/oracle/onlinelog/stdbyredo08.log‘) SIZE 50m; alter database add standby logfile group 9 (‘+DATA/oracle/onlinelog/stdbyredo09.log‘) SIZE 50m; alter database add standby logfile group 10 (‘+DATA/oracle/onlinelog/stdbyredo10.log‘) SIZE 50m; |
2)备库的standby日志:
alter database add standby logfile group 5(‘ /u01/app/orcl/oradata/orcl/stdbyredo5.log‘) SIZE 50m; alter database add standby logfile group 6(‘ /u01/app/orcl/oradata/orcl/stdbyredo6.log‘) SIZE 50m; alter database add standby logfile group 7(‘ /u01/app/orcl/oradata/orcl/stdbyredo7.log‘) SIZE 50m; alter database add standby logfile group 8(‘ /u01/app/orcl/oradata/orcl/stdbyredo8.log‘) SIZE 50m; alter database add standby logfile group 9(‘ /u01/app/orcl/oradata/orcl/stdbyredo9.log‘) SIZE 50m; alter database add standby logfile group 10(‘ /u01/app/orcl/oradata/orcl/stdbyredo10.log‘) SIZE 50m; alter database add standby logfile group 11(‘ /u01/app/orcl/oradata/orcl/stdbyredo11.log‘) SIZE 50m; alter database add standby logfile group 12(‘ /u01/app/orcl/oradata/orcl/stdbyredo12.log‘) SIZE 50m; alter database add standby logfile group 13(‘ /u01/app/orcl/oradata/orcl/stdbyredo13.log‘) SIZE 50m; alter database add standby logfile group 14(‘/u01/app/orcl/oradata/orcl/stdbyredo13.log stdbyredo14.log‘) SIZE 50m; alter database add standby logfile group 15(‘/u01/app/orcl/oradata/orcl/stdbyredo13.log stdbyredo15.log‘) SIZE 50m; alter database add standby logfile group 16(‘/u01/app/orcl/oradata/orcl/stdbyredo13.log stdbyredo16.log‘) SIZE 50m; |
Data Guard的主备库切换分为2种,switchover和failover.遇到突发事件,基本都是采用failover切换. 在主备库切换完成后应该修改数据库服务器的IP地址,即备库的地址.这样才能保证系统的正常运作.
一般SWITCHOVER切换都是计划中的切换,特点是在切换后,不会丢失任何的数据,而且这个过程是可逆的,整个DATA GUARD环境不会被破坏,原来DATA GUARD环境中的所有物理和逻辑STANDBY都可以继续工作。
select switchover_status from v$database; |
alter database commit to switchover to physical standby with session shutdown; |
select status from v$instance; shutdown immediate startup mount |
alter database commit to switchover to physical standby; |
alter database recover managed standby database disconnect from session; |
select switchover_status from v$database; |
alter database commit to switchover to primary; |
alter database open; |
FAILOVER切换一般是PRIMARY数据库发生故障后的切换,这种情况是STANDBY数据库发挥其作用的情况。这种切换发生后,可能会造成数据的丢失。而且这个过程不是可逆的,DATA GUARD环境会被破坏。由于PRIMARY数据库已经无法启动,所以FAILOVER切换所需的条件并不多,只要检查STANDBY是否运行在最大保护模式下,如果是的话,需要将其置为最大性能模式,否则切换到PRIMARY角色也无法启动。
FailOver后,主库会做一次resetlogs,整个DG环境也就破坏了.
sql> select unique thread#, max(sequence#) over(partition by thread#) last from v$archived_log; sql> select thread#, low_sequence#, high_sequence# from v$archive_gap; 如果有,则拷贝过来并且注册 sql> alter database register physical logfile ‘路径‘; |
重复查看直到没有应用的日志。
alter database recover managed standby database cancel; |
alter database recover managed standby database finish; select database_role from v$database; alter database commit to switchover to primary; alter database open; |
select database_role from v$database; |
1)设置好环境变量
2)数据库名字要一样
env ~/.bash_profile
3)数据库的名字主库和备库要一样
4)主库和备库的唯一名字可以不一样
5)查看监听状态使其只有一个服务注册上。
6)然后使用修改后的参数文件启动到nomount 状态。放置好备库的控制文件/u01/app/orcl/oradata/orcl/standby.ctl,后
启动数据库到mount状态。
alter database mount standby database; |
7)主库备库都要实时观察报错日志。
tail -f alert_oracle.log |
7)停止standby的自动恢复状态
alter database recover managed standby database finish; |
8)取消应用的日志
alter database recover managed standby database cancel; |
9)开启闪回
alter database flashback on; |
10)应用日志
alter database recover managed standby database disconnect from session; |
11)添加online 日志组。
alter database add logfile group 4 |
12)增大联机日志文件。
先删除:
alter database drop logfile group 1; alter database drop logfile group2(‘/u01/app/orcl/oradata/orcl/red/o02.log‘); alter database drop logfile group3(‘/u01/app/orcl/oradata/orcl/red/o03.log‘); alter database drop logfile group4(‘/u01/app/orcl/oradata/orcl/red/o04.log‘); |
后添加:
alter database add logfile group 1 (‘/u01/app/orcl/oradata/orcl/red/o03.log‘) size 500m reuse; alter database add logfile group 3 (‘d:\oradata/wsjcyl/redo03.log‘) size 500m reuse; alter database add logfile group 2 (‘d:\oradata/wsjcyl/redo02.log‘) size 500m reuse; |
RAC使用pfile 文本文件编辑的方式。从spfile创建出pfile修改后,还原到磁盘组时。要注意以下参数。
show parameter instance_number show parameter thread show parameter undo_tablespace |
如果设置不正确,则会导致数据库无法启动。通过执行以下命令来修复。
alter system set instance_number=1 scope=spfile sid=‘oracle1‘; alter system set instance_number=2 scope=spfile sid=‘oracle2‘;
alter system set thread=1 scope=spfile sid=‘oracle1‘; alter system set thread=2 scope=spfile sid=‘oracle2‘;
alter system set undo_tablespace=‘undotbs1‘ scope=spfile sid=‘oracle1‘; alter system set undo_tablespace=‘undotbs2‘ scope=spfile sid=‘oracle2‘; |
ORACLE11g R2 RAC+DG FOR OEL6.5安装实施报告
标签:
原文地址:http://www.cnblogs.com/zaming/p/4322208.html