HANA数据库备份查看和还原
1.检查trace文件
cat backup.log |grep "/usr/sap/HEQ/HDB00/backup/data/"
2.通过studio检查catalog
3.查看视图M_BACKUP_CATALOG ---complete data backup/incremental data backup/differential data backup
select*from"M_BACKUP_CATALOG"whereENTRY_TYPE_NAME='completedatabackup'andstate_name='successful'orderbysys_start_timedesc;
ENTRY_ID,ENTRY_TYPE_NAME,BACKUP_ID,SYS_START_TIME,UTC_START_TIME,SYS_END_TIME,UTC_END_TIME,STATE_NAME,COMMENT,MESSAGE,SYSTEM_ID1479879019957,"completedatabackup",1479879019957,"2016-11-2313:30:19.957000000","2016-11-2305:30:19.957000000","2016-11-2313:47:01.453000000","2016-11-2305:47:01.453000000","successful","","<ok>",""1479874724234,"completedatabackup",1479874724234,"2016-11-2312:18:44.234000000","2016-11-2304:18:44.234000000","2016-11-2312:33:37.222000000","2016-11-2304:33:37.222000000","successful","","<ok>",""1479872660066,"completedatabackup",1479872660066,"2016-11-2311:44:20.066000000","2016-11-2303:44:20.066000000","2016-11-2312:01:43.350000000","2016-11-2304:01:43.350000000","successful","","<ok>",""1479870313939,"completedatabackup",1479870313939,"2016-11-2311:05:13.939000000","2016-11-2303:05:13.939000000","2016-11-2311:22:28.214000000","2016-11-2303:22:28.214000000","successful","","<ok>",""1479869176913,"completedatabackup",1479869176913,"2016-11-2310:46:16.913000000","2016-11-2302:46:16.913000000","2016-11-2311:03:19.029000000","2016-11-2303:03:19.029000000","successful","","<ok>",""1479800886690,"completedatabackup",1479800886690,"2016-11-2215:48:06.690000000","2016-11-2207:48:06.690000000","2016-11-2216:04:25.923000000","2016-11-2208:04:25.923000000","successful","","<ok>",""1479110498231,"completedatabackup",1479110498231,"2016-11-1416:01:38.231000000","2016-11-1408:01:38.231000000","2016-11-1416:16:56.940000000","2016-11-1408:16:56.940000000","successful","","<ok>",""
4.如果想检查某一个备份是否OK可以这么做
hdbbackupcheck backup_filename
heqadm@ECQ:/usr/sap/HEQ/HDB00/backup/data/dbsqlbackup>hdbbackupcheck2016-11-23.complete_databackup_0_1Backup'/hana/shared/HEQ/HDB00/backup/data/dbsqlbackup/2016-11-23.complete_databackup_0_1'successfullychecked.heqadm@ECQ:/usr/sap/HEQ/HDB00/backup/data/dbsqlbackup>
hdbbackupcheck -v backup_filename 加v查看详细信息
还原数据库可以通过studio,下面是命令行还原过程:
1.To call recoverSys.py, enter the statement in the following format: HDBSettings.sh recoverSys.py
[<parameters>]
If you run HDBSettings.sh recoverSys.py without any parameters, recoverSys.py performs a
recovery to the most recent point in time
在HDB运行的时候删掉一个数据文件,做一个默认还原恢复
heqadm@ECQ:/usr/sap/HEQ/SYS/global/hdb/data/mnt00001/hdb00003>rm-rfdatavolume_0000.datheqadm@ECQ:/usr/sap/HEQ/HDB00/eccqas/trace>HDBSettings.shrecoverSys.py[140219726718720,0.002]>>startingrecoverSys(atThuNov2409:20:082016)[140219726718720,0.002]args:()[140219726718720,0.002]keys:{}ownpid:27909recoverSysstarted:2016-11-2409:20:08testingmaster:eccqaseccqasismastershutdowndatabase,timeoutis120stopsystemstopsystem:eccqasstoppingsystem:2016-11-2409:20:08stoppedsystem:2016-11-2409:20:59creatingfilerecoverInstance.sqlrestartdatabaserestartmasternameserver:2016-11-2409:21:04startsystem:eccqas2016-11-24T09:21:14+08:00P02806115893ec1ad5INFORECOVERYstateofservice:nameserver,eccqas:30001,volume:1,RecoveryExecuteTopologyAndSSFSRecoveryFinishedrecoverSysfinishedsuccessfully:2016-11-2409:21:15[140219726718720,66.334]0[140219726718720,66.334]<<endingrecoverSys,rc=0(RC_TEST_OK),after66.332secs
可以此时可以查看iostat-d1等待IO完成HDB自动开启发现,数据库已经恢复到最近正常状态Device:tpskB_read/skB_wrtn/skB_readkB_wrtnsda166.00151552.0016392.0015155216392Device:tpskB_read/skB_wrtn/skB_readkB_wrtnsda215.00187392.0032768.0018739232768Device:tpskB_read/skB_wrtn/skB_readkB_wrtnsda224.00201216.0027648.0020121627648Device:tpskB_read/skB_wrtn/skB_readkB_wrtnsda233.00217088.0021504.0021708821504Device:tpskB_read/skB_wrtn/skB_readkB_wrtnsda213.86176918.8140558.4217868840964Device:tpskB_read/skB_wrtn/skB_readkB_wrtnsda246.00216064.0035840.0021606435840Device:tpskB_read/skB_wrtn/skB_readkB_wrtnsda226.00193536.0037888.0019353637888
heqadm@ECQ:/usr/sap/HEQ/HDB00/eccqas/trace>sapcontrol-nr00-functionGetProcessList24.11.201609:41:56GetProcessListOKname,description,dispstatus,textstatus,starttime,elapsedtime,pidhdbdaemon,HDBDaemon,GREEN,Running,2016112409:21:05,0:20:51,28043hdbcompileserver,HDBCompileserver,GREEN,Running,2016112409:21:16,0:20:40,28131hdbindexserver,HDBIndexserver,GREEN,Running,2016112409:21:22,0:20:34,28200hdbnameserver,HDBNameserver,GREEN,Running,2016112409:21:06,0:20:50,28061hdbpreprocessor,HDBPreprocessor,GREEN,Running,2016112409:21:16,0:20:40,28134hdbwebdispatcher,HDBWebDispatcher,GREEN,Running,2016112409:41:20,0:00:36,28635hdbxsengine,HDBXSEngine,GREEN,Running,2016112409:21:22,0:20:34,28202heqadm@ECQ:/usr/sap/HEQ/HDB00/eccqas/trace>
2.指定文件,之前备份的命令是:"backupdatausingfile('$date.complete')"
那么还原的命令是:RECOVER DATA USING file ('2016-11-23.complete')
heqadm@ECQ:/usr/sap/HEQ/SYS/global/hdb/data/mnt00001/hdb00003>HDBSettings.shrecoverSys.py--command="RECOVERDATAUSINGfile('2016-11-23.complete')CLEARLOG"[139945440958208,0.002]>>startingrecoverSys(atThuNov2411:28:562016)[139945440958208,0.002]args:()[139945440958208,0.002]keys:{'command':"RECOVERDATAUSINGfile('2016-11-23.complete')CLEARLOG"}ownpid:30597recoverSysstarted:2016-11-2411:28:56testingmaster:eccqaseccqasismastershutdowndatabase,timeoutis120stopsystemstopsystem:eccqasstoppingsystem:2016-11-2411:28:56stoppedsystem:2016-11-2411:28:56creatingfilerecoverInstance.sqlrestartdatabaserestartmasternameserver:2016-11-2411:29:01startsystem:eccqas2016-11-24T11:29:11+08:00P03071715894613fe1INFORECOVERYstateofservice:nameserver,eccqas:30001,volume:1,RecoveryExecuteTopologyAndSSFSRecoveryFinishedrecoverSysfinishedsuccessfully:2016-11-2411:29:11[139945440958208,15.490]0[139945440958208,15.491]<<endingrecoverSys,rc=0(RC_TEST_OK),after15.489secsheqadm@ECQ:/usr/sap/HEQ/SYS/global/hdb/data/mnt00001/hdb00003>
The CLEAR LOG option prevents the recovery of entries from the log area. No log entries from the log area are replayed, and the log area is initialized. As a consequence, the content of the log area is lost.
If they are needed, the log entries from the log backups are replayed.
CLEAR LOG must be used in the following situations:
The log area is unusable.
You are recovering the database to a different system.
The CLEAR LOG command corresponds to theInitialize log areaoption inSAP HANAstudio.
3.查看可以还原恢复到哪个时间点
1821207 - Determining required recovery files
1705945 - Determining required restoration files
heqadm@ECQ:/hana/shared/HEQ/HDB00/backup/data/dbsqlbackup>hdbbackupdiag-f-d/hana/shared/HEQ/HDB00/backup/log/foundbackupcatalog1479887651122fromfile/hana/shared/HEQ/HDB00/backup/log/log_backup_0_0_0_0.1479887651122usingbackupcatalog1479887651122fromfile/hana/shared/HEQ/HDB00/backup/log/log_backup_0_0_0_0.14798876511222016-11-23.complete_databackup_0_12016-11-23.increment_databackup_incremental_0_1479887451566_0_12016-11-23.complete_databackup_1_12016-11-23.increment_databackup_incremental_1479879019957_1479887451566_1_12016-11-23.complete_databackup_2_12016-11-23.increment_databackup_incremental_1479879019957_1479887451566_2_12016-11-23.complete_databackup_3_12016-11-23.increment_databackup_incremental_1479879019957_1479887451566_3_1log_backup_1_0_1677888_1679488.1479887648977log_backup_2_0_11973184_11976576.1479887565796log_backup_3_0_4965350720_4965451904.1479887545567heqadm@ECQ:/hana/shared/HEQ/HDB00/backup/data/dbsqlbackup>
heqadm@ECQ:/hana/shared/HEQ/HDB00/backup/data/dbsqlbackup>hdbbackupdiag-d/hana/shared/HEQ/HDB00/backup/data/dbsqlbackup-b2016-11-23.complete_databackupBackupfile:/hana/shared/HEQ/HDB00/backup/data/dbsqlbackup/2016-11-23.complete_databackup_0_1Backuptime:2016-11-23T13:30:21+08:00Backupfile:/hana/shared/HEQ/HDB00/backup/data/dbsqlbackup/2016-11-23.complete_databackup_2_1Backuptime:2016-11-23T13:30:21+08:00RedoLogPosition:11925379Backupfile:/hana/shared/HEQ/HDB00/backup/data/dbsqlbackup/2016-11-23.complete_databackup_1_1Backuptime:2016-11-23T13:30:21+08:00RedoLogPosition:1652418Backupfile:/hana/shared/HEQ/HDB00/backup/data/dbsqlbackup/2016-11-23.complete_databackup_3_1Backuptime:2016-11-23T13:30:21+08:00RedoLogPosition:4942939522heqadm@ECQ:/hana/shared/HEQ/HDB00/backup/data/dbsqlbackup>
-rw-r-----1heqadmsapsys6483968Nov2315:54log_backup_3_0_4965350720_4965451904.1479887545567
heqadm@ECQ:/usr/sap/HEQ/HDB00/backup/log>HDBSettings.shrecoverSys.py--command="RECOVERDATABASEUNTILTIMESTAMP'2016-11-2315:54:00'CLEARLOG"[140447315224320,0.002]>>startingrecoverSys(atThuNov2414:11:262016)[140447315224320,0.002]args:()[140447315224320,0.002]keys:{'command':"RECOVERDATABASEUNTILTIMESTAMP'2016-11-2315:54:00'CLEARLOG"}ownpid:6290recoverSysstarted:2016-11-2414:11:26testingmaster:eccqaseccqasismastershutdowndatabase,timeoutis120stopsystemstopsystem:eccqasstoppingsystem:2016-11-2414:11:26stoppedsystem:2016-11-2414:11:26creatingfilerecoverInstance.sqlrestartdatabaserestartmasternameserver:2016-11-2414:11:31startsystem:eccqas2016-11-24T14:11:41+08:00P00641015894f606efINFORECOVERYstateofservice:nameserver,eccqas:30001,volume:1,RecoveryExecuteTopologyAndSSFSRecoveryFinishedrecoverSysfinishedsuccessfully:2016-11-2414:11:42[140447315224320,15.485]0[140447315224320,15.485]<<endingrecoverSys,rc=0(RC_TEST_OK),after15.483secsheqadm@ECQ:/usr/sap/HEQ/HDB00/backup/log>
可以指定备份和日志的目录
heqadm@ECQ:/usr/sap/HEQ/HDB00>HDBSettings.shrecoverSys.py--command="RECOVERDATABASEUNTILTIMESTAMP'2016-11-2315:54:00'CLEARLOGUSINGDATAPATH('/usr/sap/HEQ/HDB00/backup/data/dbsqlbackup/backup/')USINGLOGPATH('/usr/sap/HEQ/HDB00/backup/log/')"[140659884533504,0.002]>>startingrecoverSys(atThuNov2416:22:372016)[140659884533504,0.002]args:()[140659884533504,0.002]keys:{'command':"RECOVERDATABASEUNTILTIMESTAMP'2016-11-2315:54:00'CLEARLOGUSINGDATAPATH('/usr/sap/HEQ/HDB00/backup/data/dbsqlbackup/backup/')USINGLOGPATH('/usr/sap/HEQ/HDB00/backup/log/')"}ownpid:15906recoverSysstarted:2016-11-2416:22:37testingmaster:eccqaseccqasismastershutdowndatabase,timeoutis120stopsystemstopsystem:eccqasstoppingsystem:2016-11-2416:22:37stoppedsystem:2016-11-2416:22:37creatingfilerecoverInstance.sqlrestartdatabaserestartmasternameserver:2016-11-2416:22:42startsystem:eccqas2016-11-24T16:22:52+08:00P016026158956e207bINFORECOVERYstateofservice:nameserver,eccqas:30001,volume:1,RecoveryExecuteTopologyAndSSFSRecoveryFinishedrecoverSysfinishedsuccessfully:2016-11-2416:22:53[140659884533504,16.000]0[140659884533504,16.000]<<endingrecoverSys,rc=0(RC_TEST_OK),after15.998secsheqadm@ECQ:/usr/sap/HEQ/HDB00>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。