当前位置:网站首页>把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(1)——迁移数据到节点1
把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(1)——迁移数据到节点1
2022-06-24 22:54:00 【睿思达DBA_WGX】
把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(1)——迁移数据到节点1
目录
一、把要导出的源数据库设置为非归档模式
-- 1、停库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
-- 2、启动数据库到 mount
SQL> startup mount
ORACLE instance started.
Total System Global Area 3357155328 bytes
Fixed Size 2180384 bytes
Variable Size 1828719328 bytes
Database Buffers 1509949440 bytes
Redo Buffers 16306176 bytes
Database mounted.
-- 3、修改数据库的归档模式为非归档模式
SQL> alter database noarchivelog;
Database altered.
-- 4、打开数据库
SQL> alter database open;
Database altered.
-- 5、查看归档模式
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 3
二、在 源数据库上执行数据库全备
1、创建存放备份文件的 目录
F:\>md rman_bak
F:\>dir da*
驱动器 F 中的卷是 新加卷
卷的序列号是 544F-5332
F:\ 的目录
14/06/2022 22:50 <DIR> rman_bak
0 个文件 0 字节
1 个目录 234,147,532,800 可用字节
2、查看源数据库的数据库名和实例名
SQL> show parameter name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string hisdb
db_unique_name string hisdb
global_names boolean FALSE
instance_name string hisdb
lock_name_space string
log_file_name_convert string
service_names string hisdb
-- 数据库名和实例名都是 hisdb
3、停库,然后启动数据库到 mount
-- 停库
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
-- 启动数据库到 mount 状态
SQL> startup mount;
ORACLE instance started.
Total System Global Area 3357155328 bytes
Fixed Size 2180384 bytes
Variable Size 2332035808 bytes
Database Buffers 1006632960 bytes
Redo Buffers 16306176 bytes
Database mounted.
File created.
4、备份参数文件
SQL> create pfile='f:/rman_bak/pfile0614.ora' from spfile;
5、进入rman,执行备份操作
C:\Users\Administrator>rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jun 14 15:41:09 2022
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: HISDB (DBID=2002805648)
RMAN>
-- 设置 rman 备份的路径及文件格式
-- configure channel device type disk format 'f:/rman_bak/%d_%I_%s_%p_%T.bkp';
RMAN> configure channel device type disk format 'f:/rman_bak/%d_%I_%s_%p_%T.bkp';
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'f:/rman_bak/%d_%I_%s_%p_%T.bkp';
new RMAN configuration parameters are successfully stored
-- 备份数据库
-- backup as compressed backupset database;
RMAN> backup as compressed backupset database;
Starting backup at 14-JUN-22
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=131 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=F:\APP\ORADATA\HISDB\SYSTEM01.DBF
input datafile file number=00002 name=F:\APP\ORADATA\HISDB\SYSAUX01.DBF
input datafile file number=00003 name=F:\APP\ORADATA\HISDB\UNDOTBS01.DBF
input datafile file number=00005 name=F:\APP\ORADATA\HISDB\TS001.DBF
input datafile file number=00006 name=F:\APP\ORADATA\HISDB\TS002.DBF
input datafile file number=00004 name=F:\APP\ORADATA\HISDB\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 14-JUN-22
channel ORA_DISK_1: finished piece 1 at 14-JUN-22
piece handle=F:\RMAN_BAK\HISDB_2002805648_10_1_20220614.BKP tag=TAG20220614T155620 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 14-JUN-22
channel ORA_DISK_1: finished piece 1 at 14-JUN-22
piece handle=F:\RMAN_BAK\HISDB_2002805648_11_1_20220614.BKP tag=TAG20220614T155620 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 14-JUN-22
三、把备份文件上传到 oracle rac 集群的 rac1 节点
[[email protected] data-bak]$ pwd
/home/oracle/data-bak
[[email protected] data-bak]$ ll
total 298580
-rw-r--r-- 1 oracle oinstall 304627712 Jun 14 15:56 HISDB_2002805648_10_1_20220614.BKP
-rw-r--r-- 1 oracle oinstall 1114112 Jun 14 15:56 HISDB_2002805648_11_1_20220614.BKP
-rw-r--r-- 1 oracle oinstall 902 Jun 14 23:26 pfile0614.ora
四、修改参数文件
1、修改环境变量(设置 ORACLE_SID=hisdb)
#节点1
[[email protected] ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_OWNER=oracle
export ORACLE_SID=hisdb1 # ORACLE_SID=hisdb1
export ORACLE_TERM=vt100
export THREADS_FLAG=native
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
export EDITOR=vi
export SQLPATH=/home/oracle
export LANG=en_US
alias sqlplus='rlwrap sqlplus'
alias lsnrctl='rlwrap lsnrctl'
alias rman='rlwrap rman'
alias dgmgrl='rlwrap dgmgrl'
[[email protected] ~]$ source .bash_profile
#节点2
[[email protected] ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_OWNER=oracle
export ORACLE_SID=hisdb2 # ORACLE_SID=hisdb2
export ORACLE_TERM=vt100
export THREADS_FLAG=native
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
export EDITOR=vi
export SQLPATH=/home/oracle
export LANG=en_US
alias sqlplus='rlwrap sqlplus'
alias lsnrctl='rlwrap lsnrctl'
alias rman='rlwrap rman'
alias dgmgrl='rlwrap dgmgrl'
[[email protected] ~]$ source .bash_profile
2、修改参数文件的内容
[[email protected] data-bak]$ pwd
/home/oracle/data-bak
[[email protected] data-bak]$ ll
total 298580
-rw-r--r-- 1 oracle oinstall 304627712 Jun 14 15:56 HISDB_2002805648_10_1_20220614.BKP
-rw-r--r-- 1 oracle oinstall 1114112 Jun 14 15:56 HISDB_2002805648_11_1_20220614.BKP
-rw-r--r-- 1 oracle oinstall 902 Jun 14 23:26 pfile0614.ora
[[email protected] data-bak]$ vi pfile0614.ora
参数文件的内容如下:
hisdb.__db_cache_size=1241513984
hisdb.__java_pool_size=16777216
hisdb.__large_pool_size=16777216
hisdb.__oracle_base='f:\app'#ORACLE_BASE set from environment
hisdb.__pga_aggregate_target=1358954496
hisdb.__sga_target=2013265920
hisdb.__shared_io_pool_size=0
hisdb.__shared_pool_size=671088640
hisdb.__streams_pool_size=33554432
# ====== 删除以上内容 =================================================================
#=====================================================================================
# 在两个节点同时创建目录:/u01/app/oracle/admin/hisdb/adump
*.audit_file_dest='/u01/app/oracle/admin/hisdb/adump'
# 删除下一行
# *.audit_trail='db'
# 修改版本号:11.2.0.4.0
*.compatible='11.2.0.4.0'
# *.control_files='f:\app\oradata\hisdb\control01.ctl','f:\app\flash_recovery_area\hisdb\control02.ctl'
*.control_files='+DATA/hisdb/controlfile/control01.ctl','+BAK/hisdb/controlfile/control02.ctl'
*.db_block_size=8192
# 删除下一行
# *.db_domain=''
*.db_name='hisdb'
# 在两个节点同时创建目录:/u01/app/oracle/flash_recovery_area
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4102029312
# 修改路径
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=hisdbXDB)'
*.memory_target=838588928
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
修改后的参数文件内容如下:
*.audit_file_dest='/u01/app/oracle/admin/hisdb/adump'
*.compatible='11.2.0.4.0'
*.control_files='+DATA/hisdb/controlfile/control01.ctl','+BAK/hisdb/controlfile/control02.ctl'
*.db_block_size=8192
*.db_name='hisdb'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4102029312
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=hisdbXDB)'
*.memory_target=638588928
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
3、使用 pfile 启动实例到 nomount
-- startup nomount pfile='/home/oracle/data-bak/pfile0614.ora';
SQL> startup nomount pfile='/home/oracle/data-bak/pfile0614.ora';
ORACLE instance started.
Total System Global Area 638853120 bytes
Fixed Size 2255952 bytes
Variable Size 452985776 bytes
Database Buffers 176160768 bytes
Redo Buffers 7450624 bytes
4、修改两个节点的 pfile 文件,加入 spfile 文件路径
# 节点1
# vi /u01/app/oracle/product/11.2.0/db_1/dbs/inithisdb1.ora
[[email protected] data-bak]$ vi /u01/app/oracle/product/11.2.0/db_1/dbs/inithisdb1.ora
SPFILE='+DATA/hisdb/spfilehisdb.ora'
# 节点2
# vi /u01/app/oracle/product/11.2.0/db_1/dbs/inithisdb2.ora
[[email protected] data-bak]$ vi /u01/app/oracle/product/11.2.0/db_1/dbs/inithisdb2.ora
SPFILE='+DATA/hisdb/spfilehisdb.ora'
5、根据 pfile 参数文件生成 spfile 参数文件,保存到 asm 磁盘
-- create spfile='+DATA/hisdb/spfilehisdb.ora' from pfile;
SQL> create spfile='+DATA/hisdb/spfilehisdb.ora' from pfile='/home/oracle/data-bak/pfile0614.ora';
File created.
6、关闭实例,使用 spfile 重新启动实例到 nomount
-- 关闭数据库
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
-- 启动实例到 弄mount
SQL> startup nomount
ORACLE instance started.
Total System Global Area 626327552 bytes
Fixed Size 2255832 bytes
Variable Size 297796648 bytes
Database Buffers 318767104 bytes
Redo Buffers 7507968 bytes
五、恢复控制文件,启动实例到 mount
-- 恢复控制文件
[oracle@rac1 data-bak]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jun 16 16:49:19 2022
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: HISDB (not mounted)
-- 恢复控制文件
RMAN> restore controlfile from '/home/oracle/data-bak/HISDB_2002805648_11_1_20220614.BKP';
Starting restore at 16-JUN-22
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=139 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
output file name=+DATA/hisdb/controlfile/control01.ctl
output file name=+BAK/hisdb/controlfile/control02.ctl
Finished restore at 16-JUN-22
-- 启动实例到 mount
SQL> alter database mount;
Database altered.
查看控制文件中的数据文件与临时文件信息:
RMAN> report schema;
released channel: ORA_DISK_1
Starting implicit crosscheck backup at 16-JUN-22
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=139 device type=DISK
Crosschecked 10 objects
Finished implicit crosscheck backup at 16-JUN-22
Starting implicit crosscheck copy at 16-JUN-22
using channel ORA_DISK_1
Finished implicit crosscheck copy at 16-JUN-22
searching for all files in the recovery area
cataloging files...
no files cataloged
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema for database with db_unique_name HISDB
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 0 SYSTEM *** F:\APP\ORADATA\HISDB\SYSTEM01.DBF
2 0 SYSAUX *** F:\APP\ORADATA\HISDB\SYSAUX01.DBF
3 0 UNDOTBS1 *** F:\APP\ORADATA\HISDB\UNDOTBS01.DBF
4 0 USERS *** F:\APP\ORADATA\HISDB\USERS01.DBF
5 0 TS001 *** F:\APP\ORADATA\HISDB\TS001.DBF
6 0 TS001 *** F:\APP\ORADATA\HISDB\TS002.DBF
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 F:\APP\ORADATA\HISDB\TEMP01.DBF
六、还原数据库
1、核对备份文件
CROSSCHECK 命令用于核对备份文件,以确保 RMAN 资料库与备份文件保持同步。当执行该命令时,如果 RMAN 资料库记录的状态与实际备份文件不匹配,则会更新资料库里的状态使其与实际备份文件状态一致;若备份文件处于 expired 状态,那么说明该备份已失效,可以删除。
RMAN> crosscheck backup;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\BAK_20211202\HISDB_20211202_030FNB1I_1_1_1.BAK RECID=1 STAMP=1090235448
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\BAK_20211202\HISDB_20211202_040FNB1O_1_1_1.BAK RECID=2 STAMP=1090235452
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\BAK_20211202\HISDB_20211202_020FNB1I_1_1_1.BAK RECID=3 STAMP=1090235442
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\BAK_20211202\HISDB_20211202_050FNB1R_1_1_1.BAK RECID=4 STAMP=1090235453
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\BAK_20211202\HISDB_20211202_070FNB1T_1_1_1.BAK RECID=5 STAMP=1090235455
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\BAK_20211202\HISDB_20211202_080FNB1V_1_1_1.BAK RECID=6 STAMP=1090235456
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\BAK_20211202\HISDB_20211202_060FNB1T_1_1_1.BAK RECID=7 STAMP=1090235456
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\BAK_20211202\HISDB_20211202_010FNB1H_1_1_1.BAK RECID=8 STAMP=1090235442
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=D:\BAK_20211202\CTL_HISDB_20211202_1090235463_9_1 RECID=9 STAMP=1090235465
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=F:\RMAN_BAK\HISDB_2002805648_10_1_20220614.BKP RECID=10 STAMP=1107359781
Crosschecked 10 objects
2、删除失效的备份文件
RMAN> delete expired backup;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
1 1 1 1 EXPIRED DISK D:\BAK_20211202\HISDB_20211202_030FNB1I_1_1_1.BAK
2 2 1 1 EXPIRED DISK D:\BAK_20211202\HISDB_20211202_040FNB1O_1_1_1.BAK
3 3 1 1 EXPIRED DISK D:\BAK_20211202\HISDB_20211202_020FNB1I_1_1_1.BAK
4 4 1 1 EXPIRED DISK D:\BAK_20211202\HISDB_20211202_050FNB1R_1_1_1.BAK
5 5 1 1 EXPIRED DISK D:\BAK_20211202\HISDB_20211202_070FNB1T_1_1_1.BAK
6 6 1 1 EXPIRED DISK D:\BAK_20211202\HISDB_20211202_080FNB1V_1_1_1.BAK
7 7 1 1 EXPIRED DISK D:\BAK_20211202\HISDB_20211202_060FNB1T_1_1_1.BAK
8 8 1 1 EXPIRED DISK D:\BAK_20211202\HISDB_20211202_010FNB1H_1_1_1.BAK
9 9 1 1 EXPIRED DISK D:\BAK_20211202\CTL_HISDB_20211202_1090235463_9_1
10 10 1 1 EXPIRED DISK F:\RMAN_BAK\HISDB_2002805648_10_1_20220614.BKP
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=D:\BAK_20211202\HISDB_20211202_030FNB1I_1_1_1.BAK RECID=1 STAMP=1090235448
deleted backup piece
backup piece handle=D:\BAK_20211202\HISDB_20211202_040FNB1O_1_1_1.BAK RECID=2 STAMP=1090235452
deleted backup piece
backup piece handle=D:\BAK_20211202\HISDB_20211202_020FNB1I_1_1_1.BAK RECID=3 STAMP=1090235442
deleted backup piece
backup piece handle=D:\BAK_20211202\HISDB_20211202_050FNB1R_1_1_1.BAK RECID=4 STAMP=1090235453
deleted backup piece
backup piece handle=D:\BAK_20211202\HISDB_20211202_070FNB1T_1_1_1.BAK RECID=5 STAMP=1090235455
deleted backup piece
backup piece handle=D:\BAK_20211202\HISDB_20211202_080FNB1V_1_1_1.BAK RECID=6 STAMP=1090235456
deleted backup piece
backup piece handle=D:\BAK_20211202\HISDB_20211202_060FNB1T_1_1_1.BAK RECID=7 STAMP=1090235456
deleted backup piece
backup piece handle=D:\BAK_20211202\HISDB_20211202_010FNB1H_1_1_1.BAK RECID=8 STAMP=1090235442
deleted backup piece
backup piece handle=D:\BAK_20211202\CTL_HISDB_20211202_1090235463_9_1 RECID=9 STAMP=1090235465
deleted backup piece
backup piece handle=F:\RMAN_BAK\HISDB_2002805648_10_1_20220614.BKP RECID=10 STAMP=1107359781
Deleted 10 EXPIRED objects
3、更新备份文件
--catalog start with '/home/oracle/data-bak/'; -- 注意此处的目录
RMAN> catalog start with '/home/oracle/data-bak/';
searching for all files that match the pattern /home/oracle/data-bak/
List of Files Unknown to the Database
=====================================
File Name: /home/oracle/data-bak/HISDB_2002805648_10_1_20220614.BKP
File Name: /home/oracle/data-bak/HISDB_2002805648_11_1_20220614.BKP
File Name: /home/oracle/data-bak/pfile0614.ora
File Name: /home/oracle/data-bak/pfilehisdb.ora
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/oracle/data-bak/HISDB_2002805648_10_1_20220614.BKP
File Name: /home/oracle/data-bak/HISDB_2002805648_11_1_20220614.BKP
List of Files Which Where Not Cataloged
=======================================
File Name: /home/oracle/data-bak/pfile0614.ora
RMAN-07517: Reason: The file header is corrupted
File Name: /home/oracle/data-bak/pfilehisdb.ora
RMAN-07517: Reason: The file header is corrupted
4、查看备份片信息
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
11 Full 290.51M DISK 00:00:00 14-JUN-22
BP Key: 11 Status: AVAILABLE Compressed: YES Tag: TAG20220614T155620
Piece Name: /home/oracle/data-bak/HISDB_2002805648_10_1_20220614.BKP
List of Datafiles in backup set 11
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 8146403 14-JUN-22 F:\APP\ORADATA\HISDB\SYSTEM01.DBF
2 Full 8146403 14-JUN-22 F:\APP\ORADATA\HISDB\SYSAUX01.DBF
3 Full 8146403 14-JUN-22 F:\APP\ORADATA\HISDB\UNDOTBS01.DBF
4 Full 8146403 14-JUN-22 F:\APP\ORADATA\HISDB\USERS01.DBF
5 Full 8146403 14-JUN-22 F:\APP\ORADATA\HISDB\TS001.DBF
6 Full 8146403 14-JUN-22 F:\APP\ORADATA\HISDB\TS002.DBF
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
12 Full 1.05M DISK 00:00:00 14-JUN-22
BP Key: 12 Status: AVAILABLE Compressed: YES Tag: TAG20220614T155620
Piece Name: /home/oracle/data-bak/HISDB_2002805648_11_1_20220614.BKP
SPFILE Included: Modification time: 14-JUN-22
SPFILE db_unique_name: HISDB
Control File Included: Ckp SCN: 8146403 Ckp time: 14-JUN-22
5、恢复数据库
------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
run{
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/';
set newname for datafile 5 to '+data/';
set newname for datafile 6 to '+data/';
set newname for tempfile 1 to '+data/';
restore database;
switch datafile all;
switch tempfile all;
}
------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
RMAN>
run{
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/';
set newname for datafile 5 to '+data/';
set newname for tempfile 1 to '+data/';
restore database;
switch datafile all;
switch tempfile all;
11> }
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 16-JUN-22
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to +data/
channel ORA_DISK_1: restoring datafile 00002 to +data/
channel ORA_DISK_1: restoring datafile 00003 to +data/
channel ORA_DISK_1: restoring datafile 00004 to +data/
channel ORA_DISK_1: restoring datafile 00005 to +data/
channel ORA_DISK_1: restoring datafile 00006 to F:\APP\ORADATA\HISDB\TS002.DBF
channel ORA_DISK_1: reading from backup piece /home/oracle/data-bak/HISDB_2002805648_10_1_20220614.BKP
channel ORA_DISK_1: piece handle=/home/oracle/data-bak/HISDB_2002805648_10_1_20220614.BKP tag=TAG20220614T155620
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 16-JUN-22
datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=1107536313 file name=+DATA/hisdb/datafile/system.281.1107536257
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=1107536313 file name=+DATA/hisdb/datafile/sysaux.282.1107536257
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=1107536314 file name=+DATA/hisdb/datafile/undotbs1.283.1107536257
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=1107536315 file name=+DATA/hisdb/datafile/users.285.1107536259
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=1107536315 file name=+DATA/hisdb/datafile/ts001.284.1107536259
renamed tempfile 1 to +data/ in control file
七、启动数据库
SQL> alter database open resetlogs upgrade;
Database altered.
编译无效对象:
SQL> @?/rdbms/admin/utlrp.sql
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2022-06-15 21:32:50
DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC> objects in the database. Recompilation time is proportional to the
DOC> number of invalid objects in the database, so this command may take
DOC> a long time to execute on a database with a large number of invalid
DOC> objects.
DOC>
DOC> Use the following queries to track recompilation progress:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
DECLARE
*
ERROR at line 1:
ORA-04063: package body "SYS.DBMS_SQLTUNE" has errors
ORA-06508: PL/SQL: could not find program unit being called: "SYS.DBMS_SQLTUNE"
ORA-06512: at "SYS.UTL_RECOMP", line 783
ORA-06512: at line 4
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2022-06-15 21:32:59
DOC> The following query reports the number of objects that have compiled
DOC> with errors.
DOC>
DOC> If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
OBJECTS WITH ERRORS
-------------------
0
DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#
ERRORS DURING RECOMPILATION
---------------------------
0
Function created.
PL/SQL procedure successfully completed.
Function dropped.
PL/SQL procedure successfully completed.
八、修改日志文件信息
1、查看日志文件信息
SQL> col member for a40
SQL> select GROUP#, STATUS, TYPE, MEMBER from v$logfile;
GROUP# STATUS TYPE MEMBER
---------- ------- ------- ----------------------------------------
3 ONLINE F:\APP\ORADATA\HISDB\REDO03.LOG
2 ONLINE F:\APP\ORADATA\HISDB\REDO02.LOG
1 ONLINE F:\APP\ORADATA\HISDB\REDO01.LOG
2、添加日志组和日志文件
-- 用于指定 Oracle 数据库服务器创建数据文件的缺省路径
SQL> alter system set db_create_file_dest='+DATA';
System altered.
-- 提前创建目录:/usr/local/oradata/hisdb_bak/
alter database add logfile group 5 '+data/hisdb/onlinelog/redo05a.log' size 50m;
alter database add logfile group 6 '+data/hisdb/onlinelog/redo06a.log' size 50m;
alter database add logfile group 7 '+data/hisdb/onlinelog/redo07a.log' size 50m;
3、查看日志文件信息
SQL> select GROUP#, STATUS, TYPE, MEMBER from v$logfile;
GROUP# STATUS TYPE MEMBER
---------- ------- ------- ----------------------------------------
3 ONLINE F:\APP\ORADATA\HISDB\REDO03.LOG
2 ONLINE F:\APP\ORADATA\HISDB\REDO02.LOG
1 ONLINE F:\APP\ORADATA\HISDB\REDO01.LOG
5 ONLINE /usr/local/oradata/hisdb/redo05a.log
6 ONLINE /usr/local/oradata/hisdb/redo06a.log
7 ONLINE /usr/local/oradata/hisdb/redo07a.log
5 INVALID ONLINE /usr/local/oradata/hisdb_bak/redo05b.log
6 INVALID ONLINE /usr/local/oradata/hisdb_bak/redo06b.log
7 INVALID ONLINE /usr/local/oradata/hisdb_bak/redo07b.log
9 rows selected.
SQL> select GROUP#,SEQUENCE#,BYTES,MEMBERS,STATUS from v$log;
GROUP# SEQUENCE# BYTES MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1 340 52428800 1 INACTIVE
2 341 52428800 1 INACTIVE
7 0 314572800 2 UNUSED
5 0 314572800 2 UNUSED
6 0 314572800 2 UNUSED
3 342 52428800 1 CURRENT
6 rows selected.
4、删除失效的日志组
(1)切换日志
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> select GROUP#,SEQUENCE#,BYTES,MEMBERS,STATUS from v$log;
GROUP# SEQUENCE# BYTES MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1 1 52428800 1 INACTIVE
2 2 52428800 1 ACTIVE
3 3 52428800 1 ACTIVE
5 4 314572800 2 CURRENT --当前日志组为 4
6 0 314572800 2 UNUSED
7 0 314572800 2 UNUSED
6 rows selected.
(2)打检查点
SQL> alter system checkpoint;
System altered.
SQL> select GROUP#,SEQUENCE#,BYTES,MEMBERS,STATUS from v$log;
GROUP# SEQUENCE# BYTES MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
1 1 52428800 1 INACTIVE -- 日志组1 变为非活动状态(INACTIVE)
2 2 52428800 1 INACTIVE -- 日志组2 变为非活动状态(INACTIVE)
3 3 52428800 1 INACTIVE -- 日志组3 变为非活动状态(INACTIVE)
5 4 314572800 2 CURRENT
6 0 314572800 2 UNUSED
7 0 314572800 2 UNUSED
6 rows selected.
(3)删除日志组:1、2、3
SQL> alter database drop logfile group 1;
alter database drop logfile group 2;
alter database drop logfile group 3;
Database altered.
(4)查看日志组信息
SQL> select GROUP#,SEQUENCE#,BYTES,MEMBERS,STATUS from v$log;
GROUP# SEQUENCE# BYTES MEMBERS STATUS
---------- ---------- ---------- ---------- ----------------
5 4 314572800 2 CURRENT
6 0 314572800 2 UNUSED
7 0 314572800 2 UNUSED
SQL> select GROUP#, STATUS, TYPE, MEMBER from v$logfile;
GROUP# STATUS TYPE MEMBER
---------- ------- ------- ----------------------------------------
5 ONLINE /usr/local/oradata/hisdb/redo05a.log
6 ONLINE /usr/local/oradata/hisdb/redo06a.log
7 ONLINE /usr/local/oradata/hisdb/redo07a.log
5 ONLINE /usr/local/oradata/hisdb_bak/redo05b.log
6 ONLINE /usr/local/oradata/hisdb_bak/redo06b.log
7 ONLINE /usr/local/oradata/hisdb_bak/redo07b.log
6 rows selected.
九、升级数据字典
1、通过 startup upgrade 启动实例
-- 停库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
-- 启动数据库
SQL> startup upgrade;
ORACLE instance started.
Total System Global Area 659730432 bytes
Fixed Size 2256152 bytes
Variable Size 444596968 bytes
Database Buffers 209715200 bytes
Redo Buffers 3162112 bytes
Database mounted.
Database opened.
2、升级数据字典
SQL> @$ORACLE_HOME/rdbms/admin/catupgrd.sql
十、重启实例
-- 停库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
-- 启动实例
SQL> startup
ORACLE instance started.
Total System Global Area 659730432 bytes
Fixed Size 2256152 bytes
Variable Size 457179880 bytes
Database Buffers 192937984 bytes
Redo Buffers 7356416 bytes
Database mounted.
Database opened.
再次编译无效的应用对象:
@?/rdbms/admin/utlrp.sql
边栏推荐
猜你喜欢

