暂无图片
暂无图片
3
暂无图片
暂无图片
暂无图片

使用dg备库备份集进行不完全恢复

原创 _ 云和恩墨 2022-04-11
2229

一、测试环境准备

172.16.220.10 主库
172.16.220.20 备库
172.16.220.30 测试库
SQL> select open_mode,protection_mode,database_role from v$database;
READ ONLY WITH APPLY                     MAXIMUM AVAILABILITY                     PHYSICAL STANDBY
SQL> select process,status,group#,thread#,sequence#,block#,blocks from v$managed_standby;
ARCH               CLOSING                  6                                       1         95     108544       1731
DGRD               ALLOCATED                N/A                                     0          0          0          0
DGRD               ALLOCATED                N/A                                     0          0          0          0
ARCH               CLOSING                  5                                       1         94          1        184
ARCH               CLOSING                  4                                       1         93          1          4
ARCH               CLOSING                  4                                       1         96          1          9
MRP0               APPLYING_LOG             N/A                                     1         97       2051     409600
RFS                IDLE                     N/A                                     1          0          0          0
RFS                IDLE                     1                                       1         97       2051          1
RFS                IDLE                     N/A                                     0          0          0          0
RFS                IDLE                     N/A                                     0          0          0          0
RFS                IDLE                     N/A                                     0          0          0          0
------------------------------------------------------------------------------------------------------------------------------------

二、主库创建数据

conn scott/tiger
scott@orcl> create table t as select * from dba_objects;

Table created.

scott@orcl> insert into t select * from t;

72641 rows created.

scott@orcl> / --多执行几次

scott@orcl> select count(*) from t;

  COUNT(*)
----------
   2324512

备库查看

SQL> select count(*) from scott.t;
     72641
SQL> select count(*) from scott.t; --过一会同步过来了
  COUNT(*)
----------
   2324512 

三、共享存储设备准备 172.16.220.20 备库 172.16.220.30 测试库配置共享磁盘

[root@19c02 ~]# yum install iscsi-initiator-utils -y
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
file:///mnt/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /mnt/repodata/repomd.xml"
正在尝试其它镜像。
软件包 iscsi-initiator-utils-6.2.0.874-10.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@19c02 ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:4a041e71a4a
[root@19c02 ~]# echo "options=--whitelisted --replace-whitespace" > /etc/scsi_id.config
[root@19c02 ~]# cat /etc/iscsi/initiatorname.iscsi                                     
InitiatorName=iqn.1994-05.com.redhat:4a041e71a4a
[root@19c02 ~]# cat /etc/scsi_id.config
options=--whitelisted --replace-whitespace
[root@19c02 ~]# systemctl enable iscsi
[root@19c02 ~]# systemctl start iscsi
[root@19c02 ~]# iscsiadm -m discovery -t st -p 172.16.220.100:3260    --访问iscsi 提示无法发现                               
iscsiadm: No portals found  
[root@openfiler etc]# vi initiators.deny  --注释掉这个就行
# PLEASE DO NOT MODIFY THIS CONFIGURATION FILE!
#       This configuration file was autogenerated
#       by Openfiler. Any manual changes will be overwritten
#       Generated at: Sun Feb 13 13:41:14 EST 2022

#iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17 ALL
# End of Openfiler configuration
[root@19c02 ~]# iscsiadm -m discovery -t st -p 172.16.220.100:3260  --发现四条路径
172.16.220.100:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.101:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.102:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.103:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
[root@19c02 ~]# iscsiadm -m discovery -t st -p 172.16.220.101:3260
172.16.220.101:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.100:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.102:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.103:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
[root@19c02 ~]# iscsiadm -m discovery -t st -p 172.16.220.102:3260
iscsiadm -m discovery -t st -p 172.16.220.103:3260172.16.220.102:3260,
172.16.220.100:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.100:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.101:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.103:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
[root@19c02 ~]# iscsiadm -m discovery -t st -p 172.16.220.103:3260
172.16.220.103:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.100:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.101:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.102:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17

登录

