服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > 数据库技术 > Oracle技术 > DBA > 查看文档

oracle dba的工作列表上写了些什么?

  在数据库关闭状态与进行。将所有的数据文件、重演日志文件及控制文件拷贝到磁盘。空闲的时间再将备份移到磁带上。
数据库管理员(dba)的主要工作


启动和关闭数据库

一)     启动数据库
$ svrmgrl
svrmgr> connect internal     (实例启动)
svrmgr> startup

二)     关闭数据库
$ svrmgrl
svrmgr> connect internal    
svrmgr> shutdown [immediate/abort]
immediate:正在访问数据库的会话被完全终止、资源有序释放后才关闭       数据库。
abort: 会话立即中止,数据库立即关闭。
备份与恢复

一)     逻辑备份与恢复(即卸库与装库)
1.     卸库:export
不带参数:
$ cd $oracle_home/bin
$ exp

username: cwadmin
password:
connected to: oracle8 enterprise edition release 8.0.4.0.0 - production
pl/sql release 8.0.4.0.0 - production
enter array fetch buffer size: 4096 >
export file: expdat.dmp > pzexdat.dmp

(1)     e(ntire database), (2)u(sers), or (3)t(ables): (2)u > 1
    export grants (yes/no): yes > y
    export table data (yes/no): yes > y
    compress extents (yes/no): yes >y
    export 工作开始自动进行最终出现:
    export terminated successfully without warnings.
   

    带参数,可选参数如下(可用exp help=y 得到):

    keyword description (default)     keyword     description (default)
---------------------------------------------------------------------------------------------------
userid   username/password       full       export entire file (n)
buffer   size of data buffer       owner     list of owner usernames
file   output file (expdat.dmp)   tables     list of table names
compress import into one extent (y)   recordlength length of io record
grants   export grants (y)         inctype     incremental export type
indexes export indexes (y)       record     track incr. export (y)
rows   export data rows (y)       parfile     parameter filename
constraints export constraints (y)   consistent   cross-table consistency
log     log file of screen output   statistics   analyze objects (estimate)
direct   direct path (n)
feedback display progress every x rows (0)
point_in_time_recover   tablespace point-in-time recovery (n)
recovery_tablespaces   list of tablespace names to recover
volsize number of bytes to write to each tape volume

例:$exp userid=cwadmin/cwadmin tables=’(sys_cwxx,sys_menu)’ file=pzexport.dmp

2.     装库:

不带参数
$ cd $oracle_home/bin
$ imp

username: cwadmin
password:
connected to: oracle8 enterprise edition release 8.0.4.0.0 - production
pl/sql release 8.0.4.0.0 - production
import file: expdat.dmp > pzexdat.dmp
enter insert buffer size (minimum is 4096) 30720> 10240

export file created by export:v08.00.04 via conventional path
list contents of import file only (yes/no): no >

ignore create error due to object existence (yes/no): no > y
import grants (yes/no):yes > y
import table data (yes/no):yes >y
import entire export file (yes/no):no >y
    import 工作开始自动进行最终出现:
    import terminated successfully with warnings.

带参数,可选参数如下(可用imp help=y 得到):

keyword description (default)     keyword     description (default)
---------------------------------------------------------------------------------------------------
userid   username/password       full     import entire file (n)
buffer   size of data buffer       fromuser   list of owner usernames
file   input file (expdat.dmp)   touser     list of usernames
show   just list file contents (n)   tables     list of table names
ignore   ignore create errors (n)   recordlength   length of io record
grants   import grants (y)       inctype     incremental import type
indexes import indexes (y)       commit     commit array insert (n)
rows   import data rows (y)     parfile     parameter filename
log     log file of screen output
destroy overwrite tablespace data file (n)
indexfile write table/index info to specified file
charset character set of export file (nls_lang)
point_in_time_recover tablespace point-in-time recovery (n)
skip_unusable_indexes skip maintenance of unusable indexes (n)
analyze execute analyze statements in dump file (y)
feedback display progress every x rows(0)
volsize number of bytes in file on each volume of a file on tape  

例:$imp userid=cwadmin/cwadmin tables=’(sys_dwxx, sys_menu)’ file=pzexdat.dmp

二)     物理备份与恢复
1.     冷备份与热备份
冷备份
在数据库关闭状态与进行。将所有的数据文件、重演日志文件及控制文件拷贝到磁盘。空闲的时间再将备份移到磁带上。
    (1)可通过:svrmgr> select * from v$logfile;
              select * from v$dbfile;
              select * from v$control.file;
    这些语句来了解数据文件、重演日志文件及控制文件的相应位置及名称。
(2)利用$cp 命令来拷贝:
  例:$cp /u01/u02/pz_ts.ora /dbfile_b/

热备份
数据库必须工作在“archivelog”方式下
可利用svrmgr> archive log list 语句来查归档日志状态

  若在“noarchivelog”方式下,进行转换
  svrmgr> connect internal      
  svrmgr> shutdown immediate     ---关闭数据库---
  svrmgr> startup mount   ---为暂停日志方式转换准备数据库---
  svrmgr> alter database archivelog; ---转换---
  svrmgr> alter database open;     ---打开数据库---
 
  拷贝
  1> 将一个表空间置为备份方式
    svrmgr> alter tablespace pzts begin backup;
  2> 拷贝
    svrmgr>$cp /u01/u02/pz_ts.ora /dbfile_b/
  3> 取消该表备份方式
      svrmgr>alter tablespace pzts end backup;
  利用以上3步,将所有表空间下的数据文件进行备份
  4> 拷贝控制文件
  5> 拷贝归档重演日志

2.     恢复
        磁盘出现故障,数据库自行关闭。
(1)     将驻留在磁盘上的备份拷贝到其他磁盘或磁带上
(2)     执行  
        svrmgr> connect internal
        svrmgr> startup mount
        svrmgr> alter database open;
  会出现错误信息,提示需要恢复
(3)     执行
            svrmgr> recover database
        根据提示,自动恢复
(4)     执行
            svrmgr>alter database open
        恢复完成,数据库打开。

扫描关注微信公众号