使用DataDomain BoostFS保护大型Oracle数据库

Oracle 合成增量备份:

DataDomain BoostFS 提供源端压缩去重能力:

一、配置DD6300:

user add boostfs role none password <你的密码>
ddboost user assign boostfs
ddboost storage-unit create unit_boostfs user boostfs
ddboost storage-unit show
mtree list

二、数据库服务器配置:

操作系统:Oracle Linux 8.2
数据库版本:Oracle 19.3

实验环境拓扑图:

三、安装Oracle 19.3数据库

# 1、配置本地YUM源
mount /dev/cdrom /media
echo "[local]
name=local
baseurl=file:///media/BaseOS
enable=1
gpgcheck=0 " > /etc/yum.repos.d/local.repo

# 2、安装一些必要的工具
yum  -y  install net-tools vim wget unzip zip

# 3、配置操作系统内核参数
echo "
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 4194304
kernel.shmmax = 17179869183
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144 
net.core.wmem_max = 1048586   
" >> /etc/sysctl.d/99-sysctl.conf
sysctl -p

# 4、配置/etc/security/limits.conf
echo "oracle  soft nproc 2048
oracle  hard nproc 16384
oracle  soft nofile 4096
oracle  hard nofile 65536" >> /etc/security/limits.conf

# 5、配置/etc/pam.d/login
echo "
session  required  /lib64/security/pam_limits.so
session  required  pam_limits.so" >> /etc/pam.d/login

