搭建rac对单实例的MAA
一:实验环境
系统:redhat 4
三台计算机rac1,rac2,dg.
--其中rac为主库,单实例为备库
已在虚拟机里搭建好集群环境(rac1,rac2);
dg计算机里还没有建任何数据库(只安装Oracle软件)。
二:实验步骤
单实例环境部署请参考文档‘Linux下安装Oracle 10g(redhat 4)’。
3.1:enable forced logging
--将主库设为强制归档
SQL> select force_logging from v$database;
FOR
---
NO
SQL> alter database force logging;
Database altered.
SQL> select force_logging from v$database;
FOR
---
YES
3.2:创建密码文件
在rac的两个节点上执行:
SQL> alter user sys identified by oracle;
User altered.
建密码文件:
cd /u01/app/oracle/product/10.2.0/db_1/dbs --注意,一定要在该路径下建密码文件
[oracle@rac1 dbs]$ orapwd file=orapwprod1 password=oracle entries=3 force=y
[oracle@rac2 dbs]$ orapwd file=orapwprod2 password=oracle entries=3 force=y
在备库上建密码文件
cd /u01/app/oracle/product/10.2.0/db_1/dbs
[oracle@dg dbs]$ orapwd file=orapwsdyprod password=oracle entries=3
3.3:configure a standby redo log
在任意一个节点上查询日志情况:
SQL> select group#,thread#,sequence#,bytes/1024/1024mb
2 from v$log;
GROUP# THREAD# SEQUENCE# MB
---------- ---------- ---------- ----------
1 1 4 50
2 1 5 50
3 2 3 50
4 2 4 50
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DATA/prod/onlinelog/group_2.262.856078815
+REDOLOG/prod/onlinelog/group_2.258.856078819
+DATA/prod/onlinelog/group_1.261.856078807
+REDOLOG/prod/onlinelog/group_1.257.856078813
+DATA/prod/onlinelog/group_3.266.856079013
+REDOLOG/prod/onlinelog/group_3.259.856079015
+DATA/prod/onlinelog/group_4.267.856079017
+REDOLOG/prod/onlinelog/group_4.260.856079019
8 rows selected.
用下面这个公式决定standby redo log file group的数量:
(每个节点日志组最大数+1)*节点数量
比如,这里每个节点都有两组日志,有两个节点,因此需要配置(2+1)*2=6组standby redo log file group.
建立standby redo log;
SQL> alter database add standby logfile thread 1 group 5 '+DATA' size 50m;
Database altered.
SQL> alter database add standby logfile thread 1 group 6 '+DATA' size 50m;
Database altered.
SQL> alter database add standby logfile thread 1 group 7 '+DATA' size 50m;
Database altered
SQL> alter database add standby logfile thread 2 group 8 '+DATA' size 50m;
Database altered.
SQL> alter database add standby logfile thread 2 group 9 '+DATA' size 50m;
Database altered.
SQL> alter database add standby logfile thread 2 group 10 '+DATA' size 50m;
Database altered.
在两个节点上都查看一下建的standby log file:
SQL> select group#,thread#,status
2 from v$standby_log;
GROUP# THREAD# STATUS
---------- ---------- ----------
5 1 UNASSIGNED
6 1 UNASSIGNED
7 1 UNASSIGNED
8 2 UNASSIGNED
9 2 UNASSIGNED
10 2 UNASSIGNED
6 rows selected.
3.4:Set Primary Database Initialization Parameters
在rac1节点上创建pfile(由于它原本Pfile内容只有SPFILE='+DG1/prod/spfileprod.ora'这一句)
SQL> create pfile='/home/oracle/initprod1.ora' from spfile;
File created.
vi initprod.ora
添加如下内容:
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(prod,sdyprod)'
LOG_ARCHIVE_DEST_1=
'LOCATION=+DATA/prod
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=prod'
LOG_ARCHIVE_DEST_2=
'SERVICE=sdyprod LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=sdyprod'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=3
FAL_SERVER=sdyprod
prod1.FAL_CLIENT=prod1
prod2.FAL_CLIENT=prod2
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/sdyprod/','+DATA/prod/datafile/','/u01/app/oracle/oradata/sdyprod/','+DATA/prod/tempfile/'
LOG_FILE_NAME_CONVERT= '/u01/app/oracle/oradata/sdyprod/','+DATA/prod/onlinelog/','/u01/app/oracle/oradata/sdyprod/','+REDOLOG/prod/onlinelog/'
STANDBY_FILE_MANAGEMENT=AUTO
看以该pfile文件能否登陆成功,并创建spfile(rac里建spfile时,不指定位置的话,会默认放在本地磁盘上)
SQL> startup force nomount pfile='/home/oracle/initprod1.ora';
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
SQL> create spfile='+DATA/prod/spfileprod.ora' from pfile='/home/oracle/initprod1.ora';
File created
在打开rac1之前,先把rac2的实例关掉,因为现在spfile已经改变了。
在rac2上:shutdown immediate;
在rac1上:startup force;
在rac2上:startup;
/*
若rac2的库没关,rac1以修改后的spfile启动,会报错:
SQL> startup force;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
ORA-01105: mount is incompatible with mounts by other instances
ORA-01677: standby file name convert parameters differ from other instance
*/
3.5:enable archiving
--若已经归档,这步可以隔过去了
3.6:Create a Backup Copy of the Primary Database Datafiles
(由于是rac环境,只能用rman备份了)
在rac1下做一个热备份(由于rac默认备份放在ASM下,所以这里备份需要手工指定位置):
RMAN> run {
2> allocate channel c1 type disk;
3> allocate channel c2 type disk;
4> backup full database format '/home/oracle/backup/%d_%s.bak';
5> }
--在rac1下的/home/oracle/backup可以看到备份集,rac2下的/home/oracle/backup下看不到。
3.7:create a control file for the standby database
--在任意一个节点上皆可
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 96470608 bytes
Database Buffers 184549376 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> alter database create standby controlfile as '/home/oracle/sdyprod_control01.ctl';
Database altered.
SQL> alter database open;
Database altered.
3.8: Prepare an Initialization Parameter File for the Standby Database
将rac1下建的初始化参数文件远程拷贝到备库192.168.8.225上:
[oracle@rac1 ~]$
scp initprod1.ora 192.168.8.225:/u01/app/oracle/product/10.2.0/db_1/dbs/initsdyprod.ora
The authenticity of host '192.168.8.225 (192.168.8.225)' can't be established.
RSA key fingerprint is 6d:1d:6b:1a:34:63:f2:f4:4c:15:0d:eb:60:e0:13:4d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.8.225' (RSA) to the list of known hosts.
oracle@192.168.8.225's password:
initprod1.ora 100% 2214 2.2KB/s 00:00
拷贝过来的initprod1.ora文件内容:
prod1.__db_cache_size=163577856
prod2.__db_cache_size=155189248
prod1.__java_pool_size=4194304
prod2.__java_pool_size=4194304
prod1.__large_pool_size=4194304
prod2.__large_pool_size=4194304
prod1.__shared_pool_size=109051904
prod2.__shared_pool_size=117440512
prod1.__streams_pool_size=0
prod2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/prod/adump'
*.background_dump_dest='/u01/app/oracle/admin/prod/bdump'
*.cluster_database_instances=2
*.cluster_database=true
*.compatible='10.2.0.1.0'
*.control_files='+DATA/prod/controlfile/current.260.856078805','+REDOLOG/prod/controlfile/current.256.856078805'
*.core_dump_dest='/u01/app/oracle/admin/prod/cdump'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='prod'
*.db_recovery_file_dest='+REDOLOG'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=prodXDB)'
prod1.instance_number=1
prod2.instance_number=2
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=+DATA/prod'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_listener='LISTENERS_PROD'
*.remote_login_passwordfile='exclusive'
*.sga_target=285212672
prod2.thread=2
prod1.thread=1
*.undo_management='AUTO'
prod2.undo_tablespace='UNDOTBS2'
prod1.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/prod/udump'
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(prod,sdyprod)'
LOG_ARCHIVE_DEST_1=
'LOCATION=+DATA/prod/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=prod'
LOG_ARCHIVE_DEST_2=
'SERVICE=sdyprod LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=sdyprod'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=3
FAL_SERVER=sdyprod
prod1.FAL_CLIENT=prod1
prod2.FAL_CLIENT=prod2
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/sdyprod/','+DATA/prod/datafile/','/u01/app/oracle/oradata/sdyprod/','+DATA/prod/tempfile/'
LOG_FILE_NAME_CONVERT= '/u01/app/oracle/oradata/sdyprod/','+DATA/prod/onlinelog/','/u01/app/oracle/oradata/sdyprod/','+REDOLOG/prod/onlinelog/'
STANDBY_FILE_MANAGEMENT=AUTO
相对于修改前的参数文件,修改后的initsdyprod.ora如下(改动的地方已用黄色阴影标出):
prod1.__db_cache_size=163577856
prod2.__db_cache_size=155189248
prod1.__java_pool_size=4194304
prod2.__java_pool_size=4194304
prod1.__large_pool_size=4194304
prod2.__large_pool_size=4194304
prod1.__shared_pool_size=109051904
prod2.__shared_pool_size=117440512
prod1.__streams_pool_size=0
prod2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/sdyprod/adump'
*.background_dump_dest='/u01/app/oracle/admin/sdyprod/bdump'
#*.cluster_database_instances=2
#*.cluster_database=true
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/admin/sdyprod/sdyprod_control01.ctl'
*.core_dump_dest='/u01/app/oracle/admin/sdyprod/cdump'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='prod'
*.db_recovery_file_dest=''
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=prodXDB)'
prod.instance_number=1
*.job_queue_processes=10
#*.log_archive_dest_1='LOCATION=+DATA/prod'
#*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_listener='LISTENERS_PROD'
*.remote_login_passwordfile='exclusive'
*.sga_target=285212672
sdyprod.thread=1
*.undo_management='AUTO'
sdyprod.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/sdyprod/udump'
db_unique_name=sdyprod
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(prod,sdyprod)'
LOG_ARCHIVE_DEST_1=
'LOCATION=/arch/sdyprod
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=sdyprod'
LOG_ARCHIVE_DEST_2=
'SERVICE=prod LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=prod'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=3
FAL_SERVER=prod
FAL_CLIENT=sdyprod
DB_FILE_NAME_CONVERT='+DATA/prod/datafile/','/u01/app/oracle/oradata/sdyprod/','+DATA/prod/tempfile/','/u01/app/oracle/oradata/sdyprod/'
LOG_FILE_NAME_CONVERT= '+DATA/prod/onlinelog/','/u01/app/oracle/oradata/sdyprod/','+REDOLOG/prod/onlinelog/' ,'/u01/app/oracle/oradata/sdyprod/'
STANDBY_FILE_MANAGEMENT=AUTO
3.9:在备库上建立相关目录
--建归档路径:/arch/sdyprod
[root@dg~]# mkdir -p /arch/sdyprod
[root@dg ~]# chown oracle:dba /arch/sdyprod
[oracle@dg ~]$ mkdir -p /u01/app/oracle/admin/sdyprod
[oracle@dg ~]$ mkdir -p /u01/app/oracle/oradata/sdyprod
[oracle@dg admin]$ cd sdyprod/
[oracle@dg sdyprod]$ ls
[oracle@dg sdyprod]$ mkdir adump bdump cdump udump
--创建备份文件夹
[oracle@dg ~]$ cd /home/oracle
[oracle@dg ~]$ ls
Desktop initsdyprod.ora software
[oracle@dg ~]$ mkdir backup
3.10:Copy Files from the Primary System to the Standby System(用RMAN方式)
[oracle@rac1 backup]$ scp *.bak 192.168.8.225:/home/oracle/backup/
oracle@192.168.8.225's password:
PROD_1.bak 100% 362MB 14.5MB/s 00:25
PROD_2.bak 100% 257MB 13.5MB/s 00:19
PROD_3.bak 100% 15MB 14.6MB/s 00:01
PROD_4.bak 100% 96KB 96.0KB/s 00:00
[oracle@rac1 backup]$ cd /home/oracle
[oracle@rac1 ~]$ scp sdyprod_control01.ctl 192.168.8.225:/home/oracle/
oracle@192.168.8.225's password:
sdyprod_control01.ctl 100% 15MB 7.3MB/s 00:02
注意:拷贝的数据文件和控制文件必须得和原来的路径一模一样,否则会出错。
3.11:Configure listeners for the primary and standby databases
--配监听和tnsnames.ora
[oracle@rac1 admin]$ cd /u01/app/oracle/product/10.2.0/db_1/network/admin
[oracle@rac1 admin]$ ls
listener.ora samples shrept.lst tnsnames.ora
在rac1,rac2的tnsnames.ora中添加如下内容:
sdyprod=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.8.225)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sdyprod)
(UR=A)
)
)
在备库192.168.8.225中添加如下内容:
LISTENERS_PROD =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
)
PROD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod)
)
)
PROD2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod)
(INSTANCE_NAME = prod2)
)
)
PROD1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod)
(INSTANCE_NAME = prod1)
)
)
tnsping一下,看能否Ping通,如以tnsping prod1为例:
看到‘OK’字样,表示ping通了。
在备库lsnrctl start
lsnrctl status
3.12 在备库上修改/etc/hosts文件
# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost
192.168.8.225 dg
192.168.8.220 rac1
192.168.8.222 rac1-vip
10.10.10.1 rac1-priv
192.168.8.221 rac2
192.168.8.223 rac2-vip
10.10.10.2 rac2-priv
3.13: Create a server parameter file for the standby database
--在备库上:
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
SQL> create spfile from pfile;
File created
3.14:在主库恢复数据库
-------在主库通过rman duplicate standby db
[oracle@rac1 admin]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Dec 12 07:35:04 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: PROD (DBID=212879047)
RMAN> connect auxiliary sys/oracle@sdyprod;
connected to auxiliary database: PROD (not mounted)
RMAN> duplicate target database for standby
2> ;
Starting Duplicate Db at 26-AUG-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK
contents of Memory Script:
{
restore clone standby controlfile;
sql clone 'alter database mount standby database';
}
executing Memory Script
Starting restore at 26-AUG-14
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: copied control file copy
input filename=/home/oracle/sdyprod_control01.ctl
output filename=/u01/app/oracle/admin/sdyprod/sdyprod_control01.ctl
Finished restore at 26-AUG-14
sql statement: alter database mount standby database
released channel: ORA_AUX_DISK_1
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/sdyprod/temp.263.856078825";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/sdyprod/system.256.856078713";
set newname for datafile 2 to
"/u01/app/oracle/oradata/sdyprod/undotbs1.258.856078719";
set newname for datafile 3 to
"/u01/app/oracle/oradata/sdyprod/sysaux.257.856078715";
set newname for datafile 4 to
"/u01/app/oracle/oradata/sdyprod/users.259.856078719";
set newname for datafile 5 to
"/u01/app/oracle/oradata/sdyprod/example.264.856078831";
set newname for datafile 6 to
"/u01/app/oracle/oradata/sdyprod/undotbs2.265.856078943";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/sdyprod/temp.263.856078825 in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 26-AUG-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK
skipping datafile 2; already restored to file /u01/app/oracle/oradata/sdyprod/undotbs1.258.856078719
skipping datafile 3; already restored to file /u01/app/oracle/oradata/sdyprod/sysaux.257.856078715
skipping datafile 5; already restored to file /u01/app/oracle/oradata/sdyprod/example.264.856078831
skipping datafile 1; already restored to file /u01/app/oracle/oradata/sdyprod/system.256.856078713
skipping datafile 4; already restored to file /u01/app/oracle/oradata/sdyprod/users.259.856078719
skipping datafile 6; already restored to file /u01/app/oracle/oradata/sdyprod/undotbs2.265.856078943
restore not done; all files readonly, offline, or already restored
Finished restore at 26-AUG-14
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy recid=4 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/system.256.856078713
datafile 2 switched to datafile copy
input datafile copy recid=5 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/undotbs1.258.856078719
datafile 3 switched to datafile copy
input datafile copy recid=6 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/sysaux.257.856078715
datafile 4 switched to datafile copy
input datafile copy recid=7 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/users.259.856078719
datafile 5 switched to datafile copy
input datafile copy recid=8 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/example.264.856078831
datafile 6 switched to datafile copy
input datafile copy recid=9 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/undotbs2.265.856078943
Finished Duplicate Db at 26-AUG-14
RMAN>
3.15:在备库上应用日志
SQL> alter database recover managed standby database disconnect from session;
查看报警日志或者v$archived_log,看是否同步归档日志。
在主库上scott用户下的表t插入一条数据:
SQL> insert into t values(3);
1 row created.
SQL> commit;
Commit complete.
在备库上查看一下:
SQL> select * from t;
select * from t
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
由于,在read only下查看,会导致应用日志的延迟,于是决定,在备库切换成主库后再查看。
3.16:角色切换
在主库上关掉其他实例,只剩一个实例以切换到备库:
进rac2:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
进rac1:
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE --表示有活动的会话,需要kill掉
SQL> select sid,serial#,username from v$session where username is not null;
SID SERIAL# USERNAME
---------- ---------- ------------------------------
124 8 SYS
131 3 SYS
132 9 SYS
151 17 SYS
152 9 SYS
SQL> select distinct sid from v$mystat;
SID
----------
124
SQL> alter system kill session '131,3';
System altered.
SQL> alter system kill session '132,9';
System altered.
SQL> alter system kill session '151,17';
System altered.
SQL> alter system kill session '152,9';
System altered.
SQL> alter database commit to switchover to physical standby with session shutdown;
Database altered.
SQL> select status from v$instance;
STATUS
------------
STARTED
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 100664912 bytes
Database Buffers 180355072 bytes
Redo Buffers 2973696 bytes
--必须得先关库,再startup mount,而不是alter database mount;否则报错
Database mounted.
进备库:
SQL> alter database commit to switchover to primary with session shutdown ;
alter database commit to switchover to primary with session shutdown
*
ERROR at line 1:
ORA-16139: media recovery required
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> alter database commit to switchover to primary with session shutdown ;
Database altered.
SQL> alter database open;
SQL> select open_mode
2 from v$database;
OPEN_MODE
----------
READ WRITE
SQL> select *
2 from scott.t;
ID
----------
3
1
2
--备库切换为主库后,看到了之前的主库插入的数据3。
--原来的主库(即切换角色后的备库),应用日志:
alter database recover managed standby database disconnect from session
搭建rac对单实例的MAA的更多相关文章
- Oracle_lhr_CentOS 7.3 ECS上搭建RAC 18c+单实例DG+EMCC+DG的FSFO快速故障转移配置
Oracle_lhr_CentOS 7.3 ECS上搭建RAC 18c+单实例DG+EMCC+DG的FSFO快速故障转移配置 [大型连续免费公开课]Oracle 18c rac+dg+13.3的em ...
- oracle 11g r2 rac到单实例的dg
oracle 11g r2 rac到单实例的dg 1 主备环境说明 rac环境--primary CentOS release 6.5 (Final)hostname rac1 rac2ip 10.* ...
- ORACLE11g R2【RAC+ASM→单实例FS】
ORACLE11g R2[RAC+ASM→单实例FS] 11g R2 RAC+ASMà单实例FS的DG,建议禁用OMF. 本演示案例所用环境: primary standby OS Hostnam ...
- ORACLE10g R2【RAC+ASM→单实例FS】
ORACLE10g R2[RAC+ASM→单实例FS] 10g R2 RAC+ASMà单实例FS的DG,建议禁用OMF. 本演示案例所用环境: primary standby OS Hostnam ...
- Oracle - 给rac创建单实例dg,并做主从切换
一.概述 本文将介绍如何给rac搭建单节点的dg,以及如何对其进行角色转换.预先具备的知识(rac搭建,单实例-单实例dg搭建) 二.实验环境介绍 主库rac(已安装rac,并已有数据库orcl)ra ...
- oracle rac与单实例DG切换
1.主库查看状态(RAC库) SQL> select database_role,switchover_status from v$database; DATABASE_ROLE SWITCHO ...
- Oracle RAC备份异机单实例恢复演练
本文只节选了操作方案的部分章节: 3. 操作步骤 3.1. 异机单实例Oracle数据库软件安装 在异机上进行单实例Oracle数据库软件安装.该步骤过程不再本文中重复描述,如果对安装过程存在疑问 ...
- 12c RAC 用Rman 恢复到异机单实例
准备工作 原服务器软件部署:Redhat 6.6 + Oracle 12.2.0.1 rac Oracle12c单实例安装 1.创建恢复服务器,设置大于原库数据大小的磁盘容量.设置相同的服务器主机名参 ...
- Oracle 11g RAC 环境下单实例非缺省监听及端口配置
如果在Oracle 11g RAC环境下使用dbca创建单实例数据库后,Oracle会自动将其注册到缺省的1521端口及监听器.大多数情况下我们使用的为非缺省监听器以及非缺省的监听端口.而且在Orac ...
随机推荐
- Android 利用Application对象存取公共数据
本文章来给大家介绍Android 利用Application对象存取公共数据. Android系统在运行每一个程序应用的时候,都会创建一个Application对象,用于存储与整个应用相关的公共变量. ...
- HDOJ 1302(UVa 573) The Snail(蜗牛爬井)
Problem Description A snail is at the bottom of a 6-foot well and wants to climb to the top. The sna ...
- linux中断处理程序
Linux进行中断处理的4个步骤: 1.当中断产生,跳到统一入口IRQ_SVC 2.获取中断号 3.根据中断号找到irq_desc结构 4.从irq_desc结构中取出事先注册好的中断处理函数 Lin ...
- Vanya and Triangles 暴力枚举
枚举法: 枚举法是利用计算机速度快, 精度高的特点, 对要解决的问题所有可能情况进行霸道的, 一个不漏检验, 从中找出符合要求的答案. 特点: 1. 得到的结果一定正确. 2. 可能做了很多无用功,效 ...
- POJ-1028(字符串模拟)
Web Navigation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 31906 Accepted: 14242 ...
- Java虚拟机内存优化实践
前面一篇文章介绍了Java虚拟机的体系结构和内存模型,既然提到内存,就不得不说到内存泄露.众所周知,Java是从C++的基础上发展而来的,而C++程序的很大的一个问题就是内存泄露难以解决,尽管Java ...
- WINDOWS OPTIMIZE
WIN10 SHUT DOWN AUTOMATICALLY UPDATE 1.service -> windows update 2.gpedit ->计算机配置 - 管理模板 - Win ...
- C++沉思录之三——设计容器类
一.对容器的基本认识 总的来说,容器应该包含放在其中的对象的副本,而不是对象本身. 二.复制容器意味着什么? 通常将容器成为模板,而容器内的对象的类型就是模板参数.Container<T> ...
- linux增大交换分区
进来在批量搭建环境,遇到搭建完环境之后发现swap忘记的情况,后来百度了下,发现了下面的方法,网上可能存在好多相应的帖子说这个事情也比较简单,以下是自己实践的结果,分享给大家. 1.查看现有memor ...
- canvas-画蜗牛
<!doctype html><html lang="en"> <head> <meta charset="UTF-8" ...