[root@19c02 ~]# iscsiadm -m node -T iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17 -p 172.16.220.100:3260  --日志太多 只记录一条登录日志
# BEGIN RECORD 6.2.0.874-10
node.name = iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
node.tpgt = 1
node.startup = automatic
node.leading_login = No
iface.hwaddress = <empty>
iface.ipaddress = <empty>
iface.iscsi_ifacename = default
iface.net_ifacename = <empty>
iface.gateway = <empty>
iface.subnet_mask = <empty>
iface.transport_name = tcp
iface.initiatorname = <empty>
iface.state = <empty>
iface.vlan_id = 0
iface.vlan_priority = 0
iface.vlan_state = <empty>
iface.iface_num = 0
iface.mtu = 0
iface.port = 0
iface.bootproto = <empty>
iface.dhcp_alt_client_id_state = <empty>
iface.dhcp_alt_client_id = <empty>
iface.dhcp_dns = <empty>
iface.dhcp_learn_iqn = <empty>
iface.dhcp_req_vendor_id_state = <empty>
iface.dhcp_vendor_id_state = <empty>
iface.dhcp_vendor_id = <empty>
iface.dhcp_slp_da = <empty>
iface.fragmentation = <empty>
iface.gratuitous_arp = <empty>
iface.incoming_forwarding = <empty>
iface.tos_state = <empty>
iface.tos = 0
iface.ttl = 0
iface.delayed_ack = <empty>
iface.tcp_nagle = <empty>
iface.tcp_wsf_state = <empty>
iface.tcp_wsf = 0
iface.tcp_timer_scale = 0
iface.tcp_timestamp = <empty>
iface.redirect = <empty>
iface.def_task_mgmt_timeout = 0
iface.header_digest = <empty>
iface.data_digest = <empty>
iface.immediate_data = <empty>
iface.initial_r2t = <empty>
iface.data_seq_inorder = <empty>
iface.data_pdu_inorder = <empty>
iface.erl = 0
iface.max_receive_data_len = 0
iface.first_burst_len = 0
iface.max_outstanding_r2t = 0
iface.max_burst_len = 0
iface.chap_auth = <empty>
iface.bidi_chap = <empty>
iface.strict_login_compliance = <empty>
iface.discovery_auth = <empty>
iface.discovery_logout = <empty>
node.discovery_address = 172.16.220.103
node.discovery_port = 3260
node.discovery_type = send_targets
node.session.initial_cmdsn = 0
node.session.initial_login_retry_max = 8
node.session.xmit_thread_priority = -20
node.session.cmds_max = 128
node.session.queue_depth = 32
node.session.nr_sessions = 1
node.session.auth.authmethod = None
node.session.auth.username = <empty>
node.session.auth.password = <empty>
node.session.auth.username_in = <empty>
node.session.auth.password_in = <empty>
node.session.timeo.replacement_timeout = 120
node.session.err_timeo.abort_timeout = 15
node.session.err_timeo.lu_reset_timeout = 30
node.session.err_timeo.tgt_reset_timeout = 30
node.session.err_timeo.host_reset_timeout = 60
node.session.iscsi.FastAbort = Yes
node.session.iscsi.InitialR2T = No
node.session.iscsi.ImmediateData = Yes
node.session.iscsi.FirstBurstLength = 262144
node.session.iscsi.MaxBurstLength = 16776192
node.session.iscsi.DefaultTime2Retain = 0
node.session.iscsi.DefaultTime2Wait = 2
node.session.iscsi.MaxConnections = 1
node.session.iscsi.MaxOutstandingR2T = 1
node.session.iscsi.ERL = 0
node.session.scan = auto
node.conn[0].address = 172.16.220.100
node.conn[0].port = 3260
node.conn[0].startup = manual
node.conn[0].tcp.window_size = 524288
node.conn[0].tcp.type_of_service = 0
node.conn[0].timeo.logout_timeout = 15
node.conn[0].timeo.login_timeout = 15
node.conn[0].timeo.auth_timeout = 45
node.conn[0].timeo.noop_out_interval = 5
node.conn[0].timeo.noop_out_timeout = 5
node.conn[0].iscsi.MaxXmitDataSegmentLength = 0
node.conn[0].iscsi.MaxRecvDataSegmentLength = 262144
node.conn[0].iscsi.HeaderDigest = None
node.conn[0].iscsi.IFMarker = No
node.conn[0].iscsi.OFMarker = No
# END RECORD
[root@19c02 ~]# iscsiadm -m node 
172.16.220.103:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.100:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.101:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
172.16.220.102:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17
[root@19c02 ~]# iscsiadm -m session
tcp: [1] 172.16.220.103:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17 (non-flash)
tcp: [2] 172.16.220.100:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17 (non-flash)
tcp: [3] 172.16.220.101:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17 (non-flash)
tcp: [4] 172.16.220.102:3260,1 iqn.2006-01.com.openfiler:tsn.b5ef9cc99a17 (non-flash)
4.1、配置多路径
[root@19c02 ~]# rpm -qa|grep multipath
device-mapper-multipath-libs-0.4.9-123.el7.x86_64
device-mapper-multipath-0.4.9-123.el7.x86_64
[root@19c02 ~]# modprobe dm-multipath
[root@19c02 ~]# modprobe dm-round-robin
[root@19c02 ~]# lsmod |grep dm_multipath
dm_multipath           27792  1 dm_round_robin
dm_mod                124407  3 dm_multipath,dm_log,dm_mirror
[root@19c02 ~]# systemctl enable multipathd
[root@19c02 ~]# systemctl start multipathd

[root@19c02 ~]# multipath -v2
Feb 13 13:54:58 | /etc/multipath.conf does not exist, blacklisting all devices.
Feb 13 13:54:58 | A default multipath.conf file is located at
Feb 13 13:54:58 | /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf
Feb 13 13:54:58 | You can run /sbin/mpathconf --enable to create
Feb 13 13:54:58 | /etc/multipath.conf. See man mpathconf(8) for more details

[root@19c02 ~]# cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/multipath.conf
[root@19c02 ~]# for i in `cat /proc/partitions | awk '{print$4}' |grep sd | grep [a-z]$`; do
> echo "### $i: `/lib/udev/scsi_id --whitelisted --device=/dev/$i`"; done
### sda: 36000c293cd0a6b0298cbc2221e0bc7d5 --注意 需要在虚拟机配置文件中加入disk.EnableUUID="TRUE",否则看不到uuid
### sdb: 36000c2998f10cbfcf0e87502a6d13ba6
### sdc: 14f504e46494c45526130735964652d736d70432d37725244
### sdd: 14f504e46494c45526130735964652d736d70432d37725244
### sde: 14f504e46494c45526130735964652d736d70432d37725244
### sdf: 14f504e46494c45526332505577682d73596d632d304a7a50
### sdg: 14f504e46494c45526332505577682d73596d632d304a7a50
### sdh: 14f504e46494c4552706354586b572d674a6d672d42436c69
### sdi: 14f504e46494c45526332505577682d73596d632d304a7a50
### sdj: 14f504e46494c4552706354586b572d674a6d672d42436c69
### sdk: 14f504e46494c4552706354586b572d674a6d672d42436c69
### sdl: 14f504e46494c45526130735964652d736d70432d37725244
### sdm: 14f504e46494c45526332505577682d73596d632d304a7a50
### sdn: 14f504e46494c4552706354586b572d674a6d672d42436c69
[root@19c02 ~]# iscsiadm -m session -P 3 |grep "Attached"
                Attached SCSI devices:
                        Attached scsi disk sdc          State: running
                        Attached scsi disk sdf          State: running
                        Attached scsi disk sdh          State: running
                Attached SCSI devices:
                        Attached scsi disk sde          State: running
                        Attached scsi disk sdi          State: running
                        Attached scsi disk sdk          State: running
                Attached SCSI devices:
                        Attached scsi disk sdd          State: running
                        Attached scsi disk sdg          State: running
                        Attached scsi disk sdj          State: running
                Attached SCSI devices:
                        Attached scsi disk sdl          State: running
                        Attached scsi disk sdm          State: running
                        Attached scsi disk sdn          State: running
[root@19c02 ~]# fdisk -l|grep "/dev/sd"
磁盘 /dev/sda:85.9 GB, 85899345920 字节,167772160 个扇区
/dev/sda1            2048    16779263     8388608   82  Linux swap / Solaris
/dev/sda2   *    16779264   167772159    75496448   83  Linux
磁盘 /dev/sdb:107.4 GB, 107374182400 字节,209715200 个扇区
磁盘 /dev/sdc:21.5 GB, 21474836480 字节,41943040 个扇区
磁盘 /dev/sdd:21.5 GB, 21474836480 字节,41943040 个扇区
磁盘 /dev/sde:21.5 GB, 21474836480 字节,41943040 个扇区
磁盘 /dev/sdf:42.9 GB, 42949672960 字节,83886080 个扇区
磁盘 /dev/sdg:42.9 GB, 42949672960 字节,83886080 个扇区
磁盘 /dev/sdh:21.5 GB, 21474836480 字节,41943040 个扇区
磁盘 /dev/sdi:42.9 GB, 42949672960 字节,83886080 个扇区
磁盘 /dev/sdj:21.5 GB, 21474836480 字节,41943040 个扇区
磁盘 /dev/sdk:21.5 GB, 21474836480 字节,41943040 个扇区
磁盘 /dev/sdl:21.5 GB, 21474836480 字节,41943040 个扇区
磁盘 /dev/sdm:42.9 GB, 42949672960 字节,83886080 个扇区
磁盘 /dev/sdn:21.5 GB, 21474836480 字节,41943040 个扇区
[root@19c02 ~]# ls -l /dev/disk/by-id
总用量 0
lrwxrwxrwx 1 root root  9 2月  13 22:00 ata-VMware_Virtual_SATA_CDRW_Drive_01000000000000000001 -> ../../sr0
lrwxrwxrwx 1 root root 10 2月  13 22:00 dm-name-mpatha -> ../../dm-0
lrwxrwxrwx 1 root root 10 2月  13 22:00 dm-name-mpathb -> ../../dm-1
lrwxrwxrwx 1 root root 10 2月  13 22:00 dm-name-mpathc -> ../../dm-2
lrwxrwxrwx 1 root root 10 2月  13 22:00 dm-uuid-mpath-14f504e46494c45526130735964652d736d70432d37725244 -> ../../dm-0
lrwxrwxrwx 1 root root 10 2月  13 22:00 dm-uuid-mpath-14f504e46494c45526332505577682d73596d632d304a7a50 -> ../../dm-1
lrwxrwxrwx 1 root root 10 2月  13 22:00 dm-uuid-mpath-14f504e46494c4552706354586b572d674a6d672d42436c69 -> ../../dm-2
lrwxrwxrwx 1 root root  9 2月  13 22:00 scsi-14f504e46494c45526130735964652d736d70432d37725244 -> ../../sdc
lrwxrwxrwx 1 root root  9 2月  13 22:00 scsi-14f504e46494c45526332505577682d73596d632d304a7a50 -> ../../sdf
lrwxrwxrwx 1 root root  9 2月  13 22:00 scsi-14f504e46494c4552706354586b572d674a6d672d42436c69 -> ../../sdh
lrwxrwxrwx 1 root root  9 2月  13 22:00 scsi-36000c293cd0a6b0298cbc2221e0bc7d5 -> ../../sda
lrwxrwxrwx 1 root root 10 2月  13 22:00 scsi-36000c293cd0a6b0298cbc2221e0bc7d5-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 2月  13 22:00 scsi-36000c293cd0a6b0298cbc2221e0bc7d5-part2 -> ../../sda2
lrwxrwxrwx 1 root root  9 2月  13 22:00 scsi-36000c2998f10cbfcf0e87502a6d13ba6 -> ../../sdb
lrwxrwxrwx 1 root root  9 2月  13 22:00 wwn-0x6000c293cd0a6b0298cbc2221e0bc7d5 -> ../../sda
lrwxrwxrwx 1 root root 10 2月  13 22:00 wwn-0x6000c293cd0a6b0298cbc2221e0bc7d5-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 2月  13 22:00 wwn-0x6000c293cd0a6b0298cbc2221e0bc7d5-part2 -> ../../sda2
lrwxrwxrwx 1 root root  9 2月  13 22:00 wwn-0x6000c2998f10cbfcf0e87502a6d13ba6 -> ../../sdb

[root@19c02 ~]# multipath -ll|grep mpath
mpathc (14f504e46494c4552706354586b572d674a6d672d42436c69) dm-2 OPNFILER,VIRTUAL-DISK    
mpathb (14f504e46494c45526332505577682d73596d632d304a7a50) dm-1 OPNFILER,VIRTUAL-DISK    
mpatha (14f504e46494c45526130735964652d736d70432d37725244) dm-0 OPNFILER,VIRTUAL-DISK
4.2、多路径聚合
[root@19c02 ~]# vim /etc/multipath.conf
blacklist {
       wwid 36000c293cd0a6b0298cbc2221e0bc7d5
       wwid 36000c2998f10cbfcf0e87502a6d13ba6
}
defaults {
	path_selector		"round-robin 0"
	path_grouping_policy	multibus
	rr_min_io		100
	max_fds			8192
	rr_weight		priorities
	failback		immediate
	no_path_retry		fail
	user_friendly_names	yes
	find_multipaths yes
}
multipaths {
	multipath {
		wwid			14f504e46494c45526130735964652d736d70432d37725244
		alias			disk20g01
	}
	multipath {
		wwid			14f504e46494c45526332505577682d73596d632d304a7a50
		alias			disk40g
	}
	multipath {
		wwid			14f504e46494c4552706354586b572d674a6d672d42436c69
		alias			disk20g02
	}	
}
						
[root@19c02 ~]# multipath -F
[root@19c02 ~]# systemctl stop multipathd
[root@19c02 ~]# systemctl start multipathd
[root@19c02 ~]# multipath -v2
[root@19c02 ~]# multipath -ll
disk40g (14f504e46494c45526332505577682d73596d632d304a7a50) dm-1 OPNFILER,VIRTUAL-DISK    
size=40G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
  |- 33:0:0:1 sdf 8:80  active ready running
  |- 34:0:0:1 sdi 8:128 active ready running
  |- 35:0:0:1 sdg 8:96  active ready running
  `- 36:0:0:1 sdm 8:192 active ready running
disk20g02 (14f504e46494c4552706354586b572d674a6d672d42436c69) dm-2 OPNFILER,VIRTUAL-DISK    
size=20G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
  |- 33:0:0:2 sdh 8:112 active ready running
  |- 34:0:0:2 sdk 8:160 active ready running
  |- 35:0:0:2 sdj 8:144 active ready running
  `- 36:0:0:2 sdn 8:208 active ready running
disk20g01 (14f504e46494c45526130735964652d736d70432d37725244) dm-0 OPNFILER,VIRTUAL-DISK    
size=20G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
  |- 33:0:0:0 sdc 8:32  active ready running
  |- 34:0:0:0 sde 8:64  active ready running
  |- 35:0:0:0 sdd 8:48  active ready running
  `- 36:0:0:0 sdl 8:176 active ready running
[root@19c02 ~]# 
[root@19c02 ~]# dmsetup ls|grep disk                
disk40g (253:1)
disk20g02       (253:2)
disk20g01       (253:0)
4.3、传输盘设置
ls -lsa /dev/mapper/*
[root@19c02 mapper]# ls -lsa /dev/mapper/*
0 crw------- 1 root root 10, 236 2月  13 22:00 /dev/mapper/control
0 lrwxrwxrwx 1 root root       7 2月  13 22:12 /dev/mapper/disk20g01 -> ../dm-0
0 lrwxrwxrwx 1 root root       7 2月  13 22:12 /dev/mapper/disk20g02 -> ../dm-2
0 lrwxrwxrwx 1 root root       7 2月  13 22:12 /dev/mapper/disk40g -> ../dm-1
4.4、逻辑卷配置 --只能在一个节点配置
[root@19c02 mapper]# pvcreate /dev/mapper/disk40g
  Physical volume "/dev/mapper/disk40g" successfully created.
[root@19c02 mapper]# vgcreate backupvg /dev/mapper/disk40g
  Volume group "backupvg" successfully created
[root@19c02 mapper]# lvcreate -n backuplv -L 35G backupvg
  Logical volume "backuplv" created.
 
[root@19c02 backupvg]# mkfs.xfs /dev/backupvg/backuplv
meta-data=/dev/backupvg/backuplv isize=512    agcount=4, agsize=2293760 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=9175040, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=4480, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

 [root@19c02 ~]# mkdir /backup
[root@19c02 ~]# mount /dev/backupvg/backuplv /backup

[root@19c02 ~]# vi /etc/fstab --注释进去,非必要不启用自动挂载
# /dev/backupvg/backuplv /backup xfs defaults 0 0
4.4、备份
oracle@19c02:/backup]$rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Feb 13 23:46:32 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1616795247)

RMAN> run
2> {
3> allocate channel c1 type disk;
4> allocate channel c2 type disk;
5> backup as compressed backupset  database format '/backup/FULL_%d_%U.bak';
6> backup as compressed backupset archivelog all format '/backup/ARC_%d_%U.arc';
7> backup current controlfile  format '/backup/control_%U.ctl';
8> backup spfile format '/backup/spfile_%d_%U.ora';
9> release channel c1;
10> release channel c2;
11> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=201 device type=DISK

allocated channel: c2
channel c2: SID=20 device type=DISK

Starting backup at 2022-02-13 23:46:38
channel c1: starting compressed full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/ORCL/users01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ORCL/undotbs01.dbf
channel c1: starting piece 1 at 2022-02-13 23:46:38
channel c2: starting compressed full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/ORCL/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/ORCL/sysaux01.dbf
channel c2: starting piece 1 at 2022-02-13 23:46:38
channel c1: finished piece 1 at 2022-02-13 23:47:03
piece handle=/backup/FULL_ORCL_3v0lp6mu_1_1.bak tag=TAG20220213T234638 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:25
channel c2: finished piece 1 at 2022-02-13 23:47:23
piece handle=/backup/FULL_ORCL_400lp6mu_1_1.bak tag=TAG20220213T234638 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:45
Finished backup at 2022-02-13 23:47:23

Starting backup at 2022-02-13 23:47:23
RMAN-06820: warning: failed to archive current log at primary database
cannot connect to remote database
channel c1: starting compressed archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=90 RECID=18 STAMP=1096532660
input archived log thread=1 sequence=91 RECID=19 STAMP=1096538106
input archived log thread=1 sequence=92 RECID=20 STAMP=1096538108
input archived log thread=1 sequence=93 RECID=21 STAMP=1096538110
input archived log thread=1 sequence=94 RECID=23 STAMP=1096546823
input archived log thread=1 sequence=95 RECID=22 STAMP=1096546822
input archived log thread=1 sequence=96 RECID=24 STAMP=1096546827
input archived log thread=1 sequence=97 RECID=25 STAMP=1096549726
channel c1: starting piece 1 at 2022-02-13 23:47:23
channel c2: starting compressed archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=1 sequence=98 RECID=26 STAMP=1096549768
input archived log thread=1 sequence=99 RECID=27 STAMP=1096549961
input archived log thread=1 sequence=100 RECID=28 STAMP=1096549964
input archived log thread=1 sequence=101 RECID=29 STAMP=1096549967
input archived log thread=1 sequence=102 RECID=31 STAMP=1096583801
input archived log thread=1 sequence=103 RECID=30 STAMP=1096583800
input archived log thread=1 sequence=104 RECID=32 STAMP=1096583801
input archived log thread=1 sequence=105 RECID=33 STAMP=1096583807
channel c2: starting piece 1 at 2022-02-13 23:47:23
channel c1: finished piece 1 at 2022-02-13 23:47:30
piece handle=/backup/ARC_ORCL_410lp6ob_1_1.arc tag=TAG20220213T234723 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:07
channel c1: starting compressed archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=73 RECID=2 STAMP=1096532522
input archived log thread=1 sequence=74 RECID=8 STAMP=1096532523
input archived log thread=1 sequence=75 RECID=4 STAMP=1096532522
input archived log thread=1 sequence=76 RECID=3 STAMP=1096532522
input archived log thread=1 sequence=77 RECID=7 STAMP=1096532523
input archived log thread=1 sequence=78 RECID=5 STAMP=1096532522
input archived log thread=1 sequence=79 RECID=6 STAMP=1096532522
input archived log thread=1 sequence=80 RECID=1 STAMP=1096532522
input archived log thread=1 sequence=81 RECID=9 STAMP=1096532524
input archived log thread=1 sequence=82 RECID=10 STAMP=1096532587
input archived log thread=1 sequence=83 RECID=11 STAMP=1096532593
input archived log thread=1 sequence=84 RECID=12 STAMP=1096532655
input archived log thread=1 sequence=85 RECID=13 STAMP=1096532655
input archived log thread=1 sequence=86 RECID=14 STAMP=1096532656
input archived log thread=1 sequence=87 RECID=15 STAMP=1096532656
input archived log thread=1 sequence=88 RECID=16 STAMP=1096532656
input archived log thread=1 sequence=89 RECID=17 STAMP=1096532660
channel c1: starting piece 1 at 2022-02-13 23:47:30
channel c2: finished piece 1 at 2022-02-13 23:47:30
piece handle=/backup/ARC_ORCL_420lp6ob_1_1.arc tag=TAG20220213T234723 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:07
channel c1: finished piece 1 at 2022-02-13 23:47:31
piece handle=/backup/ARC_ORCL_430lp6oi_1_1.arc tag=TAG20220213T234723 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 2022-02-13 23:47:31

Starting backup at 2022-02-13 23:47:31
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 2022-02-13 23:47:33
channel c1: finished piece 1 at 2022-02-13 23:47:34
piece handle=/backup/control_440lp6ok_1_1.ctl tag=TAG20220213T234732 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 2022-02-13 23:47:34

Starting backup at 2022-02-13 23:47:34
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 2022-02-13 23:47:34
channel c1: finished piece 1 at 2022-02-13 23:47:35
piece handle=/backup/spfile_ORCL_450lp6om_1_1.ora tag=TAG20220213T234734 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 2022-02-13 23:47:35

Starting Control File and SPFILE Autobackup at 2022-02-13 23:47:35
piece handle=/u01/app/oracle/product/19.0.0/db_1/dbs/c-1616795247-20220213-17 comment=NONE
Finished Control File and SPFILE Autobackup at 2022-02-13 23:47:36

released channel: c1

released channel: c2

[root@19c02 backup]# cp /u01/app/oracle/product/19.0.0/db_1/dbs/arch1* /backup/arch/ --将最近的归档日志也复制过去
4.5、逻辑卷迁移数据
4.5.1、172.16.220.20主机逻辑卷导出
[root@19c02 etc]# umount /backup
[root@19c02 etc]# vgchange -an backupvg
  0 logical volume(s) in volume group "backupvg" now active
[root@19c02 etc]# vgexport backupvg
  Volume group "backupvg" successfully exported
4.5.2、172.16.220.30主机逻辑卷导入
[root@19c03 mapper]# vgscan
  Reading volume groups from cache.
  Found volume group "backupvg" using metadata type lvm2
[root@19c03 mapper]# pvscan
  PV /dev/mapper/disk40g   VG backupvg        lvm2 [<40.00 GiB / <5.00 GiB free]
  Total: 1 [<40.00 GiB] / in use: 1 [<40.00 GiB] / in no VG: 0 [0   ]
[root@19c03 mapper]# vgimport backupvg
  Volume group "backupvg" successfully imported
[root@19c03 mapper]# vgchange -ay backupvg
  1 logical volume(s) in volume group "backupvg" now active
[root@19c03 mapper]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree 
  backupvg   1   1   0 wz--n- <40.00g <5.00g
[root@19c03 mapper]# lvs
  LV       VG       Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  backuplv backupvg -wi-a----- 35.00g                                                    
[root@19c03 mapper]# mkdir /backup
[root@19c03 mapper]# mount /dev/backupvg/backuplv /backup

[root@19c03 /]# cd backup/
[root@19c03 backup]# ls
arch  full_1096584902_2i0lp3m6_1_1.bak  spfile_2m0lp3ts_1_1.ora  spfile_2o0lp41l_1_1.ora   --备份文件已经传输过来
4.6、数据库恢复
[oracle@19c03:/home/oracle]$export ORACLE_SID=test
[oracle@19c03:/home/oracle]$vi pfile.ora
db_name=orcl
[oracle@19c03:/home/oracle]$rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Feb 13 23:13:47 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)
RMAN> startup nomount pfile='/home/oracle/pfile.ora';

Oracle instance started

Total System Global Area     268434280 bytes

Fixed Size                     8895336 bytes
Variable Size                201326592 bytes
Database Buffers              50331648 bytes
Redo Buffers                   7880704 bytes


RMAN> restore spfile to pfile '/home/oracle/pfile.ora' from '/backup/spfile_2m0lp3ts_1_1.ora';

Starting restore at 2022-02-13 23:17:04
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /backup/spfile_2m0lp3ts_1_1.ora
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 2022-02-13 23:17:07

RMAN> shutdown immediate --关机 删除pfile中dg相关的参数

Oracle instance shut down

RMAN>
RMAN> startup nomount pfile='/home/oracle/pfile.ora';

connected to target database (not started)
Oracle instance started

Total System Global Area     268434280 bytes

Fixed Size                     8895336 bytes
Variable Size                201326592 bytes
Database Buffers              50331648 bytes
Redo Buffers                   7880704 bytes
RMAN> create spfile from pfile='/home/oracle/pfile.ora';  --创建spfile

Statement processed

RMAN> startup nomount force

Oracle instance started

Total System Global Area     268434280 bytes

Fixed Size                     8895336 bytes
Variable Size                201326592 bytes
Database Buffers              50331648 bytes
Redo Buffers                   7880704 bytes

RMAN> restore primary controlfile  from '/backup/control_440lp6ok_1_1.ctl';

Starting restore at 2022-02-13 23:51:59
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/product/19.0.0/db_1/dbs/cntrltest.dbf
Finished restore at 2022-02-13 23:52:01

RMAN> alter database mount;

released channel: ORA_DISK_1
Statement processed
4.7、控制文件清除垃圾信息
SQL> EXECUTE DBMS_BACKUP_RESTORE.RESETCFILESECTION(11); 

PL/SQL procedure successfully completed.

SQL> EXECUTE DBMS_BACKUP_RESTORE.RESETCFILESECTION(12); 

PL/SQL procedure successfully completed.

SQL> EXECUTE DBMS_BACKUP_RESTORE.RESETCFILESECTION(13);

PL/SQL procedure successfully completed
4.8、注册备份集并恢复
RMAN> catalog start with '/backup';

searching for all files that match the pattern /backup

List of Files Unknown to the Database
=====================================
File Name: /backup/ARC_ORCL_410lp6ob_1_1.arc
File Name: /backup/ARC_ORCL_420lp6ob_1_1.arc
File Name: /backup/ARC_ORCL_430lp6oi_1_1.arc
File Name: /backup/control_440lp6ok_1_1.ctl
File Name: /backup/FULL_ORCL_3v0lp6mu_1_1.bak
File Name: /backup/FULL_ORCL_400lp6mu_1_1.bak
File Name: /backup/spfile_ORCL_450lp6om_1_1.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: /backup/ARC_ORCL_410lp6ob_1_1.arc
File Name: /backup/ARC_ORCL_420lp6ob_1_1.arc
File Name: /backup/ARC_ORCL_430lp6oi_1_1.arc
File Name: /backup/control_440lp6ok_1_1.ctl
File Name: /backup/FULL_ORCL_3v0lp6mu_1_1.bak
File Name: /backup/FULL_ORCL_400lp6mu_1_1.bak
File Name: /backup/spfile_ORCL_450lp6om_1_1.ora

RMAN> list backup
2> ;

List of Backup Sets
===================


BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
1       49.53M     DISK        00:00:05     2022-02-13 23:47:28
        BP Key: 1   Status: AVAILABLE  Compressed: YES  Tag: TAG20220213T234723
        Piece Name: /backup/ARC_ORCL_410lp6ob_1_1.arc

  List of Archived Logs in backup set 1
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    90      4328849    2022-02-13 08:24:20 4328852    2022-02-13 08:24:20
  1    91      4328852    2022-02-13 08:24:20 4341007    2022-02-13 09:55:06
  1    92      4341007    2022-02-13 09:55:06 4341014    2022-02-13 09:55:08
  1    93      4341014    2022-02-13 09:55:08 4341021    2022-02-13 09:55:10
  1    94      4341021    2022-02-13 09:55:10 4341348    2022-02-13 12:14:52
  1    95      4341348    2022-02-13 12:14:52 4360633    2022-02-13 12:20:21
  1    96      4360633    2022-02-13 12:20:21 4360647    2022-02-13 12:20:27
  1    97      4360647    2022-02-13 12:20:27 4369257    2022-02-13 13:08:45

BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
2       33.08M     DISK        00:00:04     2022-02-13 23:47:27
        BP Key: 2   Status: AVAILABLE  Compressed: YES  Tag: TAG20220213T234723
        Piece Name: /backup/ARC_ORCL_420lp6ob_1_1.arc

  List of Archived Logs in backup set 2
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    98      4369257    2022-02-13 13:08:45 4369617    2022-02-13 13:09:27
  1    99      4369617    2022-02-13 13:09:27 4370264    2022-02-13 13:12:41
  1    100     4370264    2022-02-13 13:12:41 4370271    2022-02-13 13:12:44
  1    101     4370271    2022-02-13 13:12:44 4370279    2022-02-13 13:12:47
  1    102     4370279    2022-02-13 13:12:47 4376126    2022-02-13 13:58:11
  1    103     4376126    2022-02-13 13:58:11 4381203    2022-02-13 14:32:23
  1    104     4381203    2022-02-13 14:32:23 4381784    2022-02-13 14:36:41
  1    105     4381784    2022-02-13 14:36:41 4381799    2022-02-13 14:36:47

BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
3       3.03M      DISK        00:00:01     2022-02-13 23:47:31
        BP Key: 3   Status: AVAILABLE  Compressed: YES  Tag: TAG20220213T234723
        Piece Name: /backup/ARC_ORCL_430lp6oi_1_1.arc

  List of Archived Logs in backup set 3
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    73      4315236    2022-02-13 06:51:01 4318083    2022-02-13 07:09:24
  1    74      4318083    2022-02-13 07:09:24 4326334    2022-02-13 08:07:40
  1    75      4326334    2022-02-13 08:07:40 4326339    2022-02-13 08:07:41
  1    76      4326339    2022-02-13 08:07:41 4326344    2022-02-13 08:07:43
  1    77      4326344    2022-02-13 08:07:43 4327824    2022-02-13 08:16:21
  1    78      4327824    2022-02-13 08:16:21 4327925    2022-02-13 08:17:11
  1    79      4327925    2022-02-13 08:17:11 4327932    2022-02-13 08:17:13
  1    80      4327932    2022-02-13 08:17:13 4328539    2022-02-13 08:22:01
  1    81      4328539    2022-02-13 08:22:01 4328548    2022-02-13 08:22:05
  1    82      4328548    2022-02-13 08:22:05 4328680    2022-02-13 08:23:08
  1    83      4328680    2022-02-13 08:23:08 4328693    2022-02-13 08:23:14
  1    84      4328693    2022-02-13 08:23:14 4328824    2022-02-13 08:24:15
  1    85      4328824    2022-02-13 08:24:15 4328829    2022-02-13 08:24:16
  1    86      4328829    2022-02-13 08:24:16 4328832    2022-02-13 08:24:16
  1    87      4328832    2022-02-13 08:24:16 4328835    2022-02-13 08:24:16
  1    88      4328835    2022-02-13 08:24:16 4328840    2022-02-13 08:24:17
  1    89      4328840    2022-02-13 08:24:17 4328849    2022-02-13 08:24:20

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
4       Full    10.45M     DISK        00:00:01     2022-02-13 23:47:33
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20220213T234732
        Piece Name: /backup/control_440lp6ok_1_1.ctl
  Standby Control File Included: Ckp SCN: 4391328      Ckp time: 2022-02-13 15:44:44

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
5       Full    177.79M    DISK        00:00:19     2022-02-13 23:46:57
        BP Key: 5   Status: AVAILABLE  Compressed: YES  Tag: TAG20220213T234638
        Piece Name: /backup/FULL_ORCL_3v0lp6mu_1_1.bak
  List of Datafiles in backup set 5
  File LV Type Ckp SCN    Ckp Time            Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- ------------------- ----------- ------ ----
  4       Full 4376116    2022-02-13 13:57:41 4390907      NO    /u01/app/oracle/oradata/ORCL/undotbs01.dbf
  7       Full 4376116    2022-02-13 13:57:41              NO    /u01/app/oracle/oradata/ORCL/users01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
6       Full    304.26M    DISK        00:00:35     2022-02-13 23:47:13
        BP Key: 6   Status: AVAILABLE  Compressed: YES  Tag: TAG20220213T234638
        Piece Name: /backup/FULL_ORCL_400lp6mu_1_1.bak
  List of Datafiles in backup set 6
  File LV Type Ckp SCN    Ckp Time            Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- ------------------- ----------- ------ ----
  1       Full 4376116    2022-02-13 13:57:41 4389863      NO    /u01/app/oracle/oradata/ORCL/system01.dbf
  3       Full 4376116    2022-02-13 13:57:41 4390906      NO    /u01/app/oracle/oradata/ORCL/sysaux01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
7       Full    96.00K     DISK        00:00:00     2022-02-13 23:47:34
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20220213T234734
        Piece Name: /backup/spfile_ORCL_450lp6om_1_1.ora
  SPFILE Included: Modification time: 2022-02-13 08:21:32
  SPFILE db_unique_name: ORCLDG
  
--restore  
RMAN> restore database;

Starting restore at 2022-02-13 23:55:27
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=185 device type=DISK

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 /u01/app/oracle/oradata/ORCL/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ORCL/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /backup/FULL_ORCL_400lp6mu_1_1.bak
channel ORA_DISK_1: piece handle=/backup/FULL_ORCL_400lp6mu_1_1.bak tag=TAG20220213T234638
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
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 00004 to /u01/app/oracle/oradata/ORCL/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/ORCL/users01.dbf
channel ORA_DISK_1: reading from backup piece /backup/FULL_ORCL_3v0lp6mu_1_1.bak
channel ORA_DISK_1: piece handle=/backup/FULL_ORCL_3v0lp6mu_1_1.bak tag=TAG20220213T234638
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 2022-02-13 23:57:08

SQL> select open_mode , database_role, flashback_on from v$database; --已经为主库,如果还是备库状态的话 需要alter database activate standby database;
OPEN_MODE                                DATABASE_ROLE                    FLASHBACK_ON
---------------------------------------- -------------------------------- ------------------------------------
MOUNTED                                  PRIMARY                          NO

RMAN> alter database open resetlogs;  --提示不一致  

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 02/13/2022 23:59:25
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/u01/app/oracle/oradata/ORCL/system01.dbf'

SQL> select checkpoint_change# from v$datafile;

CHECKPOINT_CHANGE#
------------------
           4394992
           4394992
           4394992
           4394992

SQL> select checkpoint_change# from v$datafile_header;

CHECKPOINT_CHANGE#
------------------
           4376116
           4376116
           4376116
           4376116

复制后面的归档日志过来
RMAN> recover database until scn 4394992;

Starting recover at 2022-02-14 00:14:15
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 102 is already on disk as file /backup/arch/arch1_102_1089014515.dbf
archived log for thread 1 with sequence 103 is already on disk as file /backup/arch/arch1_103_1089014515.dbf
archived log for thread 1 with sequence 104 is already on disk as file /backup/arch/arch1_104_1089014515.dbf
archived log for thread 1 with sequence 105 is already on disk as file /backup/arch/arch1_105_1089014515.dbf
archived log for thread 1 with sequence 106 is already on disk as file /backup/arch/arch1_106_1089014515.dbf
archived log for thread 1 with sequence 107 is already on disk as file /backup/arch/arch1_107_1089014515.dbf
archived log for thread 1 with sequence 108 is already on disk as file /backup/arch/arch1_108_1089014515.dbf
archived log for thread 1 with sequence 109 is already on disk as file /backup/arch/arch1_109_1089014515.dbf
archived log for thread 1 with sequence 110 is already on disk as file /backup/arch/arch1_110_1089014515.dbf
archived log file name=/backup/arch/arch1_102_1089014515.dbf thread=1 sequence=102
archived log file name=/backup/arch/arch1_103_1089014515.dbf thread=1 sequence=103
archived log file name=/backup/arch/arch1_104_1089014515.dbf thread=1 sequence=104
archived log file name=/backup/arch/arch1_105_1089014515.dbf thread=1 sequence=105
archived log file name=/backup/arch/arch1_106_1089014515.dbf thread=1 sequence=106
archived log file name=/backup/arch/arch1_107_1089014515.dbf thread=1 sequence=107
archived log file name=/backup/arch/arch1_108_1089014515.dbf thread=1 sequence=108
archived log file name=/backup/arch/arch1_109_1089014515.dbf thread=1 sequence=109
archived log file name=/backup/arch/arch1_110_1089014515.dbf thread=1 sequence=110
media recovery complete, elapsed time: 00:00:02
Finished recover at 2022-02-14 00:14:18

RMAN> alter database open resetlogs;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00601: fatal error in recovery manager
RMAN-03004: fatal error during execution of command
ORA-03114: not connected to ORACLE
RMAN-03002: failure of sql statement command at 02/14/2022 00:14:33
ORA-03113: end-of-file on communication channel
Process ID: 28251
Session ID: 162 Serial number: 35081

SQL> select * from v$logfile;
  GROUP# STATUS         TYPE           MEMBER                                             IS_REC     CON_ID
---------- -------------- -------------- -------------------------------------------------- ------ ----------
         3                ONLINE         /u01/app/oracle/oradata/ORCL/redo03.log            NO              0
         2                ONLINE         /u01/app/oracle/oradata/ORCL/redo02.log            NO              0
         1                ONLINE         /u01/app/oracle/oradata/ORCL/redo01.log            NO              0
         4                STANDBY        /u01/app/oracle/oradata/ORCL/standbyredo01.log     NO              0
         5                STANDBY        /u01/app/oracle/oradata/ORCL/standbyredo02.log     NO              0
         6                STANDBY        /u01/app/oracle/oradata/ORCL/standbyredo03.log     NO              0
         7                STANDBY        /u01/app/oracle/oradata/ORCL/standbyredo04.log     NO              0
SQL> select * from v$log;
 GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARCHIV STATUS   FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME      CON_ID
---------- ---------- ---------- ---------- ---------- ---------- ------ -------- ------------- ------------------- ------------ ---------- ----------
         1 1          1  209715200        512          1 NO     CURRENT        4394993 2022-02-14 00:14:26   1.8447E+19                     0
         3 1          0  209715200        512          1 YES    UNUSED               0                                0                     0
         2 1          0  209715200        512          1 YES    UNUSED               0                                0                     0
4.8.1、本地没有日志文件
SQL> alter database drop logfile group 4;

Database altered.

SQL> alter database drop logfile group 5;
alter database drop logfile group 5
*
ERROR at line 1:
ORA-00313: open failed for members of log group 5 of thread 1
ORA-00312: online log 5 thread 1: '/u01/app/oracle/oradata/ORCL/standbyredo02.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7

SQL> select DATABASE_ROLE,PROTECTION_MODE,OPEN_MODE,LOG_MODE from v$database; --最大可用模式的锅
DATABASE_ROLE                    PROTECTION_MODE                          OPEN_MODE                                LOG_MODE
-------------------------------- ---------------------------------------- ---------------------------------------- ------------------------
PRIMARY                          MAXIMUM AVAILABILITY                     MOUNTED                                  ARCHIVELOG


SQL> alter database set standby database to maximize performance;

SQL> select DATABASE_ROLE,PROTECTION_MODE,OPEN_MODE,LOG_MODE from v$database;

DATABASE_ROLE                    PROTECTION_MODE                          OPEN_MODE                                LOG_MODE
-------------------------------- ---------------------------------------- ---------------------------------------- ------------------------
PRIMARY                          MAXIMUM PERFORMANCE                      MOUNTED                                  ARCHIVELOG


RMAN> alter database open;

Statement processed

五、总结

  • 没有redo文件,数据库起来后可以自动创建的,主要是足以temp表空间,因为很多情况下控制文件虽然写了创建temp表空间,但是不会创建临死数据文件,需要添加临死数据文件。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论