ORACLE10gRAC数据库迁移至10gRAC
Posted datalife
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ORACLE10gRAC数据库迁移至10gRAC相关的知识,希望对你有一定的参考价值。
1、数据库备份
RUN {
ALLOCATE CHANNEL ch00 DEVICE TYPE disk;
ALLOCATE CHANNEL ch01 DEVICE TYPE disk;
ALLOCATE CHANNEL ch02 DEVICE TYPE disk;
ALLOCATE CHANNEL ch03 DEVICE TYPE disk;
ALLOCATE CHANNEL ch04 DEVICE TYPE disk;
ALLOCATE CHANNEL ch05 DEVICE TYPE disk;
backup as compressed backupset database filesperset 5 format ‘/backup/bk_%d_%T%s_%p‘ ;
sql ‘alter system archive log current‘;
backup current controlfile format ‘/backup/ctl_%d_%T_%s‘;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
RELEASE CHANNEL ch04;
RELEASE CHANNEL ch05;
}
备份完成后多切换几次redo日志
2、数据库恢复
一 检验条件
二 准备工作
拷贝备份文件到目标服务器:scp -r backup/ 10.168.39.243:/backup
1 创建相关目录
两节点
mkdir -p /oracle/admin/orcl/adump
mkdir -p /oracle/admin/orcl/bdump
mkdir -p /oracle/admin/orcl/cdump
mkdir -p /oracle/admin/orcl/udump
mkdir -p /oracle/admin/orcl/pfile
mkdir -p /oracle/arch
节点1
mkdir /rac_arch1
chown -R oracle:oinstall /rac_arch1/
chmod -R 775 /rac_arch1/
节点2
mkdir /rac_arch2
chown -R oracle:oinstall /rac_arch2/
chmod -R 775 /rac_arch2/
2参数文件
使用oracle用户
vi pfile0928.ora
orcl2.__db_cache_size=1090519040
orcl1.__db_cache_size=1140850688
orcl1.__java_pool_size=16777216
orcl2.__java_pool_size=16777216
orcl1.__large_pool_size=16777216
orcl2.__large_pool_size=33554432
orcl2.__shared_pool_size=402653184
orcl1.__shared_pool_size=369098752
orcl1.__streams_pool_size=16777216
orcl2.__streams_pool_size=16777216
*.audit_file_dest=‘/oracle/admin/orcl/adump‘
*.background_dump_dest=‘/oracle/admin/orcl/bdump‘
*.cluster_database_instances=2
*.cluster_database=true
*.compatible=‘10.2.0.5.0‘
*.control_files=‘+ORCLDATA/orcl/controlfile/current01.ctl‘,‘+ORCLDATA/orcl/controlfile/current02.ctl‘,‘+ORCLDATA/orcl/controlfile/current03.ctl‘
*.core_dump_dest=‘/oracle/admin/orcl/cdump‘
*.cursor_sharing=‘FORCE‘
*.db_block_size=8192
*.db_create_file_dest=‘+ORCLDATA‘
*.db_domain=‘‘
*.db_file_multiblock_read_count=16
*.db_name=‘orcl‘
*.db_writer_processes=2
*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=orclXDB)‘
orcl2.instance_number=2
orcl1.instance_number=1
*.job_queue_processes=10
orcl1.local_listener=‘(ADDRESS=(PROTOCOL=TCP)(HOST=10.168.39.242)(PORT=1521))‘
orcl2.local_listener=‘(ADDRESS=(PROTOCOL=TCP)(HOST=10.168.39.244)(PORT=1521))‘
#orcl1.log_archive_dest_1=‘location=/rac_arch1‘
#orcl2.log_archive_dest_1=‘location=/rac_arch2‘
*.log_archive_dest_1=‘location=/backup‘
*.open_cursors=300
*.optimizer_index_caching=95
*.optimizer_index_cost_adj=5
*.optimizer_mode=‘FIRST_ROWS_10‘
*.pga_aggregate_target=3359637504
*.processes=1000
orcl1.processes=1500
orcl2.processes=1500
*.remote_listener=‘LISTENERS_ORCL‘
*.remote_login_passwordfile=‘exclusive‘
orcl1.sessions=1655
orcl2.sessions=1655
*.sga_target=1610612736
orcl2.thread=2
orcl1.thread=1
*.undo_management=‘AUTO‘
orcl2.undo_tablespace=‘UNDOTBS2‘
orcl1.undo_tablespace=‘UNDOTBS1‘
*.user_dump_dest=‘/oracle/admin/orcl/udump‘
三 启动实例
$ export ORACLE_SID=orcl1
sqlplus / as sysdba
startup nomount pfile=‘/oracle/pfile0928.ora‘
四 恢复控制文件
rman target /
set dbid=1340406187
restore controlfile from ‘/backup/ctl_ORCL_20150928_7830‘;
六 恢复数据库
alter database mount;
run {
ALLOCATE CHANNEL ch00 DEVICE TYPE disk;
ALLOCATE CHANNEL ch01 DEVICE TYPE disk;
ALLOCATE CHANNEL ch02 DEVICE TYPE disk;
ALLOCATE CHANNEL ch03 DEVICE TYPE disk;
restore database;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
}
注册归档日志:
catalog archivelog ‘/backup_243/1_24712_812625454.dbf‘;
catalog archivelog ‘/backup_243/1_24713_812625454.dbf‘;
catalog archivelog ‘/backup_243/1_24714_812625454.dbf‘;
catalog archivelog ‘/backup_243/1_24715_812625454.dbf‘;
catalog archivelog ‘/backup_243/1_24716_812625454.dbf‘;
catalog archivelog ‘/backup_243/2_22519_812625454.dbf‘;
catalog archivelog ‘/backup_243/2_22520_812625454.dbf‘;
catalog archivelog ‘/backup_243/2_22521_812625454.dbf‘;
catalog archivelog ‘/backup_243/2_22522_812625454.dbf‘;
catalog archivelog ‘/backup_243/2_22523_812625454.dbf‘;
run {
ALLOCATE CHANNEL ch00 DEVICE TYPE disk;
ALLOCATE CHANNEL ch01 DEVICE TYPE disk;
ALLOCATE CHANNEL ch02 DEVICE TYPE disk;
ALLOCATE CHANNEL ch03 DEVICE TYPE disk;
recover database;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
}
六 打开数据库
SQL> alter database open resetlogs;
七 数据库整理
修改spfile启动 shutdown immediate
create spfile=‘+ORCLDATA/orcl/SPFILE/spfileorcl.ora‘ from pfile=‘/oracle/product/10.2.0/db_1/dbs/initorcl1.ora‘;
echo "SPFILE=‘+ORCLDATA/orcl/SPFILE/spfileorcl.ora‘" > /oracle/product/10.2.0/db_1/dbs/initorcl1.ora
startup
show parameter spfile
八、启用集群特性:
select * from v$option where parameter = ‘Real Application Clusters‘;
show parameter cluster
alter system set cluster_database=true scope=spfile;
alter system set cluster_database_instances=2 scope=spfile;
alter system set instance_number=1 scope=spfile sid=‘orcl1‘;
alter system set instance_number=2 scope=spfile sid=‘orcl2‘;
alter system set thread=1 scope=spfile sid=‘orcl1‘;
alter system set thread=2 scope=spfile sid=‘orcl2‘;
新建一组UNDO 表空间和线程2 使用的两组REDO 文件:这里已经创建。
alter database enable thread 2;
修改归档路径为两个节点:
alter system set log_archive_dest_1=‘location=/arch1‘ scope=spfile sid=‘orcl1‘;
alter system set log_archive_dest_1=‘location=/arch2‘ scope=spfile sid=‘orcl2‘;
节点2
export ORACLE_SID=orcl2
echo "SPFILE=‘+ORCLDATA/orcl/SPFILE/spfileorcl.ora‘" > /oracle/product/10.2.0/db_1/dbs/initorcl2.ora
sqlplus / as sysdba
startup
set line 150 pages 1000
show parameter cluster;
select instance_number,instance_name,host_name from v$instance;
select instance_number,instance_name,host_name from gv$instance;
注册到OCR
srvctl add database -d orcl -o $ORACLE_HOME -p +ORCLDATA/orcl/SPFILE/spfileorcl.ora
srvctl add instance -d orcl -i orcl1 -n hostname1
srvctl add instance -d orcl -i orcl2 -n hostname2
srvctl start database -d orcl
监听 、tnsnames.ora
alter system set local_listener=‘(ADDRESS = (PROTOCOL = TCP)(HOST =10.168.34.243)(PORT = 1521))‘ scope=both sid=‘orcl1‘;
alter system set local_listener=‘(ADDRESS = (PROTOCOL = TCP)(HOST =10.168.34.245)(PORT = 1521))‘ scope=both sid=‘orcl2‘;
tnsnames.ora
LISTENERS_ORCL =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname2-vip)(PORT = 1521))
)
ORCL2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname2-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
(INSTANCE_NAME = orcl2)
)
)
ORCL1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname1-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
(INSTANCE_NAME = orcl1)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname2-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
修改SGA PGA 以sys用户登录系统
alter system set sga_max_size=30000m scope=spfile sid=‘*‘;
alter system set sga_target=30000m scope=spfile sid=‘*‘;
alter system set pga_aggregate_target=8000m scope=spfile sid=‘*‘;
重启数据库
show parameter 查看
sqlplus / as sysdba
alter system set sga_max_size=3500m scope=spfile
alter system set sga_target=3000m scope=spfile
alter system set pga_aggregate_target=1500m scope=spfile;
shutdown immediate
startup
show parameter sga
show parameter pga
拷贝生产环境密码文件到两个节点:
八、验证
select open_mode from v$database;
select instance_name,status from gv$instance;
select name,status from v$datafile;
select name ,status from v$controlfile;
select count(*) from dba_objects;
select count(*) from dba_segments;
至此RAC数据库迁移至RAC完毕。
以上是关于ORACLE10gRAC数据库迁移至10gRAC的主要内容,如果未能解决你的问题,请参考以下文章
如何完全删载与清除oracle 10grac cluster