# 6、配置/etc/profile
echo "
if [ \$USER = \"oracle\" ];then
        if [ \$SHELL = \"/bin/ksh\" ];then
                ulimit -p 16384
                ulimit -n 65536
        else
                ulimit -u 16384 -n 65536
        fi
fi" >> /etc/profile
source /etc/profile

# 7、利用YUM安装oracle数据库需要的依赖包
yum -y install make
yum -y install libnsl
yum -y install compat-libcap1
yum -y install libstdc++-devel
yum -y install gcc-c++
yum -y install ksh
yum -y install glibc-devel
yum -y install libaio-devel

# 8、创建组(oinstall,dba)、用户(oracle) 以及用户密码
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba -p 'oracle' -d /home/oracle oracle
echo 'oracle:oracle1234' | chpasswd

# 9、配置/u01存储:
fdisk /dev/sdb
mkfs.xfs /dev/sdb1
mkdir /u01
mount /dev/sdb1 /u01
echo "/dev/sdb1               /u01                    xfs     defaults        0 0" >> /etc/fstab

# 10、创建Oracle数据库相关的目录并赋予相对应的权限
mkdir -p /u01/app/oracle/product/19.3.0
mkdir -p /home/{OracleData,OracleArch/ArchiveLog,OracleBackup/{rmanbak,expdpbak,ArchiveLogBak}}
chown -R oracle:oinstall  /u01/app/   /home/Oracle*
chmod -R  775  /u01/app/   /home/Oracle*

# 11、配置Oracle用户的环境变量:/home/oracle/.bash_profile
echo "
# alias sqlplus='rlwrap sqlplus'
# alias rman='rlwrap rman'
export TMP=/tmp
export TMPDIR=\$TMP
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/19.3.0
export EDITOR=/usr/bin/vim
export ORACLE_SID=BOOST
export PATH=\$ORACLE_HOME/bin:/usr/bin:\$PATH
export PATH=\$PATH:/usr/bin/:/bin:/usr/bin/X11:/usr/local/bin
export PATH=\$PATH:\$ORACLE_BASE/common/oracle/bin
export ORACLE_TERM=xterm
export TNS_ADMIN=\$ORACLE_HOME/network/admin
export ORA_NLS10=\$ORACLE_HOME/nls/data
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/lib:/usr/lib:/usr/local/lib:\$ORACLE_HOME/oracm/lib:\$ORACLE_HOME/lib
export LIBPATH=\$LIBPATH:\$ORA_CRS_HOME/lib:\$ORACLE_HOME/lib 
export CLASSPATH=\$CLASSPATH:\$ORACLE_HOME/rdbms/jlib:\$ORACLE_HOME/jlib:\$ORACLE_HOME/network/jlib:\$ORACLE_HOME/JRE 
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_DATE_FORMAT='yyyy-MM-dd hh24:mi:ss'
" >> /home/oracle/.bash_profile

# 12、上传Oracle软件包,并安装Oracle 19.3数据库软件
xhost +

su - oracle
export DISPLAY=:0.0
export CV_ASSUME_DISTID=RHEL7.6
unset LANG
unzip LINUX.X64_193000_db_home.zip -d /u01/app/oracle/product/19.3.0/
cd /u01/app/oracle/product/19.3.0/
.runInstaller &

四、挂载 BoostFS 文件系统:

4.1、安装DDBoostFS-7.10.0.0-1017960.rhel.x86_64.rpm

DDBoostFS-7.10.0.0-1017960.rhel.x86_64.rpm
默认安装到 /opt/emc/boostfs/

[root@localhost ~]# rpm -ivh DDBoostFS-7.10.0.0-1017960.rhel.x86_64.rpm 
准备中...                          ################################# [100%]
正在升级/安装...
   1:ddboostfs-7.8.0.0-1007848        ################################# [100%]
[root@localhost ~]# 

4.2、注册DD6300存储单元

/opt/emc/boostfs/bin/boostfs lockbox set -d 100.1.2.151 -s unit_boostfs -u boostfs

4.3、新建挂载点/boostfs,挂载DD6300

mkdir /boostfs
chown oracle:oinstall /boostfs
/opt/emc/boostfs/bin/boostfs mount -d 100.1.2.151 -s unit_boostfs /boostfs

4.4、卸载DD6300

/opt/emc/boostfs/bin/boostfs umount /boostfs

4.5、挂载 unit_boostfs 存储单元,创建相应的备份目录

su - oracle
/opt/emc/boostfs/bin/boostfs mount -d 100.1.2.151 -s unit_boostfs -o security=lockbox /boostfs

mkdir -p /boostfs/cora1/BOOST/FULL
mkdir -p /boostfs/cora1/BOOST/ARCH
mkdir -p /boostfs/cora1/BOOST/CONTROL
mkdir -p /boostfs/cora1/BOOST/SNAPSHOT
mkdir -p /boostfs/cora1/BOOST/INCR

ls -l /boostfs/cora1/BOOST

4.6、配置重新启动自动挂载:

cat "100.1.2.151:/unit_boostfs /boostfs boostfs umask=0000,user,_netdev 0 0" >> /etc/fstab

五、执行第一次全备份 (L0)

5.1、执行备份:BACKUP AS COPY INCREMENTAL LEVEL 0

rman target /
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE COMPRESSION ALGORITHM 'BASIC';
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY PARALLELISM 4; 
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/boostfs/cora1/BOOST/CONTROL/%d_%F.ctl';
show all;

run {
    sql 'ALTER SYSTEM SWITCH LOGFILE';
    BACKUP AS COPY INCREMENTAL LEVEL 0 TAG "INCR_MERGE" DATABASE format '/boostfs/cora1/BOOST/FULL/%d_TS_%N_FNO_%f.bkp';
    sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
    backup archivelog all format '/boostfs/cora1/BOOST/ARCH/%d_Archive_%u.arlog' not backed up 1 times;
}

5.2、查看存储单元 unit_boostfs 的消重压缩比

sysadmin@dd6300# ddboost storage-unit show compression unit_boostfs

List of files in unit_boostfs and their compression info:

cora1:
Total files: 9;  bytes/storage_used: 3.4
        Logical Bytes:        1,909,814,784
       Original Bytes:        1,916,518,928
  Globally Compressed:        1,759,704,259
   Locally Compressed:          551,732,643
            Meta-data:            7,482,852

六、生成第一次全备(L0)的快照复制

###6.1、在DD6300上操作:

sysadmin@dd6300# filesys fastcopy source /data/col1/unit_boostfs/cora1/BOOST/FULL destination /data/col1/unit_boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL
(00:00) Waiting for fastcopy to complete...
Fastcopy status: fastcopy /data/col1/unit_boostfs/cora1/BOOST/FULL to /data/col1/unit_boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL: copied 4 files, 1 directory in 0.00 seconds
sysadmin@dd6300# 

或者在数据库服务器上操作:

ssh fastcopy@100.1.2.151 filesys fastcopy source /data/col1/unit_boostfs/cora1/BOOST/FULL destination /data/col1/unit_boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL

6.2、在数据库服务器主机端查看

ls -l /boostfs/cora1/BOOST/SNAPSHOT

6.3、在DD6300上查看空间消耗,消重压缩比:

sysadmin@dd6300# ddboost storage-unit show compression unit_boostfs

List of files in unit_boostfs and their compression info:

cora1:
Total files: 13;  bytes/storage_used: 6.8
        Logical Bytes:        3,776,312,832
       Original Bytes:        3,789,469,494
  Globally Compressed:        1,759,704,259
   Locally Compressed:          551,732,643
            Meta-data:            7,483,460

我们可以看到物理容量根本没有增加,而逻辑大小增加了,提供了6.8:1的去重复和压缩好处。
注意:全局压缩(Globally Compressed)是重复数据删除的影响,本地压缩(Locally Compressed)是上述值中的压缩影响。

6.4、下一步是在Oracle中编目此备份,以便它可以用于Oracle未来的任何恢复过程。快照备份被标记为“cora1_BOOST_1_FIRST_FULL”

rman target /

catalog datafilecopy '/boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL/BOOST_TS_SYSAUX_FNO_3.bkp' TAG='cora1_BOOST_1_FIRST_FULL' ;

catalog datafilecopy '/boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL/BOOST_TS_SYSTEM_FNO_1.bkp' TAG='cora1_BOOST_1_FIRST_FULL' ;

catalog datafilecopy '/boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL/BOOST_TS_UNDOTBS1_FNO_4.bkp' TAG='cora1_BOOST_1_FIRST_FULL' ;

catalog datafilecopy '/boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL/BOOST_TS_USERS_FNO_7.bkp' TAG='cora1_BOOST_1_FIRST_FULL' ;

RMAN Catalog现在有每个数据库文件的两个备份副本的记录,因此带有“INCR MERGE”标记的原始备份现在可以用于Oracle增量合并备份。

RMAN> list copy;
specification does not match any control file copy in the repository
List of Datafile Copies
=======================

Key     File S Completion Time     Ckp SCN    Ckp Time            Sparse
------- ---- - ------------------- ---------- ------------------- ------
6       1    A 2022-12-05 20:14:57 2054301    2022-12-05 19:51:26 NO    
        Name: /boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL/BOOST_TS_SYSTEM_FNO_1.bkp
        Tag: CORA1_BOOST_1_FIRST_FULL

4       1    A 2022-12-05 19:51:33 2054301    2022-12-05 19:51:26 NO    
        Name: /boostfs/cora1/BOOST/FULL/BOOST_TS_SYSTEM_FNO_1.bkp
        Tag: INCR_MERGE

5       3    A 2022-12-05 20:14:50 2054302    2022-12-05 19:51:26 NO    
        Name: /boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL/BOOST_TS_SYSAUX_FNO_3.bkp
        Tag: CORA1_BOOST_1_FIRST_FULL

3       3    A 2022-12-05 19:51:31 2054302    2022-12-05 19:51:26 NO    
        Name: /boostfs/cora1/BOOST/FULL/BOOST_TS_SYSAUX_FNO_3.bkp
        Tag: INCR_MERGE

7       4    A 2022-12-05 20:14:57 2054303    2022-12-05 19:51:26 NO    
        Name: /boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL/BOOST_TS_UNDOTBS1_FNO_4.bkp
        Tag: CORA1_BOOST_1_FIRST_FULL

2       4    A 2022-12-05 19:51:29 2054303    2022-12-05 19:51:26 NO    
        Name: /boostfs/cora1/BOOST/FULL/BOOST_TS_UNDOTBS1_FNO_4.bkp
        Tag: INCR_MERGE

8       7    A 2022-12-05 20:14:58 2054304    2022-12-05 19:51:26 NO    
        Name: /boostfs/cora1/BOOST/SNAPSHOT/1_FIRST_FULL/BOOST_TS_USERS_FNO_7.bkp
        Tag: CORA1_BOOST_1_FIRST_FULL

1       7    A 2022-12-05 19:51:27 2054304    2022-12-05 19:51:26 NO    
        Name: /boostfs/cora1/BOOST/FULL/BOOST_TS_USERS_FNO_7.bkp
        Tag: INCR_MERGE

6.5、手动安装 HR Schema in 19c

[oracle@cora1 1_FIRST_FULL]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Dec 5 20:24:36 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> @?/demo/schema/human_resources/hr_main.sql

specify password for HR as parameter 1:
Enter value for 1: hr

specify default tablespeace for HR as parameter 2:
Enter value for 2: users

specify temporary tablespace for HR as parameter 3:
Enter value for 3: temp

specify log path as parameter 4:
Enter value for 4: $ORACLE_HOME/demo/schema/log/


PL/SQL procedure successfully completed.


# <省略信息...>


Commit complete.


PL/SQL procedure successfully completed.

SQL> 

SQL> SELECT table_name FROM dba_tables where owner='HR';

TABLE_NAME
--------------------------------------------------------------------------------
COUNTRIES
REGIONS
LOCATIONS
DEPARTMENTS
JOBS
EMPLOYEES
JOB_HISTORY

7 rows selected.

七、使用OIM执行增量合并备份(L1)

在执行增量备份之前,让我们通过创建一个新表test_table来生成一些更改

sqlplus / as sysdba

create table test_table as select * from hr.EMPLOYEES where rownum < 200 ;

Select count(*) from test_table;

下一步是执行增量备份(到/INCR目录),并将增量更改与标记名为“INCR_MERGE”的前一次完全备份合并(出现在/ full目录中)。
为了完整性,我们还将Archive日志备份到/ARCH目录。

rman target /
run {
    sql 'ALTER SYSTEM SWITCH LOGFILE';
    BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG "INCR_MERGE" DATABASE format '/boostfs/cora1/BOOST/INCR/%d_INCR_%U.bkp';
    RECOVER COPY OF DATABASE WITH TAG "INCR_MERGE";
    sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';

    backup archivelog all format '/boostfs/cora1/BOOST/ARCH/%d_Archive_%u.arlog' not backed up 1 times;
}

using target database control file instead of recovery catalog
sql statement: ALTER SYSTEM SWITCH LOGFILE

Starting backup at 2022-12-05 20:32:21
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=863 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=985 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=1104 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=1226 device type=DISK
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/BOOST/system01.dbf
channel ORA_DISK_1: starting piece 1 at 2022-12-05 20:32:22
channel ORA_DISK_2: starting incremental level 1 datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/BOOST/sysaux01.dbf
channel ORA_DISK_2: starting piece 1 at 2022-12-05 20:32:22
channel ORA_DISK_3: starting incremental level 1 datafile backup set
channel ORA_DISK_3: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/BOOST/undotbs01.dbf
channel ORA_DISK_3: starting piece 1 at 2022-12-05 20:32:22
channel ORA_DISK_4: starting incremental level 1 datafile backup set
channel ORA_DISK_4: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/BOOST/users01.dbf
channel ORA_DISK_4: starting piece 1 at 2022-12-05 20:32:22
channel ORA_DISK_1: finished piece 1 at 2022-12-05 20:32:25
piece handle=/boostfs/cora1/BOOST/INCR/BOOST_INCR_0a1el4im_1_1.bkp tag=INCR_MERGE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_2: finished piece 1 at 2022-12-05 20:32:25
piece handle=/boostfs/cora1/BOOST/INCR/BOOST_INCR_0b1el4im_1_1.bkp tag=INCR_MERGE comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_3: finished piece 1 at 2022-12-05 20:32:25
piece handle=/boostfs/cora1/BOOST/INCR/BOOST_INCR_0c1el4im_1_1.bkp tag=INCR_MERGE comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_4: finished piece 1 at 2022-12-05 20:32:25
piece handle=/boostfs/cora1/BOOST/INCR/BOOST_INCR_0d1el4im_1_1.bkp tag=INCR_MERGE comment=NONE
channel ORA_DISK_4: backup set complete, elapsed time: 00:00:03
Finished backup at 2022-12-05 20:32:25

Starting recover at 2022-12-05 20:32:25
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00004 name=/boostfs/cora1/BOOST/FULL/BOOST_TS_UNDOTBS1_FNO_4.bkp
channel ORA_DISK_1: reading from backup piece /boostfs/cora1/BOOST/INCR/BOOST_INCR_0c1el4im_1_1.bkp
channel ORA_DISK_2: starting incremental datafile backup set restore
channel ORA_DISK_2: specifying datafile copies to recover
recovering datafile copy file number=00007 name=/boostfs/cora1/BOOST/FULL/BOOST_TS_USERS_FNO_7.bkp
channel ORA_DISK_2: reading from backup piece /boostfs/cora1/BOOST/INCR/BOOST_INCR_0d1el4im_1_1.bkp
channel ORA_DISK_3: starting incremental datafile backup set restore
channel ORA_DISK_3: specifying datafile copies to recover
recovering datafile copy file number=00001 name=/boostfs/cora1/BOOST/FULL/BOOST_TS_SYSTEM_FNO_1.bkp
channel ORA_DISK_3: reading from backup piece /boostfs/cora1/BOOST/INCR/BOOST_INCR_0a1el4im_1_1.bkp
channel ORA_DISK_4: starting incremental datafile backup set restore
channel ORA_DISK_4: specifying datafile copies to recover
recovering datafile copy file number=00003 name=/boostfs/cora1/BOOST/FULL/BOOST_TS_SYSAUX_FNO_3.bkp
channel ORA_DISK_4: reading from backup piece /boostfs/cora1/BOOST/INCR/BOOST_INCR_0b1el4im_1_1.bkp
channel ORA_DISK_2: piece handle=/boostfs/cora1/BOOST/INCR/BOOST_INCR_0d1el4im_1_1.bkp tag=INCR_MERGE
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: restore complete, elapsed time: 00:00:02
channel ORA_DISK_1: piece handle=/boostfs/cora1/BOOST/INCR/BOOST_INCR_0c1el4im_1_1.bkp tag=INCR_MERGE
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_DISK_3: piece handle=/boostfs/cora1/BOOST/INCR/BOOST_INCR_0a1el4im_1_1.bkp tag=INCR_MERGE
channel ORA_DISK_3: restored backup piece 1
channel ORA_DISK_3: restore complete, elapsed time: 00:00:04
channel ORA_DISK_4: piece handle=/boostfs/cora1/BOOST/INCR/BOOST_INCR_0b1el4im_1_1.bkp tag=INCR_MERGE
channel ORA_DISK_4: restored backup piece 1
channel ORA_DISK_4: restore complete, elapsed time: 00:00:04
Finished recover at 2022-12-05 20:32:30

Starting Control File and SPFILE Autobackup at 2022-12-05 20:32:30
piece handle=/boostfs/cora1/BOOST/CONTROL/BOOST_c-337355871-20221205-02.ctl comment=NONE
Finished Control File and SPFILE Autobackup at 2022-12-05 20:32:31

sql statement: ALTER SYSTEM ARCHIVE LOG CURRENT

Starting backup at 2022-12-05 20:32:32
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=6 RECID=1 STAMP=1122619885
channel ORA_DISK_2: starting archived log copy
input archived log thread=1 sequence=9 RECID=7 STAMP=1122622341
channel ORA_DISK_3: starting archived log copy
input archived log thread=1 sequence=10 RECID=8 STAMP=1122669152
channel ORA_DISK_4: starting archived log copy
input archived log thread=1 sequence=7 RECID=2 STAMP=1122666703
output file name=/boostfs/cora1/BOOST/ARCH/BOOST_Archive_0f1el4j0.arlog RECID=12 STAMP=1122669152
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=8 RECID=3 STAMP=1122666703
output file name=/boostfs/cora1/BOOST/ARCH/BOOST_Archive_0g1el4j0.arlog RECID=13 STAMP=1122669152
channel ORA_DISK_2: archived log copy complete, elapsed time: 00:00:01
channel ORA_DISK_2: starting archived log copy
input archived log thread=1 sequence=11 RECID=9 STAMP=1122669152
output file name=/boostfs/cora1/BOOST/ARCH/BOOST_Archive_0h1el4j0.arlog RECID=10 STAMP=1122669152
channel ORA_DISK_3: archived log copy complete, elapsed time: 00:00:01
output file name=/boostfs/cora1/BOOST/ARCH/BOOST_Archive_0i1el4j0.arlog RECID=11 STAMP=1122669152
channel ORA_DISK_4: archived log copy complete, elapsed time: 00:00:01
output file name=/boostfs/cora1/BOOST/ARCH/BOOST_Archive_0j1el4j1.arlog RECID=14 STAMP=1122669153
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
output file name=/boostfs/cora1/BOOST/ARCH/BOOST_Archive_0k1el4j1.arlog RECID=15 STAMP=1122669153
channel ORA_DISK_2: archived log copy complete, elapsed time: 00:00:01
Finished backup at 2022-12-05 20:32:34

Starting Control File and SPFILE Autobackup at 2022-12-05 20:32:34
piece handle=/boostfs/cora1/BOOST/CONTROL/BOOST_c-337355871-20221205-03.ctl comment=NONE
Finished Control File and SPFILE Autobackup at 2022-12-05 20:32:35

RMAN> 

让我们看看增量之后,我们向DD6300中添加了多少物理存储容量去备份。

sysadmin@dd6300# ddboost storage-unit show compression unit_boostfs

List of files in unit_boostfs and their compression info:

cora1:
Total files: 25;  bytes/storage_used: 7.2
        Logical Bytes:        3,870,417,408
       Original Bytes:        4,177,289,774
  Globally Compressed:        2,101,012,327
   Locally Compressed:          572,094,273
            Meta-data:            8,970,680

八、执行增量合并全量备份(L1)的快照拷贝

下一步是保存对/INCR目录执行的OIM备份的副本,该副本已更新为/ full目录中的上一个完全备份。
以下步骤在/ snapshot目录下创建/FULL目录的快照,名为2_SECOND_FULL。
在DD6300上操作:

sysadmin@dd6300# filesys fastcopy source /data/col1/unit_boostfs/cora1/BOOST/FULL destination /data/col1/unit_boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL
Fastcopy status: fastcopy /data/col1/unit_boostfs/cora1/BOOST/FULL to /data/col1/unit_boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL: copied 4 files, 1 directory in 0.00 seconds

也可以在数据库服务器上操作:

ssh fastcopy@10.20.0.03 filesys fastcopy source /data/col1/unit_boostfs/cora1/BOOST/FULL destination /data/col1/unit_boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL

快照目录下存在增量合并的第二次完全备份的快照副本。这个备份现在拥有以前创建的表(TEST_TABLE)的副本。

[oracle@cora1 FULL]$ ls -l /boostfs/cora1/BOOST/SNAPSHOT
总用量 1
drwxr-xr-x 2 oracle oinstall 398 12月  5 19:51 1_FIRST_FULL
drwxr-xr-x 2 oracle oinstall 398 12月  5 19:51 2_SECOND_FULL
[oracle@cora1 FULL]$ ls -l /boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL/
总用量 114562
-rw-r----- 1 oracle oinstall 566239232 12月  5 20:32 BOOST_TS_SYSAUX_FNO_3.bkp
-rw-r----- 1 oracle oinstall 943726592 12月  5 20:32 BOOST_TS_SYSTEM_FNO_1.bkp
-rw-r----- 1 oracle oinstall 361766912 12月  5 20:32 BOOST_TS_UNDOTBS1_FNO_4.bkp
-rw-r----- 1 oracle oinstall   5251072 12月  5 20:32 BOOST_TS_USERS_FNO_7.bkp
[oracle@cora1 FULL]$

现在我们已经创建了完整备份的第二个副本,让我们检查Data Domain内的空间消耗。

sysadmin@dd6300# ddboost storage-unit show compression unit_boostfs

List of files in unit_boostfs and their compression info:

cora1:
Total files: 29;  bytes/storage_used: 10.9
        Logical Bytes:        5,747,401,216
       Original Bytes:        6,353,802,552
  Globally Compressed:        2,101,012,327
   Locally Compressed:          572,094,273
            Meta-data:            8,971,288

物理容量消耗保持不变,效率提高到10.9:1 (16.5GB的备份使用大约1GB的物理容量,展示了重复数据删除的威力)。

下一步是在Oracle中编目此备份,以便它可以用于Oracle未来的任何恢复过程。快照备份被标记为“cora1_BOOST_2_SECOND_FULL”。

rman target / 

catalog datafilecopy '/boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL/BOOST_TS_SYSAUX_FNO_3.bkp' TAG='cora1_BOOST_2_SECOND_FULL' ;

catalog datafilecopy '/boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL/BOOST_TS_SYSTEM_FNO_1.bkp' TAG='cora1_BOOST_2_SECOND_FULL' ;

catalog datafilecopy '/boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL/BOOST_TS_UNDOTBS1_FNO_4.bkp' TAG='cora1_BOOST_2_SECOND_FULL' ;

catalog datafilecopy '/boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL/BOOST_TS_USERS_FNO_7.bkp' TAG='cora1_BOOST_2_SECOND_FULL' ;

九、Oracle增量备份恢复场景

下一节演示使用前面执行的FULL和OIM FULL备份的恢复场景。

9.1、删除一部分记录:

create table hr.test_table as select * from hr.EMPLOYEES where rownum < 100001 ;

Select count(*) from hr.test_table;

Select count(*) from hr.test_table where EMPLOYEE_ID > 120;

delete hr.test_table where EMPLOYEE_ID > 120;

Select count(*) from hr.test_table;

commit;

9.2、正在恢复数据库数据文件的丢失

对于这个恢复测试,将使用RMAN恢复和恢复命令删除并恢复File #7 (users01.dbf)文件。

rm -i /u01/app/oracle/oradata/BOOST/users01.dbf

rman target /

CONFIGURE DEVICE TYPE SBT_TAPE CLEAR;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY PARALLELISM 1;

run {
    shutdown abort;
    startup mount;
    restore datafile 7;
    recover datafile 7;
    alter database open;
}


# <以下为输出信息>
Oracle instance shut down

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area   10032773208 bytes

Fixed Size                    12445784 bytes
Variable Size               1577058304 bytes
Database Buffers            8422162432 bytes
Redo Buffers                  21106688 bytes

Starting restore at 2022-12-05 20:52:12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=736 device type=DISK

channel ORA_DISK_1: restoring datafile 00007
input datafile copy RECID=16 STAMP=1122669925 file name=/boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL/BOOST_TS_USERS_FNO_7.bkp
destination for restore of datafile 00007: /u01/app/oracle/oradata/BOOST/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00007, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/BOOST/users01.dbf RECID=0 STAMP=0
Finished restore at 2022-12-05 20:52:14

Starting recover at 2022-12-05 20:52:14
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 2022-12-05 20:52:14

Statement processed

RMAN> 

由于每个Full和OIM备份都在Oracle中被快照和编目,RMAN能够直接从最新的备份快照(2_SECOND_FULL)恢复被删除的文件,以恢复被删除的数据文件。

十、在BoostFS上使用数据库备份的“Live Mount”恢复数据库对象(表)的丢失

为了演示此功能,将从“BOOST”数据库中删除先前创建的表(TEST_TABLE),并在ISNAPSHOT目录中创建一个2_SECOND_FULL快照作为“TEST”。
然后将使用TEST快照同时启动名为“TEST”的数据库,并将TEST_TABLE从“TEST”数据库导出并导入回“BOOST”数据库。
最后,"TEST"数据库将被关闭,其快照目录/文件将被删除。

使用数据库 Live Mount来恢复表数据库流程图:

10.1、Drop table TEST_TABLE from BOOST database

[oracle@cora1 ~]$ ps -ef|grep pmon
oracle     29116       1  0 21:06 ?        00:00:00 ora_pmon_BOOST
oracle     29740   26820  0 21:11 pts/3    00:00:00 grep --color=auto pmon
[oracle@cora1 ~]$ ORACLE_SID=BOOST sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Dec 5 21:11:36 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> drop table hr.test_table;

Table dropped.

10.2、为Live Mount,创建一个2_SECOND_FULL的快照作,并命名为TEST

ls -l /boostfs/cora1/BOOST/SNAPSHOT


# 在DD上操作:
sysadmin@dd6300# filesys fastcopy source /data/col1/unit_boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL destination /data/col1/unit_boostfs/cora1/BOOST/SNAPSHOT/TEST
Fastcopy status: fastcopy /data/col1/unit_boostfs/cora1/BOOST/SNAPSHOT/2_SECOND_FULL to /data/col1/unit_boostfs/cora1/BOOST/SNAPSHOT/TEST: copied 4 files, 1 directory in 0.00 seconds


[oracle@cora1 SNAPSHOT]$ ls -l /boostfs/cora1/BOOST/SNAPSHOT
总用量 2
drwxr-xr-x 2 oracle oinstall 398 12月  5 19:51 1_FIRST_FULL
drwxr-xr-x 2 oracle oinstall 398 12月  5 19:51 2_SECOND_FULL
drwxr-xr-x 2 oracle oinstall 398 12月  5 19:51 TEST
[oracle@cora1 SNAPSHOT]$ ls -l /boostfs/cora1/BOOST/SNAPSHOT/TEST
总用量 114562
-rw-r----- 1 oracle oinstall 566239232 12月  5 20:45 BOOST_TS_SYSAUX_FNO_3.bkp
-rw-r----- 1 oracle oinstall 943726592 12月  5 20:45 BOOST_TS_SYSTEM_FNO_1.bkp
-rw-r----- 1 oracle oinstall 361766912 12月  5 20:45 BOOST_TS_UNDOTBS1_FNO_4.bkp
-rw-r----- 1 oracle oinstall   5251072 12月  5 20:45 BOOST_TS_USERS_FNO_7.bkp
[oracle@cora1 SNAPSHOT]$ 

10.3、查看创建TEST快照对DataDomain容量的影响

sysadmin@dd6300# ddboost storage-unit show compression unit_boostfs

List of files in unit_boostfs and their compression info:

cora1:
Total files: 33;  bytes/storage_used: 14.7
        Logical Bytes:        7,624,385,024
       Original Bytes:        8,530,528,792
  Globally Compressed:        2,101,119,058
   Locally Compressed:          572,169,703
            Meta-data:            8,972,472
sysadmin@dd6300# 

10.4、使用前面创建的/TEST快照启动一个新的“TEST”数据库

创建一个小型的init.ora文件,将被用来启动“TEST”oracle实例,InitTEST.ora的内容如下:

cat /tmp/TEST/initTEST.ora
#
# Init.ora file with min parameters to startup TEST
#
*.db_block_size=8192
*.db_domain=''
*.db_name='TEST'
*.control_files='/tmp/TEST/TEST_control01.ctl'
*.audit_file_dest='/tmp/TEST/'
*.audit_trail='db'
*.db_create_file_dest='/tmp/TEST/'
*.db_recovery_file_dest='/tmp/TEST/'
*.diagnostic_dest='/tmp/TEST/'
*.db_recovery_file_dest_size=8589934592
*._allow_resetlogs_corruption=TRUE
*._allow_error_simulation=TRUE
*.remote_login_passwordfile='EXCLUSIVE'
*.compatible='19.0.0.0.0'
*.shared_pool_size=5037351920

使用/tmp/TEST/initTEST.ora启动TEST Oracle数据库。使用/boostfs文件系统/TEST snapshot目录下的数据库文件创建一个新的控制文件,并打开数据库(Live Mount)。

ORACLE_SID=TEST sqlplus / as sysdba

startup nomount pfile=/tmp/TEST/initTEST.ora

CREATE CONTROLFILE REUSE SET DATABASE "TEST" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 512
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/tmp/TEST/TEST_redo01.log' SIZE 5M BLOCKSIZE 512 reuse,
GROUP 2 '/tmp/TEST/TEST_redo02.log' SIZE 5M BLOCKSIZE 512 reuse,
GROUP 3 '/tmp/TEST/TEST_redo03.log' SIZE 5M BLOCKSIZE 512 reuse
DATAFILE
'/boostfs/cora1/BOOST/SNAPSHOT/TEST/BOOST_TS_SYSAUX_FNO_3.bkp',
'/boostfs/cora1/BOOST/SNAPSHOT/TEST/BOOST_TS_SYSTEM_FNO_1.bkp',
'/boostfs/cora1/BOOST/SNAPSHOT/TEST/BOOST_TS_UNDOTBS1_FNO_4.bkp',
'/boostfs/cora1/BOOST/SNAPSHOT/TEST/BOOST_TS_USERS_FNO_7.bkp';



SQL> ALTER DATABASE OPEN RESETLOGS;

Database altered.

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/boostfs/cora1/BOOST/SNAPSHOT/TEST/BOOST_TS_USERS_FNO_7.bkp
/boostfs/cora1/BOOST/SNAPSHOT/TEST/BOOST_TS_UNDOTBS1_FNO_4.bkp
/boostfs/cora1/BOOST/SNAPSHOT/TEST/BOOST_TS_SYSTEM_FNO_1.bkp
/boostfs/cora1/BOOST/SNAPSHOT/TEST/BOOST_TS_SYSAUX_FNO_3.bkp

SQL> Select count(*) from hr.test_table;

  COUNT(*)
----------
       107

[oracle@cora1 SNAPSHOT]$ ps -ef | grep pmon
oracle     29116       1  0 21:06 ?        00:00:00 ora_pmon_BOOST
oracle     31037       1  0 21:30 ?        00:00:00 ora_pmon_TEST
oracle     31610   26820  0 21:31 pts/3    00:00:00 grep --color=auto pmon

现在有两个数据库运行“TEST”实例Live Mounted on /boostfs (DD6300)。
数据库的副本在第二次备份中,“TEST_TABLE”是完整的,因此可以导出和导入回“BOOST”数据库。
完成后,TEST oracle实例被关闭,快照被删除。

10.5、从“TEST”数据库导出TEST_TABLE到“BOOST”数据库,并清理掉TEST数据库

# 1、从 TEST 实例中导出 hr.test_table
[oracle@cora1 ~]$ ORACLE_SID=TEST exp file=test.dmp tables=hr.test_table rows=y

Export: Release 19.0.0.0.0 - Production on Mon Dec 5 21:34:28 2022
Version 19.3.0.0.0

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


Username: / as sysdba

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
server uses AL32UTF8 character set (possible charset conversion)

About to export specified tables via Conventional Path ...
Current user changed to HR
. . exporting table                     TEST_TABLE        107 rows exported
EXP-00091: Exporting questionable statistics.
Export terminated successfully with warnings.


# 22、将从 TEST 实例中导出 hr.test_table,导入BOOST数据库中
[oracle@cora1 ~]$ ORACLE_SID=BOOST imp file=test.dmp full=y

Import: Release 19.0.0.0.0 - Production on Mon Dec 5 21:36:08 2022
Version 19.3.0.0.0

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

Username: / as sysdba

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

Export file created by EXPORT:V19.00.00 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
IMP-00403: 

Warning: This import generated a separate SQL file "import_sys" which contains DDL that failed due to a privilege issue.

. importing SYS's objects into SYS
. importing HR's objects into HR
. . importing table                   "TEST_TABLE"        107 rows imported
Import terminated successfully with warnings.
[oracle@cora1 ~]$ 


# 3、查验导入的 hr.test_table
[oracle@cora1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Dec 5 21:36:27 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> select count(*) from hr.test_table;

  COUNT(*)
----------
       107


# 4、关闭 TEST 实例,删除TEST快照
[oracle@cora1 ~]$ ORACLE_SID=TEST sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Dec 5 21:37:11 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> shut abort
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@cora1 ~]$ rm -rf /boostfs/cora1/BOOST/SNAPSHOT/TEST/
[oracle@cora1 ~]$ 

十一、其他

11.1、如何设置远程ssh执行DataDomain的快速复制(fastcopy)

通过ssh为快速复制设置DataDomain远程登录
步骤1:ssh连接到DataDomain,并创建一个具有管理员级别访问权限的新数据域用户(例如:fastcopy)

user add fastcopy password <你的密码> role limited-admin force-password-change no
user password aging set fastcopy max-days-between-change 99999

步骤2:在linux上以oracle用户登录,允许远程访问上面创建的Fastcopy用户:

ssh-keygen -t ecdsa

注意:创建一个新文件 /home/oracle/.ssh/id_ecdsa.pub

ssh fastcopy@100.1.2.151 adminaccess add ssh-keys < /home/oracle/.ssh/id_ecdsa.pub

11.2、参考文献

带有BoostFS的OIM脚本示例一组执行Oracle增量合并的通用脚本已经在Github的以下位置提供。
这些脚本是参数驱动的(参数文件是00_set_environment.inc),可以用于备份和实时挂载Oracle数据库。
https://github.com/ozprem/BoostFS_OIM

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注