2007年6月7日星期四

Oracle学习笔记-2007-01-17

1. 查看归档状态
>select log_mode from v$database;
>archive log list ;

2. 切换归档状态
>shutdown immediate;
>startup mount;
>alter database archivelog(noarchivelog)
>alter database open;
>archive log list;
3. 应用pfile修改
>create pfile from spfile
修改pfile(:\oracle\product\10.1.0\Db_1\database\INITtonydb.ORA)
>create spfile from pfile
or
>show all(parameters parametername)
>alter system set parameter=valuse;
4. 指定 pfile 启动
>shutdown immediate;
>startup pfile="";
5. 手动归档
>archive log all;
6. 数据库冷备份
备份
>select name from v$datafile;
%
09>shutdown immediate;
>$copy ... 复制目标文件
>startup;
恢复
恢复数据库的唯一方法是,从冷备份文件中恢复所有数据库文件,以使数据库处于一致状态
7. 数据库热备份
备份
>alter tablespace system begin backup;
>$copy ...
>alter tablespace system end backup;
恢复
>alter database datafile 'D:\ORACLE\PRODUCT\10.1.0\ORADATA\TONYDB\SYSTEM01.DBF' offline;
>alter database open;
>$copy ...
>recover datafile 'D:\ORACLE\PRODUCT\10.1.0\ORADATA\TONYDB\SYSTEM01.DBF'
>alter database datafile 'D:\ORACLE\PRODUCT\10.1.0\ORADATA\TONYDB\SYSTEM01.DBF' online;
>alter database open
8. 分析备份文件的可用性
F:\>dbv file=f:\SYSTEM01.DBF blocksize=8192
9. 控制文件备份
> alter database backup controlfile to trace;
==
> D:\oracle\product\10.1.0\admin\tonydb\udump\tonydb_ora_xxxx.trc
10. 表空间状态的切换
> alter tablespace read only;
> alter tablespace read write;
11. 数据库不完整恢复
基于取消
>startup mount;
>recover database until cancel;
基于时间
>startup mount;
>recover database until time '2000-01-01:01:01:01';//YYYY-MM-DD:HH:MI:SS
12. RMAN
cmd> rman
RMAN> connect target / //与默认目标数据库建立连接
RMAN> show all;
RMAN> configure retention policy clear; //恢复默认设置
13. RMAN backup
RMAN> report need backup;
RMAN> run {
allocate channel c1 type disk; //信道名和设备类型
backup full //备份类型
format 'd:\backup\%d_%p_%t' //文件格式
(tablespace system //备份对象
include current controlfile);} //备份对象
注: backup {full|incremental level=n|archivelog all|database} //archivelog
backup {database} //noarchivelog
14. RMAN 使用copy 备份
RMAN> run{
allocate channel c1 type disk;
copy level 0
datafile 1 to 'd:\2222\systemimg.dbf';} //4 指定文件, 可以使用 report schema 获取
15. RMAN restore
RMAN> run {
allocate channel c1 type disk;
restore database;
recover database;
}
16. RMAN 不完整恢复
基于时间
RMAN> run {
allocate channel c1 type disk;
set until time 'DD MON YYYY HH: MI: SS';
restore database;
recover database;
}
17. RMAN 维护
RMAN> crosscheck backup of database;
RMAN> crosscheck copy of database;
RMAN> list backup of database;
RMAN> list copy of database;
RMAN> change backupset i {unavailable|unavailable};
18. exp 与 imp
19. SQL*Loader
20. 服务器配置
.\oracle\product\10.1.0\Db_1\NETWORK\ADMIN\listener.ora
SID_LIST_LISTENER = //指定侦听SID, 指定监听服务器列表
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.1.0\Db_1)
(PROGRAM = extproc)
)
)
LISTENER = //LISTENER定义
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = TONYBOX)(PORT = 1521))
)
21. 客户端配置
.\oracle\product\10.1.0\Db_1\NETWORK\ADMIN\sqlnet.ora

没有评论: