Oracle Dataguard(主库为 Oracle rac 集群)配置教程(02)—— Oracle RAC 主库的相关操作
/
本专栏详细讲解 Oracle Dataguard(Oracle 版本为11g,主库为双节点 Oracle rac 集群)的配置过程。主要内容包括:
(1)dataguard 服务器 Oracle 软件的安装。
(2)Oracle RAC 主库与 Dataguard 服务器的配置。
(3)主从同步测试。
(4)主备库切换。
/
目录
- Oracle Dataguard(主库为 Oracle rac 集群)配置教程(02)—— Oracle RAC 主库的相关操作
- 一、把 Oracle RAC 主库设置为 Force Logging 模式与归档模式
- 1、查看 Oracle RAC 主库是否为归档模式和 Force Logging 模式
- 2、把 Oracle RAC 主库设置为 Force Logging 模式
- 3、把 Oracle RAC 主库设置为归档模式
- 二、在 Oracle RAC 主库执行 RMAN 全备操作
- 1、在 Oracle RAC 主库的节点1上添加一块磁盘,用于存放备份文件
- 3、在 Oracle RAC 主库执行 RMAN 全备操作
- 4、在 Oracle RAC 主库创建物理备库控制文件
- 5、在 Oracle RAC 主库创建物理备库初始化参数文件
- 6、在 Oracle RAC 主库修改口令文件,使两个节点的SYS 用户口令均为 oracle
一、把 Oracle RAC 主库设置为 Force Logging 模式与归档模式
1、查看 Oracle RAC 主库是否为归档模式和 Force Logging 模式
SQL> select name,open_mode,log_mode,force_logging from v$database;
NAME OPEN_MODE LOG_MODE FOR
--------- -------------------- ------------ ---
HISDB READ WRITE NOARCHIVELOG NO
2、把 Oracle RAC 主库设置为 Force Logging 模式
SQL> alter database force logging;
Database altered.
SQL> select name,open_mode,log_mode,force_logging from v$database;
NAME OPEN_MODE LOG_MODE FOR
--------- -------------------- ------------ ---
HISDB READ WRITE NOARCHIVELOG YES
3、把 Oracle RAC 主库设置为归档模式
设置数据库为归档模式需要停库,然后启动数据库到 mount 状态。
(1)停库
# 切换到grid用户
# 查看数据库
[grid@rac1 ~]$ srvctl status database -d hisdb;
Instance hisdb1 is running on node rac1
Instance hisdb2 is running on node rac2
# 停库
[grid@rac1 ~]$ srvctl stop database -d hisdb;
# 查看数据库
[grid@rac1 ~]$ srvctl status database -d hisdb;
Instance hisdb1 is not running on node rac1
Instance hisdb2 is not running on node rac2
(2)切换到Oracle用户,启动数据库到mount状态(在任意一个节点操作即可)
SQL> startup mount;
ORACLE instance started.
Total System Global Area 626327552 bytes
Fixed Size 2255832 bytes
Variable Size 297796648 bytes
Database Buffers 322961408 bytes
Redo Buffers 3313664 bytes
Database mounted.
-- 把数据库设置为归档模式
SQL> alter database archivelog;
Database altered.
-- 查看数据库
SQL> select name,open_mode,log_mode,force_logging from v$database;
NAME OPEN_MODE LOG_MODE FOR
--------- -------------------- ------------ ---
HISDB MOUNTED ARCHIVELOG YES
(3)启动数据库
--停库
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
-- 切换到grid用户
-- 启动数据库
[grid@rac1 ~]$ srvctl start database -d hisdb;
[grid@rac1 ~]$ srvctl status database -d hisdb;
Instance hisdb1 is running on node rac1
Instance hisdb2 is running on node rac2
二、在 Oracle RAC 主库执行 RMAN 全备操作
1、在 Oracle RAC 主库的节点1上添加一块磁盘,用于存放备份文件
在 Oracle RAC 主库的节点1上添加一块磁盘,大小10GB,并挂载到目录 /rman_backup;在 dataguard 服务器上添加一块磁盘,大小10GB,并挂载到目录 /rman_backup。把 Oracle RAC 主库的数据库备份文件写入 /rman_backup 目录。然后通过把备份文件复制到 dataguard 服务器的 /rman_backup 目录,用于恢复数据库。
在 Oracle RAC 主库的节点1执行如下操作:
(1)在 Oracle RAC 主库的节点1上添加磁盘
# 查看磁盘信息,/dev/sdb 为新添加的磁盘
[root@rac1 ~]# ll /dev/sd*
brw-rw---- 1 root disk 8, 0 2月 10 15:55 /dev/sda
brw-rw---- 1 root disk 8, 1 2月 10 15:55 /dev/sda1
brw-rw---- 1 root disk 8, 2 2月 10 15:55 /dev/sda2
brw-rw---- 1 root disk 8, 16 2月 10 15:55 /dev/sdb
brw-rw---- 1 root disk 8, 32 2月 10 15:55 /dev/sdc
brw-rw---- 1 root disk 8, 33 2月 10 15:55 /dev/sdc1
brw-rw---- 1 root disk 8, 34 2月 10 15:55 /dev/sdc2
brw-rw---- 1 root disk 8, 35 2月 10 15:55 /dev/sdc3
brw-rw---- 1 root disk 8, 36 2月 10 15:55 /dev/sdc4
brw-rw---- 1 root disk 8, 37 2月 10 15:55 /dev/sdc5
brw-rw---- 1 root disk 8, 38 2月 10 15:55 /dev/sdc6
brw-rw---- 1 root disk 8, 39 2月 10 15:55 /dev/sdc7
brw-rw---- 1 root disk 8, 40 2月 10 15:55 /dev/sdc8
(2)为磁盘 /dev/sdb 创建分区
[root@rac1 ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x4bbf68c2 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-20971519,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-20971519,默认为 20971519):
将使用默认值 20971519
分区 1 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
# 查看磁盘信息
[root@rac1 ~]# ll /dev/sd*
brw-rw---- 1 root disk 8, 0 2月 10 15:55 /dev/sda
brw-rw---- 1 root disk 8, 1 2月 10 15:55 /dev/sda1
brw-rw---- 1 root disk 8, 2 2月 10 15:55 /dev/sda2
brw-rw---- 1 root disk 8, 16 2月 10 15:59 /dev/sdb
brw-rw---- 1 root disk 8, 17 2月 10 15:59 /dev/sdb1
brw-rw---- 1 root disk 8, 32 2月 10 15:55 /dev/sdc
brw-rw---- 1 root disk 8, 33 2月 10 15:55 /dev/sdc1
brw-rw---- 1 root disk 8, 34 2月 10 15:55 /dev/sdc2
brw-rw---- 1 root disk 8, 35 2月 10 15:55 /dev/sdc3
brw-rw---- 1 root disk 8, 36 2月 10 15:55 /dev/sdc4
brw-rw---- 1 root disk 8, 37 2月 10 15:55 /dev/sdc5
brw-rw---- 1 root disk 8, 38 2月 10 15:55 /dev/sdc6
brw-rw---- 1 root disk 8, 39 2月 10 15:55 /dev/sdc7
brw-rw---- 1 root disk 8, 40 2月 10 15:55 /dev/sdc8
(3)格式化磁盘 /dev/sdb1
[root@rac1 ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621184 blocks
131059 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
(4)创建目录 /rman_backup,并修改属性
[root@rac1 ~]# mkdir /rman_backup
[root@rac1 ~]# chown -R oracle:oinstall /rman_backup
[root@rac1 ~]# ll /
总用量 20
lrwxrwxrwx. 1 root root 7 2月 10 06:19 bin -> usr/bin
dr-xr-xr-x. 4 root root 4096 2月 9 23:50 boot
drwxr-xr-x 21 root root 3480 2月 10 15:59 dev
drwxr-xr-x. 80 root root 8192 2月 10 15:55 etc
drwxr-xr-x. 4 root root 32 2月 9 22:47 home
lrwxrwxrwx. 1 root root 7 2月 10 06:19 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 2月 10 06:19 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 11月 5 2016 media
drwxr-xr-x. 2 root root 6 11月 5 2016 mnt
drwxr-xr-x. 4 root root 36 2月 10 00:10 opt
dr-xr-xr-x 228 root root 0 2月 10 15:55 proc
drwxr-xr-x 2 oracle oinstall 6 2月 10 16:03 rman_backup
dr-xr-x---. 2 root root 135 2月 9 23:44 root
drwxr-xr-x 21 root root 620 2月 10 15:55 run
lrwxrwxrwx. 1 root root 8 2月 10 06:19 sbin -> usr/sbin
drwxr-xr-x. 8 root root 166 2月 9 23:49 soft
drwxr-xr-x. 2 root root 6 11月 5 2016 srv
dr-xr-xr-x 13 root root 0 2月 10 15:55 sys
drwxrwxrwt. 15 root root 4096 2月 10 15:56 tmp
drwxr-xr-x. 3 root oinstall 17 2月 9 22:59 u01
drwxr-xr-x. 13 root root 155 2月 10 06:19 usr
drwxr-xr-x. 19 root root 267 2月 10 15:55 var
(5)把磁盘 /dev/sdb1 挂载到目录 /rman_backup
# 临时挂载
[root@rac1 ~]# mount -t ext3 /dev/sdb1 /rman_backup
# 永久挂载
[root@rac1 ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Jan 30 02:37:18 2023
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root / xfs defaults 0 0
UUID=870d48ff-ed96-4f06-ace9-34127c37003c /boot xfs defaults 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
/dev/sdb1 /rman_backup ext3 defaults 0 0
# 查看磁盘挂载信息
[root@rac1 ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/cl-root xfs 20G 18G 2.5G 88% /
devtmpfs devtmpfs 902M 0 902M 0% /dev
tmpfs tmpfs 912M 116M 797M 13% /dev/shm
tmpfs tmpfs 912M 8.7M 904M 1% /run
tmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 138M 877M 14% /boot
tmpfs tmpfs 183M 0 183M 0% /run/user/0
/dev/sdb1 ext3 9.8G 23M 9.2G 1% /rman_backup
2、在 Dataguard 服务器上添加一块磁盘,用于存放备份文件
(1)查看磁盘信息
[root@hisdg ~]# ll /dev/sd*
brw-rw----. 1 root disk 8, 0 2月 10 15:53 /dev/sda
brw-rw----. 1 root disk 8, 1 2月 10 15:53 /dev/sda1
brw-rw----. 1 root disk 8, 2 2月 10 15:53 /dev/sda2
brw-rw----. 1 root disk 8, 16 2月 10 15:53 /dev/sdb
(2)为磁盘 /dev/sdb 创建分区
[root@hisdg ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x31bf155b 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-20971519,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-20971519,默认为 20971519):
将使用默认值 20971519
分区 1 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
# 查看磁盘信息
[root@hisdg ~]# ll /dev/sd*
brw-rw----. 1 root disk 8, 0 2月 10 15:53 /dev/sda
brw-rw----. 1 root disk 8, 1 2月 10 15:53 /dev/sda1
brw-rw----. 1 root disk 8, 2 2月 10 15:53 /dev/sda2
brw-rw----. 1 root disk 8, 16 2月 10 16:10 /dev/sdb
brw-rw----. 1 root disk 8, 17 2月 10 16:10 /dev/sdb1
(3)格式化磁盘 /dev/sdb1
[root@hisdg ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621184 blocks
131059 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
(4)创建目录 /rman_backup,并修改属性
[root@hisdg ~]# mkdir /rman_backup
[root@hisdg ~]# chown -R oracle:oinstall /rman_backup
[root@hisdg ~]# ll /
总用量 20
lrwxrwxrwx. 1 root root 7 2月 6 03:24 bin -> usr/bin
dr-xr-xr-x. 4 root root 4096 2月 6 03:32 boot
drwxr-xr-x. 20 root root 3260 2月 10 16:10 dev
drwxr-xr-x. 78 root root 8192 2月 10 15:53 etc
drwxr-xr-x. 3 root root 20 2月 10 12:51 home
lrwxrwxrwx. 1 root root 7 2月 6 03:24 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 2月 6 03:24 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 11月 5 2016 media
drwxr-xr-x. 2 root root 6 11月 5 2016 mnt
drwxr-xr-x. 3 root root 22 2月 10 14:35 opt
dr-xr-xr-x. 105 root root 0 2月 10 15:53 proc
drwxr-xr-x. 2 oracle oinstall 6 2月 10 16:13 rman_backup
dr-xr-x---. 2 root root 135 2月 5 20:13 root
drwxr-xr-x. 21 root root 620 2月 10 15:54 run
lrwxrwxrwx. 1 root root 8 2月 6 03:24 sbin -> usr/sbin
drwxr-xr-x. 6 root root 134 2月 10 13:34 soft
drwxr-xr-x. 2 root root 6 11月 5 2016 srv
dr-xr-xr-x. 13 root root 0 2月 10 15:53 sys
drwxrwxrwt. 12 root root 4096 2月 10 15:54 tmp
drwxrwxr-x. 3 oracle oinstall 17 2月 10 13:00 u01
drwxr-xr-x. 13 root root 155 2月 6 03:24 usr
drwxr-xr-x. 19 root root 267 2月 10 15:53 var
(5)把磁盘 /dev/sdb1 挂载到目录 /rman_backup
# 临时挂载
[root@hisdg ~]# mount -t ext3 /dev/sdb1 /rman_backup
# 永久挂载
[root@hisdg ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Feb 6 03:24:40 2023
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root / xfs defaults 0 0
UUID=98f33897-679b-41a1-a3e9-e6b7824033ab /boot xfs defaults 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
/dev/sdb1 /rman_backup ext3 defaults 0 0
3、在 Oracle RAC 主库执行 RMAN 全备操作
(1)切换到 Oracle 用户,查看备份信息
在 Oracle RAC 集群的节点1执行如下代码:
-- 切换到 Oracle 用户,进入 rman
[root@rac1 ~]# su - oracle
上一次登录:五 2月 10 12:00:42 CST 2023pts/6 上
[oracle@rac1 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Feb 10 16:19:38 2023
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: HISDB (DBID=2041031531)
-- 查看需要备份的数据文件
RMAN> report need backup;
using target database control file instead of recovery catalog
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
1 0 +DATA/hisdb/datafile/system.267.1128415373
2 0 +DATA/hisdb/datafile/sysaux.260.1128415373
3 0 +DATA/hisdb/datafile/undotbs1.263.1128415373
4 0 +DATA/hisdb/datafile/users.266.1128415373
5 0 +DATA/hisdb/datafile/undotbs2.259.1128415887
-- 删除归档日志文件
RMAN> delete archivelog all;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=60 instance=hisdb1 device type=DISK
List of Archived Log Copies for database with db_unique_name HISDB
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - ---------
1 1 5 A 10-FEB-23
Name: +BAK/hisdb/archivelog/2023_02_10/thread_1_seq_5.261.1128441541
2 2 2 A 10-FEB-23
Name: +BAK/hisdb/archivelog/2023_02_10/thread_2_seq_2.262.1128441549
3 2 3 A 10-FEB-23
Name: +BAK/hisdb/archivelog/2023_02_10/thread_2_seq_3.263.1128441563
Do you really want to delete the above objects (enter YES or NO)? yes
deleted archived log
archived log file name=+BAK/hisdb/archivelog/2023_02_10/thread_1_seq_5.261.1128441541 RECID=1 STAMP=1128441551
deleted archived log
archived log file name=+BAK/hisdb/archivelog/2023_02_10/thread_2_seq_2.262.1128441549 RECID=2 STAMP=1128441555
deleted archived log
archived log file name=+BAK/hisdb/archivelog/2023_02_10/thread_2_seq_3.263.1128441563 RECID=3 STAMP=1128441564
Deleted 3 objects
-- 查看备份信息
RMAN> list backup;
specification does not match any backup in the repository
-- 查看归档日志信息
RMAN> list archivelog all;
specification does not match any archived log in the repository
(2)在 Oracle RAC 主库执行全备操作
-- 执行全备(同时备份归档日志)
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup database format '/rman_backup/Full_%U.bak';
backup archivelog all format '/rman_backup/ARC_%U.bak';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
--执行全备操作,备份数据文件和归档日志
RMAN>
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup database format '/rman_backup/Full_%U.bak';
backup archivelog all format '/rman_backup/ARC_%U.bak';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> }
allocated channel: c1
channel c1: SID=60 instance=hisdb1 device type=DISK
allocated channel: c2
channel c2: SID=35 instance=hisdb1 device type=DISK
allocated channel: c3
channel c3: SID=69 instance=hisdb1 device type=DISK
allocated channel: c4
channel c4: SID=72 instance=hisdb1 device type=DISK
Starting backup at 10-FEB-23
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/hisdb/datafile/system.267.1128415373
channel c1: starting piece 1 at 10-FEB-23
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00002 name=+DATA/hisdb/datafile/sysaux.260.1128415373
input datafile file number=00004 name=+DATA/hisdb/datafile/users.266.1128415373
channel c2: starting piece 1 at 10-FEB-23
channel c3: starting full datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00003 name=+DATA/hisdb/datafile/undotbs1.263.1128415373
input datafile file number=00005 name=+DATA/hisdb/datafile/undotbs2.259.1128415887
channel c3: starting piece 1 at 10-FEB-23
channel c4: starting full datafile backup set
channel c4: specifying datafile(s) in backup set
channel c1: finished piece 1 at 10-FEB-23
piece handle=/rman_backup/Full_051k5ba1_1_1.bak tag=TAG20230210T162640 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:57
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 10-FEB-23
channel c2: finished piece 1 at 10-FEB-23
piece handle=/rman_backup/Full_061k5ba2_1_1.bak tag=TAG20230210T162640 comment=NONE
channel c2: backup set complete, elapsed time: 00:02:42
including current control file in backup set
channel c4: starting piece 1 at 10-FEB-23
channel c1: finished piece 1 at 10-FEB-23
piece handle=/rman_backup/Full_091k5beb_1_1.bak tag=TAG20230210T162640 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:22
channel c3: finished piece 1 at 10-FEB-23
piece handle=/rman_backup/Full_071k5ba2_1_1.bak tag=TAG20230210T162640 comment=NONE
channel c3: backup set complete, elapsed time: 00:02:48
channel c4: finished piece 1 at 10-FEB-23
piece handle=/rman_backup/Full_081k5bab_1_1.bak tag=TAG20230210T162640 comment=NONE
channel c4: backup set complete, elapsed time: 00:00:16
Finished backup at 10-FEB-23
Starting backup at 10-FEB-23
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=6 RECID=5 STAMP=1128443427
channel c1: starting piece 1 at 10-FEB-23
channel c2: starting archived log backup set
channel c2: specifying archived log(s) in backup set
input archived log thread=2 sequence=4 RECID=4 STAMP=1128443427
channel c2: starting piece 1 at 10-FEB-23
channel c1: finished piece 1 at 10-FEB-23
piece handle=/rman_backup/ARC_0a1k5bh5_1_1.bak tag=TAG20230210T163027 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:06
channel c2: finished piece 1 at 10-FEB-23
piece handle=/rman_backup/ARC_0b1k5bh6_1_1.bak tag=TAG20230210T163027 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:04
Finished backup at 10-FEB-23
released channel: c1
released channel: c2
released channel: c3
released channel: c4
-- 查看备份信息
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 634.48M DISK 00:00:54 10-FEB-23
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20230210T162640
Piece Name: /rman_backup/Full_051k5ba1_1_1.bak
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1035627 10-FEB-23 +DATA/hisdb/datafile/system.267.1128415373
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 390.88M DISK 00:01:36 10-FEB-23
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20230210T162640
Piece Name: /rman_backup/Full_061k5ba2_1_1.bak
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 1035629 10-FEB-23 +DATA/hisdb/datafile/sysaux.260.1128415373
4 Full 1035629 10-FEB-23 +DATA/hisdb/datafile/users.266.1128415373
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 80.00K DISK 00:00:31 10-FEB-23
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20230210T162640
Piece Name: /rman_backup/Full_091k5beb_1_1.bak
SPFILE Included: Modification time: 10-FEB-23
SPFILE db_unique_name: HISDB
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 6.41M DISK 00:02:49 10-FEB-23
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20230210T162640
Piece Name: /rman_backup/Full_071k5ba2_1_1.bak
List of Datafiles in backup set 4
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
3 Full 1035639 10-FEB-23 +DATA/hisdb/datafile/undotbs1.263.1128415373
5 Full 1035639 10-FEB-23 +DATA/hisdb/datafile/undotbs2.259.1128415887
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5 Full 17.67M DISK 00:02:47 10-FEB-23
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20230210T162640
Piece Name: /rman_backup/Full_081k5bab_1_1.bak
Control File Included: Ckp SCN: 1035644 Ckp time: 10-FEB-23
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
6 2.22M DISK 00:00:06 10-FEB-23
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20230210T163027
Piece Name: /rman_backup/ARC_0a1k5bh5_1_1.bak
List of Archived Logs in backup set 6
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 6 1031045 10-FEB-23 1035799 10-FEB-23
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
7 1.42M DISK 00:00:05 10-FEB-23
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20230210T163027
Piece Name: /rman_backup/ARC_0b1k5bh6_1_1.bak
List of Archived Logs in backup set 7
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
2 4 1031521 10-FEB-23 1035802 10-FEB-23
-- 查看备份文件
[oracle@rac1 ~]$ cd /rman_backup/
[oracle@rac1 rman_backup]$ ll
total 1079604
-rw-r----- 1 oracle asmadmin 2332160 Feb 10 16:30 ARC_0a1k5bh5_1_1.bak
-rw-r----- 1 oracle asmadmin 1490432 Feb 10 16:30 ARC_0b1k5bh6_1_1.bak
-rw-r----- 1 oracle asmadmin 665313280 Feb 10 16:27 Full_051k5ba1_1_1.bak
-rw-r----- 1 oracle asmadmin 409878528 Feb 10 16:28 Full_061k5ba2_1_1.bak
-rw-r----- 1 oracle asmadmin 6725632 Feb 10 16:29 Full_071k5ba2_1_1.bak
-rw-r----- 1 oracle asmadmin 18546688 Feb 10 16:29 Full_081k5bab_1_1.bak
-rw-r----- 1 oracle asmadmin 98304 Feb 10 16:29 Full_091k5beb_1_1.bak
drwx------ 2 oracle oinstall 16384 Feb 10 16:02 lost+found
4、在 Oracle RAC 主库创建物理备库控制文件
RMAN> backup device type disk format '/rman_backup/standby_%U.ctl' current controlfile for standby;
Starting backup at 10-FEB-23
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=73 instance=hisdb1 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including standby control file in backup set
channel ORA_DISK_1: starting piece 1 at 10-FEB-23
channel ORA_DISK_1: finished piece 1 at 10-FEB-23
piece handle=/rman_backup/standby_0c1k5bse_1_1.ctl tag=TAG20230210T163630 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 10-FEB-23
-- 查看备份文件
[root@rac1 ~]# cd /rman_backup/
[root@rac1 rman_backup]# ll
总用量 1097740
-rw-r----- 1 oracle asmadmin 2332160 2月 10 16:30 ARC_0a1k5bh5_1_1.bak
-rw-r----- 1 oracle asmadmin 1490432 2月 10 16:30 ARC_0b1k5bh6_1_1.bak
-rw-r----- 1 oracle asmadmin 665313280 2月 10 16:27 Full_051k5ba1_1_1.bak
-rw-r----- 1 oracle asmadmin 409878528 2月 10 16:28 Full_061k5ba2_1_1.bak
-rw-r----- 1 oracle asmadmin 6725632 2月 10 16:29 Full_071k5ba2_1_1.bak
-rw-r----- 1 oracle asmadmin 18546688 2月 10 16:29 Full_081k5bab_1_1.bak
-rw-r----- 1 oracle asmadmin 98304 2月 10 16:29 Full_091k5beb_1_1.bak
drwx------ 2 oracle oinstall 16384 2月 10 16:02 lost+found
-rw-r----- 1 oracle asmadmin 18546688 2月 10 16:36 standby_0c1k5bse_1_1.ctl
5、在 Oracle RAC 主库创建物理备库初始化参数文件
SQL> show parameter spfile;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATA/hisdb/spfilehisdb.ora
--备库的 ORACLE_SID 为:hisdg,备份的参数文件命名为:inithisdg.ora
SQL> create pfile='/rman_backup/inithisdg.ora' from spfile;
File created.
-- 查看备份文件
[root@rac1 rman_backup]# ll
总用量 1097744
-rw-r----- 1 oracle asmadmin 2332160 2月 10 16:30 ARC_0a1k5bh5_1_1.bak
-rw-r----- 1 oracle asmadmin 1490432 2月 10 16:30 ARC_0b1k5bh6_1_1.bak
-rw-r----- 1 oracle asmadmin 665313280 2月 10 16:27 Full_051k5ba1_1_1.bak
-rw-r----- 1 oracle asmadmin 409878528 2月 10 16:28 Full_061k5ba2_1_1.bak
-rw-r----- 1 oracle asmadmin 6725632 2月 10 16:29 Full_071k5ba2_1_1.bak
-rw-r----- 1 oracle asmadmin 18546688 2月 10 16:29 Full_081k5bab_1_1.bak
-rw-r----- 1 oracle asmadmin 98304 2月 10 16:29 Full_091k5beb_1_1.bak
-rw-r--r-- 1 oracle asmadmin 1392 2月 10 16:40 inithisdg.ora
drwx------ 2 oracle oinstall 16384 2月 10 16:02 lost+found
-rw-r----- 1 oracle asmadmin 18546688 2月 10 16:36 standby_0c1k5bse_1_1.ctl
6、在 Oracle RAC 主库修改口令文件,使两个节点的SYS 用户口令均为 oracle
--节点1
SQL> show user;
USER is "SYS"
SQL> alter user sys identified by oracle;
User altered.
--节点2
SQL> show user;
USER is "SYS"
SQL> alter user sys identified by oracle;
User altered.
-- 查看生成的口令文件
[oracle@rac2 ~]$ cd $ORACLE_HOME/dbs
[oracle@rac2 dbs]$ ll
total 20
-rw-rw---- 1 oracle asmadmin 1544 Feb 10 08:26 hc_false2.dat
-rw-rw---- 1 oracle asmadmin 1544 Feb 10 16:06 hc_hisdb2.dat
-rw-r----- 1 oracle oinstall 37 Feb 10 08:59 inithisdb2.ora
-rw-r--r-- 1 oracle oinstall 2851 Feb 10 01:02 init.ora
-rw-r----- 1 oracle oinstall 1536 Feb 10 16:43 orapwhisdb2 --口令文件