Exploring the mystery of C language program -- C language program compilation and preprocessing

非凸联合创始人李佐凡:将量化作为自己的终身事业

当他们在私域里,掌握了分寸感

ProcessOn制作ER过程(自定义)

DDD概念复杂难懂,实际落地如何设计代码实现模型?

Sumati GameFi生态纵览,神奇世界中的元素设计

TSDB在民机行业中的应用

Sumati gamefi ecological overview, element design in the magical world

Redis

Redis 那些事
随机推荐
Beescms website penetration test and repair comments "suggestions collection"
Android Internet of things application development (smart Park) - set sensor threshold dialog interface
Software testing salary in first tier cities - are you dragging your feet
Left hand dreams right hand responsibilities GAC Honda not only pays attention to sales but also children's safety
[mobile terminal] design size of mobile phone interface
FTP协议讲解
Android物联网应用程序开发(智慧园区)—— 设置传感器阈值对话框界面
【STL源码剖析】配置器(待补充)
困牛排序(寒假每日一题 40)
Chinese address and English address
write a number of lines to a new file in vim
TSDB在民机行业中的应用
DDD concept is complex and difficult to understand. How to design code implementation model in practice?
centos7.3修改mysql默认密码_详解Centos7 修改mysql指定用户的密码
如何通过EasyCVR接口监测日志观察平台拉流情况?
实战攻防演练中的四大特点
中文地址与英文地址
How to get the picture outside the chain - Netease photo album [easy to understand]
Resolution of cross reference in IDA
当人们用互联网式的思维和视角来看待产业互联网的时候,其实已陷入到了死胡同