Oracle DataBase單例項遷移到Oracle RAC
Oracle DataBase單例項遷移到Oracle RAC步驟:
遷移前單例項環境介紹:
資料庫版本:Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
資料庫物理結構:
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 440 SYSTEM *** /u01/app/oracle/oradata/orcl/system01.dbf
2 25 UNDOTBS1 *** /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 250 SYSAUX *** /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 5 USERS *** /u01/app/oracle/oradata/orcl/users01.dbf
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 440 SYSTEM *** /u01/app/oracle/oradata/orcl/system01.dbf
2 25 UNDOTBS1 *** /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 250 SYSAUX *** /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 5 USERS *** /u01/app/oracle/oradata/orcl/users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /u01/app/oracle/oradata/orcl/temp01.dbf
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /u01/app/oracle/oradata/orcl/temp01.dbf
RMAN>
主機環境
[oracle@rac1 admin]$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.2.101 rac1.localdomain rac1
192.168.2.102 rac2.localdomain rac2
192.168.0.101 rac1-priv.localdomain rac1-priv
192.168.0.102 rac2-priv.localdomain rac2-priv
192.168.2.103 rac1-vip.localdomain rac1-vip
192.168.2.104 rac2-vip.localdomain rac2-vip
[oracle@rac1 admin]$
================================================================================
1. 單節點資料庫備份
注:單節點資料庫的備份已經傳送到/u02目錄下,直接執行下面的解壓即可。
[oracle@rac1 u02]$ cd /u02
[oracle@rac1 u02]$ tar zxvf backup_db.orcl.tar.gz
backup_db/
backup_db/ORCL_24_798936483_1_full_arch.bus
backup_db/ORCL_25_798936484_1_full_ctl.bus
backup_db/ORCL_26_798936485_1_full_spfile.bus
backup_db/ORCL_22_798936465_1_full_db.bus
backup_db/initorcl.ora
backup_db/ORCL_20_798936465_1_full_db.bus
backup_db/ORCL_21_798936465_1_full_db.bus
backup_db/ORCL_23_798936466_1_full_db.bus
backup_db/ORCL_19_798936465_1_full_arch.bus
[oracle@rac1 u02]$
[oracle@rac1 u02]$ tar zxvf backup_db.orcl.tar.gz
backup_db/
backup_db/ORCL_24_798936483_1_full_arch.bus
backup_db/ORCL_25_798936484_1_full_ctl.bus
backup_db/ORCL_26_798936485_1_full_spfile.bus
backup_db/ORCL_22_798936465_1_full_db.bus
backup_db/initorcl.ora
backup_db/ORCL_20_798936465_1_full_db.bus
backup_db/ORCL_21_798936465_1_full_db.bus
backup_db/ORCL_23_798936466_1_full_db.bus
backup_db/ORCL_19_798936465_1_full_arch.bus
[oracle@rac1 u02]$
-------------------------------------------------------------------------
mkdir -p /u02/backup_db/
chown oracle:dba /u02/backup_db/
chmod 770 /u02/backup_db/
chown oracle:dba /u02/backup_db/
chmod 770 /u02/backup_db/
rman target /
run{
allocate channel d1 type disk maxpiecesize=10G;
allocate channel d2 type disk maxpiecesize=10G;
allocate channel d3 type disk maxpiecesize=10G;
backup tag 'full_db_bk' filesperset 10
as compressed backupset database force noexclude
format '/u02/backup_db/%d_%s_%t_%p_full_db.bus'
plus archivelog delete all input
format '/u02/backup_db/%d_%s_%t_%p_full_arch.bus';
allocate channel d1 type disk maxpiecesize=10G;
allocate channel d2 type disk maxpiecesize=10G;
allocate channel d3 type disk maxpiecesize=10G;
backup tag 'full_db_bk' filesperset 10
as compressed backupset database force noexclude
format '/u02/backup_db/%d_%s_%t_%p_full_db.bus'
plus archivelog delete all input
format '/u02/backup_db/%d_%s_%t_%p_full_arch.bus';
backup current controlfile tag 'full_db_cntl' format '/u02/backup_db/%d_%s_%t_%p_full_ctl.bus';
backup spfile tag 'full_db_spfile' format '/u02/backup_db/%d_%s_%t_%p_full_spfile.bus';
backup spfile tag 'full_db_spfile' format '/u02/backup_db/%d_%s_%t_%p_full_spfile.bus';
release channel d1;
release channel d2;
release channel d3;
}
release channel d2;
release channel d3;
}
SQL> create pfile from spfile;
[oracle@ocm18 dbs]$ cat initorcl.ora
orcl.__db_cache_size=432013312
orcl.__java_pool_size=8388608
orcl.__large_pool_size=4194304
orcl.__shared_pool_size=159383552
orcl.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.background_dump_dest='/u01/app/oracle/admin/orcl/bdump'
*.compatible='10.2.0.5.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl','/u01/app/oracle/oradata/orcl/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/orcl/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=201326592
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=605028352
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/orcl/udump'
[oracle@ocm18 dbs]$
2. RAC環境建立
在兩個節點操作:
cd $ORACLE_BASE/admin
mkdir orcl
cd orcl/
mkdir -p adump bdump cdump dpdump hdump pfile scripts udump
在節點1 操作:
[oracle@rac1 ~]$ cd $ORACLE_HOME/dbs
[oracle@rac1 dbs]$ orapwd file=orapworcl1 password=oracle
[oracle@rac1 dbs]$
在節點2 操作:
[oracle@rac2 ~]$ cd $ORACLE_HOME/dbs
[oracle@rac2 dbs]$ orapwd file=orapworcl2 password=oracle
[oracle@rac2 dbs]$
[oracle@rac2 ~]$ cd $ORACLE_HOME/dbs
[oracle@rac2 dbs]$ orapwd file=orapworcl2 password=oracle
[oracle@rac2 dbs]$
3. 修改初始化引數檔案
[oracle@rac1 ~]$ cp /u02/backup_db/initorcl.ora $ORACLE_HOME/dbs/initorcl1.ora
[oracle@rac1 dbs]$ vi $ORACLE_HOME/dbs/initorcl1.ora
新增:
*.cluster_database = TRUE
*.cluster_database_instances = 2
*.undo_management=AUTO
orcl1.undo_tablespace=UNDOTBS1
orcl1.instance_name=orcl1
orcl1.instance_number=1
orcl1.thread=1
orcl1.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.72.101)(PORT=1521))'
orcl2.instance_name=orcl2
orcl2.instance_number=2
orcl2.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.72.102)(PORT=1521))'
orcl2.thread=2
orcl2.undo_tablespace=UNDOTBS2
orcl2.cluster_database = TRUE
orcl2.cluster_database_instances = 2
*.cluster_database_instances = 2
*.undo_management=AUTO
orcl1.undo_tablespace=UNDOTBS1
orcl1.instance_name=orcl1
orcl1.instance_number=1
orcl1.thread=1
orcl1.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.72.101)(PORT=1521))'
orcl2.instance_name=orcl2
orcl2.instance_number=2
orcl2.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.72.102)(PORT=1521))'
orcl2.thread=2
orcl2.undo_tablespace=UNDOTBS2
orcl2.cluster_database = TRUE
orcl2.cluster_database_instances = 2
新增的引數可以參照下面的文件:
*.cluster_database = TRUE
*.cluster_database_instances = 2
*.undo_management=AUTO
.undo_tablespace=undotbs (undo tablespace which already exists)
.instance_name=
.instance_number=1
.thread=1
.local_listener=_
.instance_name=
.instance_number=2
.local_listener=_
.thread=2
.undo_tablespace=UNDOTBS2
.cluster_database = TRUE
.cluster_database_instances = 2
*.cluster_database_instances = 2
*.undo_management=AUTO
=================================================================
4. 將資料庫由檔案系統遷移到ASM
(1) 新增和修改初始化引數
檢視存在的ASM磁碟組:
[oracle@rac1 dbs]$ export ORACLE_SID=+ASM1
[oracle@rac1 dbs]$ sqlplus / as sysdba
[oracle@rac1 dbs]$ sqlplus / as sysdba
SQL> select name from v$asm_diskgroup;
NAME
------------------------------
DATA
FRA
------------------------------
DATA
FRA
SQL>
修改和新增初始化引數:
[oracle@rac1 dbs]$ vi $ORACLE_HOME/dbs/initorcl1.ora
將
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
變為
*.db_recovery_file_dest='+FRA'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
變為
*.db_recovery_file_dest='+FRA'
新增:
*.db_create_file_dest='+DATA'
*.db_create_file_dest='+DATA'
(2) 建立SPFILE
從pfile中清除 *.control_files,然後建立spfile
[oracle@rac1 dbs]$ vi $ORACLE_HOME/dbs/initorcl1.ora
刪除control_files這一行
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl','/u01/app/oracle/oradata/orcl/control03.ctl'
[oracle@rac1 dbs]$ export ORACLE_SID=orcl1
[oracle@rac1 dbs]$ sqlplus "/as sysdba"
Connected to an idle instance.
SQL> create spfile from pfile;
File created.
SQL> startup nomount
ORACLE instance started.
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1275128 bytes
Variable Size 163580680 bytes
Database Buffers 440401920 bytes
Redo Buffers 2916352 bytes
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
[oracle@rac1 dbs]$
Fixed Size 1275128 bytes
Variable Size 163580680 bytes
Database Buffers 440401920 bytes
Redo Buffers 2916352 bytes
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
[oracle@rac1 dbs]$
(3) 恢復資料庫
[oracle@rac1 dbs]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Wed Nov 14 14:52:12 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: orcl (not mounted)
RMAN> restore controlfile from '/u02/backup_db/ORCL_25_798936484_1_full_ctl.bus';
Starting restore at 14-NOV-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=150 instance=orcl1 devtype=DISK
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=150 instance=orcl1 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
output filename=+DATA/orcl/controlfile/current.395.799339993
output filename=+FRA/orcl/controlfile/current.289.799339995
Finished restore at 14-NOV-12
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
output filename=+DATA/orcl/controlfile/current.395.799339993
output filename=+FRA/orcl/controlfile/current.289.799339995
Finished restore at 14-NOV-12
RMAN>
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
released channel: ORA_DISK_1
RMAN> report schema;
Starting implicit crosscheck backup at 14-NOV-12
allocated channel: ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck backup at 14-NOV-12
allocated channel: ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck backup at 14-NOV-12
Starting implicit crosscheck copy at 14-NOV-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 14-NOV-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 14-NOV-12
searching for all files in the recovery area
cataloging files...
no files cataloged
cataloging files...
no files cataloged
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 0 SYSTEM *** /u01/app/oracle/oradata/orcl/system01.dbf
2 0 UNDOTBS1 *** /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 0 SYSAUX *** /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 0 USERS *** /u01/app/oracle/oradata/orcl/users01.dbf
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 0 SYSTEM *** /u01/app/oracle/oradata/orcl/system01.dbf
2 0 UNDOTBS1 *** /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 0 SYSAUX *** /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 0 USERS *** /u01/app/oracle/oradata/orcl/users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /u01/app/oracle/oradata/orcl/temp01.dbf
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /u01/app/oracle/oradata/orcl/temp01.dbf
RMAN>
根據上面的輸出,我們可以看到單節點的資料庫,以前的資料檔案的存放路徑;我們要對其進行修改,讓其資料檔案存放到磁碟組中,在RMAN中執行下面的語句。
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
set newname for datafile 1 to '+DATA';
set newname for datafile 2 to '+DATA';
set newname for datafile 3 to '+DATA';
set newname for datafile 4 to '+DATA';
restore database;
}
set newname for datafile 2 to '+DATA';
set newname for datafile 3 to '+DATA';
set newname for datafile 4 to '+DATA';
restore database;
}
RMAN> run {
2> allocate channel d1 type disk;
3> allocate channel d2 type disk;
4> allocate channel d3 type disk;
5>
6> set newname for datafile 1 to '+DATA';
7> set newname for datafile 2 to '+DATA';
8> set newname for datafile 3 to '+DATA';
9> set newname for datafile 4 to '+DATA';
10> restore database;
11> }
2> allocate channel d1 type disk;
3> allocate channel d2 type disk;
4> allocate channel d3 type disk;
5>
6> set newname for datafile 1 to '+DATA';
7> set newname for datafile 2 to '+DATA';
8> set newname for datafile 3 to '+DATA';
9> set newname for datafile 4 to '+DATA';
10> restore database;
11> }
released channel: ORA_DISK_1
allocated channel: d1
channel d1: sid=150 instance=orcl1 devtype=DISK
allocated channel: d1
channel d1: sid=150 instance=orcl1 devtype=DISK
allocated channel: d2
channel d2: sid=146 instance=orcl1 devtype=DISK
channel d2: sid=146 instance=orcl1 devtype=DISK
allocated channel: d3
channel d3: sid=145 instance=orcl1 devtype=DISK
channel d3: sid=145 instance=orcl1 devtype=DISK
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 14-NOV-12
channel d1: starting datafile backupset restore
channel d1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to +DATA
restoring datafile 00003 to +DATA
channel d1: reading from backup piece /u02/backup_db/ORCL_21_798936465_1_full_db.bus
channel d2: starting datafile backupset restore
channel d2: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +DATA
restoring datafile 00004 to +DATA
channel d2: reading from backup piece /u02/backup_db/ORCL_20_798936465_1_full_db.bus
channel d1: restored backup piece 1
piece handle=/u02/backup_db/ORCL_21_798936465_1_full_db.bus tag=FULL_DB_BK
channel d1: restore complete, elapsed time: 00:00:26
channel d2: restored backup piece 1
piece handle=/u02/backup_db/ORCL_20_798936465_1_full_db.bus tag=FULL_DB_BK
channel d2: restore complete, elapsed time: 00:00:41
Finished restore at 14-NOV-12
released channel: d1
released channel: d2
released channel: d3
channel d1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to +DATA
restoring datafile 00003 to +DATA
channel d1: reading from backup piece /u02/backup_db/ORCL_21_798936465_1_full_db.bus
channel d2: starting datafile backupset restore
channel d2: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +DATA
restoring datafile 00004 to +DATA
channel d2: reading from backup piece /u02/backup_db/ORCL_20_798936465_1_full_db.bus
channel d1: restored backup piece 1
piece handle=/u02/backup_db/ORCL_21_798936465_1_full_db.bus tag=FULL_DB_BK
channel d1: restore complete, elapsed time: 00:00:26
channel d2: restored backup piece 1
piece handle=/u02/backup_db/ORCL_20_798936465_1_full_db.bus tag=FULL_DB_BK
channel d2: restore complete, elapsed time: 00:00:41
Finished restore at 14-NOV-12
released channel: d1
released channel: d2
released channel: d3
RMAN>
RMAN> switch database to copy;
datafile 1 switched to datafile copy "+DATA/orcl/datafile/system.401.799340335"
datafile 2 switched to datafile copy "+DATA/orcl/datafile/undotbs1.330.799340335"
datafile 3 switched to datafile copy "+DATA/orcl/datafile/sysaux.416.799340333"
datafile 4 switched to datafile copy "+DATA/orcl/datafile/users.351.799340335"
datafile 2 switched to datafile copy "+DATA/orcl/datafile/undotbs1.330.799340335"
datafile 3 switched to datafile copy "+DATA/orcl/datafile/sysaux.416.799340333"
datafile 4 switched to datafile copy "+DATA/orcl/datafile/users.351.799340335"
RMAN> recover database;
Starting recover at 14-NOV-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=150 instance=orcl1 devtype=DISK
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=150 instance=orcl1 devtype=DISK
starting media recovery
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=16
channel ORA_DISK_1: reading from backup piece /u02/backup_db/ORCL_24_798936483_1_full_arch.bus
channel ORA_DISK_1: restored backup piece 1
piece handle=/u02/backup_db/ORCL_24_798936483_1_full_arch.bus tag=FULL_DB_BK
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=+FRA/orcl/archivelog/2012_11_14/thread_1_seq_16.290.799340411 thread=1 sequence=16
channel default: deleting archive log(s)
archive log filename=+FRA/orcl/archivelog/2012_11_14/thread_1_seq_16.290.799340411 recid=19 stamp=799340412
unable to find archive log
archive log thread=1 sequence=17
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/14/2012 15:00:19
RMAN-06054: media recovery requesting unknown log: thread 1 seq 17 lowscn 417407
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=16
channel ORA_DISK_1: reading from backup piece /u02/backup_db/ORCL_24_798936483_1_full_arch.bus
channel ORA_DISK_1: restored backup piece 1
piece handle=/u02/backup_db/ORCL_24_798936483_1_full_arch.bus tag=FULL_DB_BK
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=+FRA/orcl/archivelog/2012_11_14/thread_1_seq_16.290.799340411 thread=1 sequence=16
channel default: deleting archive log(s)
archive log filename=+FRA/orcl/archivelog/2012_11_14/thread_1_seq_16.290.799340411 recid=19 stamp=799340412
unable to find archive log
archive log thread=1 sequence=17
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/14/2012 15:00:19
RMAN-06054: media recovery requesting unknown log: thread 1 seq 17 lowscn 417407
RMAN> exit
Recovery Manager complete.
[oracle@rac1 dbs]$
##########################################################
5. 建立thread 2的日誌和另一個節點的undo表空間
[oracle@rac1 dbs]$ export ORACLE_SID=orcl1
[oracle@rac1 dbs]$ sqlplus / as sysdba
[oracle@rac1 dbs]$ sqlplus / as sysdba
檢視節點1的日誌,建立指定的目錄:
SQL> set linesize 180
SQL> col member format a50
SQL> select * from v$logfile;
SQL> col member format a50
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO
---------- ------- ------- -------------------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/orcl/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/orcl/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/orcl/redo01.log NO
SQL> host mkdir -p /u01/app/oracle/oradata/orcl/
建立日誌組和UNDO表空間,用於例項2的使用:
alter database add logfile thread 2
group 5 size 100M,
group 6 size 100M,
group 7 size 100M;
group 5 size 100M,
group 6 size 100M,
group 7 size 100M;
SQL> alter database add logfile thread 2
2 group 5 size 100M,
3 group 6 size 100M,
4 group 7 size 100M;
Database altered.
SQL> alter database open resetlogs;
Database altered.
SQL> alter database enable public thread 2;
Database altered.
SQL> CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE '+DATA';
Tablespace created.
SQL>
6. 將在檔案系統存放的日誌,遷移到+ASM
alter database add logfile thread 1
group 8 size 100M,
group 9 size 100M;
group 8 size 100M,
group 9 size 100M;
alter database drop logfile group 2;
alter database drop logfile group 3;
alter database drop logfile group 3;
alter system switch logfile;
alter system checkpoint;
alter database drop logfile group 1;
alter database add logfile group 1 size 100m, group 2 size 100m, group 3 size 100m;
alter database drop logfile group 1;
alter database add logfile group 1 size 100m, group 2 size 100m, group 3 size 100m;
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
1 ONLINE +DATA/orcl/onlinelog/group_1.412.799341123 NO
1 ONLINE +FRA/orcl/onlinelog/group_1.265.799341129 YES
2 ONLINE +DATA/orcl/onlinelog/group_2.408.799341137 NO
5 ONLINE +DATA/orcl/onlinelog/group_5.363.799340635 NO
5 ONLINE +FRA/orcl/onlinelog/group_5.290.799340641 YES
6 ONLINE +DATA/orcl/onlinelog/group_6.386.799340649 NO
6 ONLINE +FRA/orcl/onlinelog/group_6.291.799340655 YES
7 ONLINE +DATA/orcl/onlinelog/group_7.389.799340661 NO
7 ONLINE +FRA/orcl/onlinelog/group_7.275.799340667 YES
8 ONLINE +DATA/orcl/onlinelog/group_8.400.799341055 NO
8 ONLINE +FRA/orcl/onlinelog/group_8.264.799341061 YES
---------- ------- ------- -------------------------------------------------- ---
1 ONLINE +DATA/orcl/onlinelog/group_1.412.799341123 NO
1 ONLINE +FRA/orcl/onlinelog/group_1.265.799341129 YES
2 ONLINE +DATA/orcl/onlinelog/group_2.408.799341137 NO
5 ONLINE +DATA/orcl/onlinelog/group_5.363.799340635 NO
5 ONLINE +FRA/orcl/onlinelog/group_5.290.799340641 YES
6 ONLINE +DATA/orcl/onlinelog/group_6.386.799340649 NO
6 ONLINE +FRA/orcl/onlinelog/group_6.291.799340655 YES
7 ONLINE +DATA/orcl/onlinelog/group_7.389.799340661 NO
7 ONLINE +FRA/orcl/onlinelog/group_7.275.799340667 YES
8 ONLINE +DATA/orcl/onlinelog/group_8.400.799341055 NO
8 ONLINE +FRA/orcl/onlinelog/group_8.264.799341061 YES
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
9 ONLINE +DATA/orcl/onlinelog/group_9.413.799341067 NO
9 ONLINE +FRA/orcl/onlinelog/group_9.292.799341073 YES
2 ONLINE +FRA/orcl/onlinelog/group_2.286.799341147 YES
3 ONLINE +DATA/orcl/onlinelog/group_3.394.799341153 NO
3 ONLINE +FRA/orcl/onlinelog/group_3.287.799341161 YES
---------- ------- ------- -------------------------------------------------- ---
9 ONLINE +DATA/orcl/onlinelog/group_9.413.799341067 NO
9 ONLINE +FRA/orcl/onlinelog/group_9.292.799341073 YES
2 ONLINE +FRA/orcl/onlinelog/group_2.286.799341147 YES
3 ONLINE +DATA/orcl/onlinelog/group_3.394.799341153 NO
3 ONLINE +FRA/orcl/onlinelog/group_3.287.799341161 YES
16 rows selected.
SQL>
7. 建立cluster database的檢視
create cluster database specific views within the existing instance
SQL> @$ORACLE_HOME/rdbms/admin/catclust.sql
8. 遷移臨時檔案
SQL> alter tablespace temp add tempfile '+DATA';
SQL> alter database tempfile '/u01/app/oracle/oradata/orcl/temp01.dbf' drop;
########################################################################
9. crs環境資訊建立
在節點1操作:
[oracle@rac1 dbs]$ export ORACLE_SID=orcl1
[oracle@rac1 dbs]$ sqlplus / as sysdba
SQL> shutdown immediate
SQL> create pfile from spfile;
SQL> create spfile='+DATA/orcl/spfileorcl.ora' from pfile;
SQL> create spfile='+DATA/orcl/spfileorcl.ora' from pfile;
SQL> exit
[oracle@rac1 dbs]$ cd /u01/app/oracle/oracle/product/10.2.0/db_1/dbs
[oracle@rac1 dbs]$ rm spfileorcl1.ora
[oracle@rac1 dbs]$ echo "spfile='+DATA/orcl/spfileorcl.ora'" > initorcl1.ora
[oracle@rac1 dbs]$ rm spfileorcl1.ora
[oracle@rac1 dbs]$ echo "spfile='+DATA/orcl/spfileorcl.ora'" > initorcl1.ora
在節點2操作:
[oracle@rac2 dbs]$ cd /u01/app/oracle/oracle/product/10.2.0/db_1/dbs
[oracle@rac2 dbs]$ rm spfileorcl2.ora
rm: cannot remove `spfileorcl2.ora': No such file or directory
[oracle@rac2 dbs]$ echo "spfile='+DATA/orcl/spfileorcl.ora'" > initorcl2.ora
[oracle@rac2 dbs]$
10. 配置並啟動RAC資料庫
[oracle@rac1 dbs]$ srvctl add database -d orcl -o /u01/app/oracle/oracle/product/10.2.0/db_1
[oracle@rac1 dbs]$ srvctl add instance -d orcl -i orcl1 -n rac1
[oracle@rac1 dbs]$ srvctl add instance -d orcl -i orcl2 -n rac2
[oracle@rac1 dbs]$ srvctl add instance -d orcl -i orcl1 -n rac1
[oracle@rac1 dbs]$ srvctl add instance -d orcl -i orcl2 -n rac2
[oracle@rac1 dbs]$ srvctl modify instance -d orcl -i orcl1 -s +ASM1
[oracle@rac1 dbs]$ srvctl modify instance -d orcl -i orcl2 -s +ASM2
[oracle@rac1 dbs]$ srvctl modify instance -d orcl -i orcl2 -s +ASM2
[oracle@rac1 dbs]$ srvctl start database -d orcl
[oracle@rac1 dbs]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.orcl.db application ONLINE ONLINE rac2
ora....l1.inst application ONLINE ONLINE rac1
ora....l2.inst application ONLINE ONLINE rac2
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
ora....b.AP.cs application OFFLINE OFFLINE
ora....db1.srv application OFFLINE OFFLINE
ora....b.GL.cs application OFFLINE OFFLINE
ora....db2.srv application OFFLINE OFFLINE
ora.racdb.db application OFFLINE OFFLINE
ora....b1.inst application OFFLINE OFFLINE
ora....b2.inst application OFFLINE OFFLINE
[oracle@rac1 dbs]$
[oracle@rac1 dbs]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.orcl.db application ONLINE ONLINE rac2
ora....l1.inst application ONLINE ONLINE rac1
ora....l2.inst application ONLINE ONLINE rac2
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
ora....b.AP.cs application OFFLINE OFFLINE
ora....db1.srv application OFFLINE OFFLINE
ora....b.GL.cs application OFFLINE OFFLINE
ora....db2.srv application OFFLINE OFFLINE
ora.racdb.db application OFFLINE OFFLINE
ora....b1.inst application OFFLINE OFFLINE
ora....b2.inst application OFFLINE OFFLINE
[oracle@rac1 dbs]$
##############################################
11. tnsnames.ora 網路配置檔案
在兩個節點的tnsnames.ora檔案中操作
[oracle@rac1 dbs]$ cd $ORACLE_HOME/network/admin
[oracle@rac1 admin]$ vi tnsnames.ora
[oracle@rac1 admin]$ vi tnsnames.ora
新增:
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip.localdomain)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip.localdomain)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
ORCL1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
(INSTANCE_NAME = orcl1)
)
)
ORCL2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
(INSTANCE_NAME = orcl2)
)
)
LISTENERS_ORCL =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip.localdomain)(PORT = 1521))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.localdomain)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip.localdomain)(PORT = 1521))
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
12. 驗證
[oracle@rac1 admin]$ sqlplus
SQL> col inst_name format a50
SQL> select * from v$active_instances;
INST_NUMBER INST_NAME
----------- --------------------------------------------------
1 rac1.localdomain:orcl1
----------- --------------------------------------------------
1 rac1.localdomain:orcl1
2 rac2.localdomain:orcl2
SQL> col host_name format a20
SQL> select instance_name, host_name, archiver, thread#, status from gv$instance;
SQL> select instance_name, host_name, archiver, thread#, status from gv$instance;
INSTANCE_NAME HOST_NAME ARCHIVE THREAD# STATUS
---------------- -------------------- ------- ---------- ------------
orcl1 rac1.localdomain STARTED 1 OPEN
orcl2 rac2.localdomain STARTED 2 OPEN
---------------- -------------------- ------- ---------- ------------
orcl1 rac1.localdomain STARTED 1 OPEN
orcl2 rac2.localdomain STARTED 2 OPEN
SQL>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27571661/viewspace-761316/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 11g RAC到單例項OGG同步Oracle單例
- oracle rac 單個例項不能生成awr報告的問題Oracle
- ORA-29702複製RAC Oracle軟體啟動單例項Oracle單例
- 記錄一次Oracle 11.2.0.4 RAC異地恢復到單例項Oracle單例
- Oracle 資料庫巡檢指令碼 單例項 RAC 輸出HTML格式Oracle資料庫指令碼單例HTML
- Disable Database Audit In Oracle 19c RAC-20220111DatabaseOracle
- Oracle RAC 遷移替換 OCR 盤Oracle
- oracle之 單例項監聽修改埠Oracle單例
- oracle資料庫與oracle例項Oracle資料庫
- 4.1. Oracle例項Oracle
- Oracle Far Sync例項Oracle
- ORACLE11GR2 RAC解除安裝ASM例項步驟OracleASM
- oracle資料庫跨平臺(AIX)從RAC恢復至(linux)下的單例項Oracle資料庫AILinux單例
- rac恢復到單例項單例
- RAC+DG(asm單例項)ASM單例
- oracle RACOracle
- Oracle Database 19c(19.9) RAC On RedHat 8.3 Using VirtualBox and MacBookOracleDatabaseRedhatMac
- oracle 例項表查詢Oracle
- 平安科技從 Oracle 遷移到 UbiSQL 的實踐OracleSQL
- 將 CentOS 8 作業系統遷移到 Oracle LinuxCentOS作業系統OracleLinux
- Oracle RAC Cache Fusion 系列十七:Oracle RAC DRMOracle
- oracle RAC 更換儲存遷移資料Oracle
- ORACLE database vaultOracleDatabase
- Oracle clone databaseOracleDatabase
- Oracle 例項和RAC叢集下資料庫日誌目錄合集Oracle資料庫
- Oracle RAC CacheFusion 系列十五:Oracle RAC CRServer Part TwoOracleServer
- Oracle 遷移到 OB 過程中的函式改造案例Oracle函式
- Networker恢復oracle rac到單機Oracle
- Oracle搭建rac到單庫的adgOracle
- ORACLE-LINUX環境字元介面單例項安裝OracleLinux字元單例
- Oracle 11G資料庫單例項安裝Oracle資料庫單例
- 【PSU】Oracle打PSU及解除安裝PSU(單例項)Oracle單例
- ORACLE RAC clusterwareOracle
- Oracle Database Scheduler整理OracleDatabase
- Oracle Physical Database LimitsOracleDatabaseMIT
- Oracle RAC Cache Fusion系列十八:Oracle RAC Statisticsand Wait EventsOracleAI
- oracle 12c RAC安裝,例項不能多節點同時啟動Oracle
- Oracle Database Cloud - Database as a Service Quick StartOracleDatabaseCloudUI
- Oracle 11.2 DataGuard RAC To RAC搭建Oracle