개요
Backup/Recovery 를 위한 계정으로 백업과 복구 관련된 모든 권한을 갖는 계정인 SYSBACKUP을 이용해
Tibero에서 제공되는 백업/복구 관리자인 tbrmgr backup/recovery를 수행하는 방법을 안내합니다.
방법
SYSBACKUP의 role, privileges 확인
1.
Privileges 조회
[tac1] SQL> select * from dba_sys_privs where grantee='SYSBACKUP';
GRANTEE PRIVILEGE ADMIN_OPTION
-------------------- ---------------------------------------- ------------
SYSBACKUP ALTER SYSTEM NO
SYSBACKUP CREATE SESSION NO
SYSBACKUP ALTER SESSION NO
SYSBACKUP CREATE TABLESPACE NO
SYSBACKUP ALTER TABLESPACE NO
SYSBACKUP DROP TABLESPACE NO
SYSBACKUP ALTER DATABASE NO
SYSBACKUP ALTER RMGR NO
8 rows selected.
SQL
복사
2.
Role 조회
[tac1] SQL> select * from dba_role_privs where grantee='SYSBACKUP';
GRANTEE GRANTED_ROLE ADMIN_OPTION DEFAULT_ROLE
-------------------- -------------------- ------------ ------------
SYSBACKUP SELECT_CATALOG_ROLE NO YES
1 row selected.
SQL
복사
3.
Role에 부여된 Privileges 조회
[tac1] SQL> SELECT GRANTEE, PRIVILEGE FROM DBA_SYS_PRIVS WHERE GRANTEE IN ('SELECT_CATALOG_ROLE');
GRANTEE PRIVILEGE
-------------------- ----------------------------------------
SELECT_CATALOG_ROLE SELECT ANY DICTIONARY
1 row selected.
SQL
복사
Full Backup을 이용한 Backup & Recovery
1.
샘플 스키마 생성, 샘플 데이터 insert
--샘플 Tablespace 생성
SQL>create tablespace test01 datafile '+DS0/tac/test01.dtf' size 100M autoextend off;
SQL
복사
--샘플 스키마 생성
SQL>create user test01 identified by test01 default tablespace test01;
SQL>grant connect, resource to test01;
SQL
복사
--샘플 데이터 insert
[tac1] SQL>conn test01/test01
[tac1] SQL>create table t (col number);
[tac1] SQL>BEGIN
FOR I IN 1..1000
LOOP
INSERT INTO t
SELECT LEVEL
FROM dual
CONNECT BY LEVEL <= 10;
END LOOP;
COMMIT;
END;
/
SQL
복사
-- 데이터 확인
[tac1] SQL> select count(*) from t;
COUNT(*)
----------
10000
1 row selected.
SQL
복사
2.
tbrmgr Full Backup 수행
--tablespace와 datafile 확인
[tac1] SQL>col DF_NAME format a40
[tac1] SQL>col TS_NAME format a15
[tac1] SQL>SELECT a.name as DF_NAME, b.name as TS_NAME, a.FILE#, b.TS#
FROM v$datafile a
JOIN v$tablespace b
ON a.TS#=b.TS# ;
DF_NAME TS_NAME FILE# TS#
---------------------------------------- --------------- ---------- ----------
+DS0/tac/system01/system01.dtf SYSTEM 0 0
+DS0/tac/system01/undo0_01.dtf UNDO0 1 1
+DS0/tac/system01/usr01.dtf USR 2 3
+DS0/tac/system01/tpr01.dtf SYSSUB 3 4
+DS0/tac/system02/undo1_01.dtf UNDO1 4 5
+DS0/tac/test01.dtf TEST01 5 6
6 rows selected.
SQL
복사
--tbrmgr full backup 수행
$ tbrmgr backup --userid sysbackup/tibero@tac1 -o /home/tibero/backup -w
==============================================================================
= Recovery Manager(RMGR) starts =
= =
= TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. =
==============================================================================
archive log check succeeded
RMGR '-o' option used
: backing up to /home/tibero/backup
==============================================================================
RMGR - Backup (FULL)
==============================================================================
Initializing the backup progress, it may take few minutes...
BACKUP (set_id: 1, ts_id: 0, df_id: 0)
100.0% |===============================>| 38400/38400 blks 0.00s
Synchronizing...
BACKUP (set_id: 1, ts_id: 1, df_id: 1)
100.0% |===============================>| 12800/12800 blks 0.00s
Synchronizing...
BACKUP (set_id: 1, ts_id: 3, df_id: 2)
100.0% |===============================>| 12800/12800 blks 0.00s
Synchronizing...
BACKUP (set_id: 1, ts_id: 4, df_id: 3)
100.0% |===============================>| 12800/12800 blks 0.00s
Synchronizing...
BACKUP (set_id: 1, ts_id: 5, df_id: 4)
100.0% |===============================>| 38400/38400 blks 0.00s
Synchronizing...
BACKUP (set_id: 1, ts_id: 6, df_id: 5)
100.0% |===============================>| 12800/12800 blks 0.00s
Synchronizing...
Switching an online logfile...
Backing up archive logfiles...
Archivelog log-tac1-t0-r0-s8.arc (thread: 0, set_id: 1, low_tsn: 198541, next_tsn: 202169) backed up
Archivelog log-tac1-t1-r0-s6.arc (thread: 1, set_id: 1, low_tsn: 198541, next_tsn: 202169) backed up
Archive logfiles backup succeeded
Backing up the control file...
Control file backup succeeded
Database backup succeeded
RMGR backup ends
SQL
복사
3.
장애 상황 유발을 위해 tablespace 제거
--TAS의 경우 DB가 기동 중인 상황에서는 datafile 삭제 불가능하여 DB down
$ cmrctl stop db --name tac1 --option immediate
$ cmrctl stop db --name tac2 --option immediate
SQL
복사
--TAS에 접속하여 test01.dtf 데이터 파일 삭제
[15:01]ASCMD +DS0/tac> ls
c1.ctl
c2.ctl
system01/
system02/
archive/
.passwd
test01.dtf
Number of files found: 7
[15:01]ASCMD +DS0/tac> rm test01.dtf
Removing file: +DS0/tac/test01.dtf
SQL
복사
4.
tbrmgr Recovery 수행
--DB 기동하여 장애 상황 확인
$ cmrctl start db --name tac1
BOOT SUCCESS! (MODE : MOUNT)
sys.log 확인 시
********************************************************
* Critical Warning : Raise svmode failed. The reason is
* TBR-1024 : Database needs media recovery: open failed(+DS0/tac/test01.dtf).
* Current server mode is MOUNT.
********************************************************
SQL
복사
--tbrmgr recovery 수행
$ tbrmgr recover --userid sysbackup/tibero@tac1 -o /home/tibero/backup -w
==============================================================================
= Recovery Manager(RMGR) starts =
= =
= TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. =
==============================================================================
RMGR '-o' option used
: restoring from /home/tibero/backup
==============================================================================
RMGR - recovery (WITH ARCHIVELOG)
==============================================================================
CM information
===========================================================
CM NAME : cm1
CM UI PORT : 18629
RESOURCE FILE PATH : /cm/cmresource
CM MODE : GUARD ON, FENCE OFF, ROOT ON
LOG LEVEL : 2
CM BLOCK SIZE : 512
===========================================================
Trying to shutdown other instances
=============================== SUCCESS! ===============================
Succeeded to request at the local node to stop the service.
Please use "cmrctl show service" command to verify the result.
=======================================================================
Shutdown succeeded
Shutting down the instance...
tbdown failed. proc info file is deleted.
Hint: Please check if the tbsvr instance was already stopped.
info file is deleted.
unlink failed.: No such file or directory
Control file #0 (+DS0/tac/c1.ctl) is accessible
Control file #1 (+DS0/tac/c2.ctl) is accessible
All control files are accessible. No need to restore the backup control file.
Booting up the instance...
Change core dump dir to /db/tibero7/bin/prof.
Listener port = 8629
Tibero 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Tibero instance started up (MOUNT mode).
Initializing the restore progress, it may take few minutes...
RMGR begins restoring backup files.
Full backup set_id: 1
Last incremental backup set_id: 1
RESTORE (set_id: 1, ts_id: 0, df_id: 0) - FULL BACKUP
100.0% |===============================>| 38400/38400 blks 2.01s
Synchronizing...
RESTORE (set_id: 1, ts_id: 1, df_id: 1) - FULL BACKUP
100.0% |===============================>| 12800/12800 blks 0.00s
Synchronizing...
RESTORE (set_id: 1, ts_id: 3, df_id: 2) - FULL BACKUP
100.0% |===============================>| 12800/12800 blks 0.00s
Synchronizing...
RESTORE (set_id: 1, ts_id: 4, df_id: 3) - FULL BACKUP
100.0% |===============================>| 12800/12800 blks 0.00s
Synchronizing...
RESTORE (set_id: 1, ts_id: 5, df_id: 4) - FULL BACKUP
100.0% |===============================>| 38400/38400 blks 1.04s
Synchronizing...
RESTORE (set_id: 1, ts_id: 6, df_id: 5) - FULL BACKUP
100.0% |===============================>| 12800/12800 blks 0.00s
Synchronizing...
Settling...
Restoring logfiles...
Archivelog log-tac1-t0-r0-s8.arc (thread: 0, set_id: 1, low_tsn: 198541, next_tsn: 202169) restored
Archivelog log-tac1-t1-r0-s6.arc (thread: 1, set_id: 1, low_tsn: 198541, next_tsn: 202169) restored
Archive logfiles restoration succeeded
Database restoration succeeded
Given recovery point: COMPLETE RECOVERY
Recoverable point using only backup archivelogs: change 202168
recoverSQL: ALTER DATABASE RECOVER AUTOMATIC
Database automatic recovery succeeded
Shutting down the instance...
Tibero instance terminated (NORMAL mode).
Booting up the instance...
Change core dump dir to /db/tibero7/bin/prof.
Listener port = 8629
Tibero 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Tibero instance started up (NORMAL mode).
RMGR recovery ends
SQL
복사
5.
데이터 확인
--데이터 확인
[tac1] SQL> conn test01/test01
Connected to Tibero.
[tac1] SQL> select count(*) from t;
COUNT(*)
----------
10000
1 row selected
SQL
복사
참고
tbrmgr을 이용한 백업본 삭제 방법 입니다.
--tbrmgr을 이용하여 백업본 삭제
$ tbrmgr delete -b 1 --userid sysbackup/tibero@tac1
==============================================================================
= Recovery Manager(RMGR) starts =
= =
= TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. =
==============================================================================
archive log check succeeded
RMGR '-o' option not used
: deleting from the path actually backed up previously
==============================================================================
RMGR - delete
==============================================================================
1 out of 1 backup_sets erased
RMGR delete ends
SQL
복사