1. 登录
disql sysdba/sysdba
2. 查看当前是否处于归档模式(在线热备必须处于归档模式)
SQL>select arch_mode from v$database;
LINEID ARCH_MODE
---------- ---------
1 N
3. 设置归档模式
1) 编辑
默认路径: /opt/dmdbms/data/DAMENG/
编辑该文件,设置: "ARCH_INI = 1"
2) 设置归档目录
mkdir /opt/dmdbms/data/DAMENG/arch
3) 配置 (/opt/dmdbms/data/DAMENG/)
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /opt/dmdbms/data/DAMENG/arch
ARCH_FILE_SIZE = 128 #归档文件大小限制Mb为单位,缺省128M
ARCH_SPACE_LIMIT = 0 #空间限制MB为单位,范围1024 ~ 4294967294,默认0表示无空间限制
4) 重启数据库生效
dmserver path=/opt/dmdbms/data/DAMENG/
或
/etc//DmServiceDMSERVER restart
重新查询,已生效
SQL>select arch_mode from v$database;
LINEID ARCH_MODE
---------- ---------
1 Y
4. create tablespace,user and test tables
1) query tablespace
SQL>SELECT , FROM V$TABLESPACE AS ts, V$DATAFILE AS df WHERE = df.GROUP_ID;
2) create tablespace
SQL>create tablespace duanbb DATAFILE '/opt/dmdbms/data/DAMENG/' SIZE 128;
3) create user
SQL>create user duanbb identified by duanbb default tablespace "DUANBB";
SQL>grant resource to DUANBB;
4) create tables
SQL>conn DUANBB/DUANBB
SQL>create table t1(ID NUMBER(10), NAME VARCHAR(30));
5. backup/restore
1) database full backup/restore
a) online backup
SQL>BACKUP DATABASE FULL TO full_bak BAKFILE '/test/duanbb/DM/backup/';
b) restore: 对于数据库级的还原只支持脱机还原,不提供联机还原的功能
/etc//DmServiceDMSERVER stop
./bin/dmrestore INI_PATH=/opt/dmdbms/data/DAMENG/ FILE=/test/duanbb/DM/backup/
/etc//DmServiceDMSERVER start
2) database increment backup/restore
a) online backup
SQL>BACKUP DATABASE INCREMENT WITH BACKUPDIR '/test/duanbb/DM/backup/' TO inc1 BAKFILE '/test/duanbb/DM/backup/';
b) restore to backup
/etc//DmServiceDMSERVER stop
./bin/dmrestore INI_PATH=/opt/dmdbms/data/DAMENG/ FILE=/test/duanbb/DM/backup/
/etc//DmServiceDMSERVER start
3) restore to assigned time point
/etc//DmServiceDMSERVER stop
./bin/dmrestore INI_PATH=/opt/dmdbms/data/DAMENG/ FILE=/test/duanbb/DM/backup/full_0816.bak TIME="2013-8-16 13:38:50" ARCHIVE_DIR=/opt/dmdbms/data/DAMENG/arch
/etc//DmServiceDMSERVER start
4) tablespace backup/restore
a) full backup/restore
backup:
SQL>BACKUP TABLESPACE duanbb FULL TO duanbb_full_bak BAKFILE '/test/duanbb/DM/backup/ts_duanbb_full.bak';
restore:
SQL>ALTER TABLESPACE duanbb OFFLINE;
SQL>RESTORE TABLESPACE duanbb FROM '/test/duanbb/DM/backup/ts_duanbb_full.bak';
SQL>ALTER TABLESPACE duanbb ONLINE;
b) increment backup/restore:
backup:
SQL>BACKUP TABLESPACE duanbb INCREMENT WITH BACKUPDIR '/test/duanbb/DM/backup' TO duanbb_inc1 BAKFILE '/test/duanbb/DM/backup/ts_duanbb_inc1.bak';
restore:
SQL>ALTER TABLESPACE duanbb OFFLINE;
SQL>RESTORE TABLESPACE duanbb FROM '/test/duanbb/DM/backup/ts_duanbb_inc1.bak';
SQL>ALTER TABLESPACE duanbb ONLINE;
5) parallel backup
user 'DUANBB', tablespace: 'DUANBB'
user 'DSG', tablespace: 'DSG'
a) create parallel backup configure file '/test/duanbb/DM/' as followed contents
[DUANBB]=/test/duanbb/DM/backup/duanbb
[DSG]=/test/duanbb/DM/backup/dsg
[default]=/test/duanbb/DM/backup
b) backup
full backup
SQL>BACKUP DATABASE FULL TO PARA_BAK_1 BAKFILE '/test/duanbb/DM/backup/' PARALLEL '/test/duanbb/DM/';
increment backup
SQL>BACKUP DATABASE INCREMENT WITH BACKUPDIR '/test/duanbb/DM/backup/' TO para_inc1 BAKFILE '/test/duanbb/DM/backup/para_inc1.bak';
c) restore
/etc//DmServiceDMSERVER stop
./bin/dmrestore INI_PATH=/opt/dmdbms/data/DAMENG/ FILE=/test/duanbb/DM/backup/
or
./bin/dmrestore INI_PATH=/opt/dmdbms/data/DAMENG/ FILE=/test/duanbb/DM/backup/ TIME="2013-8-19 11:28:00" ARCHIVE_DIR=/opt/dmdbms/data/DAMENG/arch
or
./bin/dmrestore INI_PATH=/opt/dmdbms/data/DAMENG/ FILE=/test/duanbb/DM/backup/ ARCHIVE_DIR=/opt/dmdbms/data/DAMENG/arch
/etc//DmServiceDMSERVER start
还要特别注意的是,如果该数据库自最近一次还原以来还没有进行过备份,则增量备份也无法进行,
这是因为考虑到系统的最近那一次的还原会使以前的备份对于当前系统都失效,鉴于这一点,系统管理员在每次系统还原后就立即作一次完全备份是一个很好的习惯。