【脚本】Oracle控制文件移动增加删除多路复用

Oracle维护控制文件Controlfile相关脚本(移动增加删除多路复用操作)

 

-- 1-当数据库使用PFILE参数文件时,使用该方式维护控制文件
-- 1.1查看当前数据库使用的参数文件类型

SQL> SHOW PARAMETER PFILE;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /home/oracle/product/11gR2/dbs/spfileora11g.ora

 

SQL> SHOW PARAMETER SPFILE;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /home/oracle/product/11gR2/dbs/spfileora11g.ora

 
-- 1.2查看当前的数据库控制文件布局状况

SQL> SELECT NAME FROM V$CONTROLFILE;
 
NAME
--------------------------------------------------------------------------------
/home/oracle/product/oradata/ora11g/control01.ctl
/home/oracle/product/fast_recovery_area/ora11g/control04.ctl
/home/oracle/product/oradata/ora11g/control02.ctl
/home/oracle/product/oradata/ora11g/control03.ctl
/home/oracle/backup/controlfile/control05.ctl
/home/oracle/backup/controlfile/control06.ctl
/home/oracle/backup/controlfile/control07.ctl
 
7 rows selected

 

SQL> SELECT VALUE FROM V$PARAMETER WHERE NAME = 'control_files';
 
VALUE
--------------------------------------------------------------------------------
/home/oracle/product/oradata/ora11g/control01.ctl, /home/oracle/product/fast_rec

 
-- 1.3关闭数据库并且修改动态参数文件PFILE(如果当前数据库使用的PFILE参数文件)

SQL> shutdown immediate

 

control_files=("/home/oracle/product/oradata/ora11g/control01.ctl", 
               "/home/oracle/product/fast_recovery_area/ora11g/control04.ctl",
               "/home/oracle/product/oradata/ora11g/control02.ctl",
               "/home/oracle/product/oradata/ora11g/control03.ctl",
               "/home/oracle/backup/controlfile/control05.ctl",
               "/home/oracle/backup/controlfile/control06.ctl")

 
-- 1.4在操作系统层面多路复制控制文件,使得和规划相一致

$ cp /home/oracle/product/oradata/ora11g/control01.ctl 
     /home/oracle/product/oradata/ora11g/control02.ctl
$ cp /home/oracle/product/oradata/ora11g/control01.ctl 
     /home/oracle/product/oradata/ora11g/control03.ctl
$ cp /home/oracle/product/oradata/ora11g/control01.ctl 
     /home/oracle/backup/controlfile/control05.ctl
$ cp /home/oracle/product/oradata/ora11g/control01.ctl 
     /home/oracle/backup/controlfile/control06.ctl
$ cp /home/oracle/product/oradata/ora11g/control01.ctl 
     /home/oracle/backup/controlfile/control07.ctl

 
-- 1.5使用PFILE参数文件启动数据库

SQL> STARTUP PFILE = '/home/oracle/product/admin/ora11g/pfile/init.ora';

 
-- 1.6根据PFILE参数文件创建SPFILE文件

SQL> CREATE SPFILE FROM PFILE;

 
-- 1.7使用静态参数文件重启数据库

SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP

 
-- 2-当数据库使用SPFILE参数文件时,使用该方式维护控制文件
-- 2.1查看当前数据库使用的参数文件类型

SQL> SHOW PARAMETER PFILE;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /home/oracle/product/11gR2/dbs/spfileora11g.ora

 

SQL> SHOW PARAMETER SPFILE;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /home/oracle/product/11gR2/dbs/spfileora11g.ora

 
-- 2.2查看当前的数据库控制文件布局状况

SQL> SELECT NAME FROM V$CONTROLFILE;
 
NAME
--------------------------------------------------------------------------------
/home/oracle/product/oradata/ora11g/control01.ctl
/home/oracle/product/fast_recovery_area/ora11g/control04.ctl
/home/oracle/product/oradata/ora11g/control02.ctl
/home/oracle/product/oradata/ora11g/control03.ctl
/home/oracle/backup/controlfile/control05.ctl
/home/oracle/backup/controlfile/control06.ctl
/home/oracle/backup/controlfile/control07.ctl
 
7 rows selected

 
-- 2.3使用ALTER SYSTEM命令以SYS DBA用户修改控制文件信息

ALTER SYSTEM SET control_files = '/home/oracle/product/oradata/ora11g/control01.ctl',
                                 '/home/oracle/product/fast_recovery_area/ora11g/control04.ctl',
                                 '/home/oracle/product/oradata/ora11g/control02.ctl',
                                 '/home/oracle/product/oradata/ora11g/control03.ctl',
                                 '/home/oracle/backup/controlfile/control05.ctl',
                                 '/home/oracle/backup/controlfile/control06.ctl',
                                 '/home/oracle/backup/controlfile/control07.ctl'
                                 SCOPE = spfile;

                                 
-- 2.4关闭数据库

SQL> SHUTDOWN IMMEDIATE;

 
-- 2.5在操作系统层面多路复制控制文件,使得和规划相一致

$ cp /home/oracle/product/oradata/ora11g/control01.ctl 
     /home/oracle/product/oradata/ora11g/control02.ctl
$ cp /home/oracle/product/oradata/ora11g/control01.ctl 
     /home/oracle/product/oradata/ora11g/control03.ctl
$ cp /home/oracle/product/oradata/ora11g/control01.ctl 
     /home/oracle/backup/controlfile/control05.ctl
$ cp /home/oracle/product/oradata/ora11g/control01.ctl 
     /home/oracle/backup/controlfile/control06.ctl
$ cp /home/oracle/product/oradata/ora11g/control01.ctl 
     /home/oracle/backup/controlfile/control07.ctl

 
-- 2.6启动数据库并根据SPFILE创建PFILE

SQL> STARTUP;
SQL> CREATE PFILE FROM SPFILE;

 

你可能感兴趣的:(oracle,脚本,控制文件,多路复用)