通过冷备重建控制文件创建数据库

1.创建prof_$ORACLE_SID文件:
 prof_gs30xn prof_gs30xa

eg:
stty erase "^H"
umask 022
ORACLE_SID=gs30xa
ORACLE_BASE=/paic/stg/oracle/10g/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2.0
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
ORA_NLS10=$ORACLE_HOME/nls/data
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$ORACLE_HOME/bin:/usr/sbin:/usr/local/bin:/usr/ccs/bin:$PATH
NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"
export PS1 ORACLE_SID ORACLE_BASE ORACLE_HOME NLS_LANG ORA_NLS10 LD_LIBRARY_PATH NLS_DATE_FORMAT
export PATH
PS1="`hostname`:10g:$ORACLE_SID > "
TERM=vt100;export TERM
#SHELL_PATH=/etc/paic/shell; export SHELL_PATH
TEMP=$HOME/tmp
export TEMP
EDITOR=vi
export EDITOR

 


2.建立相关的路径,将$SID替换成你要建库的sid,如gs30xa
cd $ORACLE_BASE/admin
mkdir $SID
mkdir $ORACLE_BASE/admin/$SID/adump 
mkdir $ORACLE_BASE/admin/$SID/bdump 
mkdir $ORACLE_BASE/admin/$SID/cdump
mkdir $ORACLE_BASE/admin/$SID/udump

3.创建并修改 init 配置文件,也可根据现有的文件创建
cd $ORACLE_HOME/dbs
vi initgs30xa.ora
然后输入如下内容:注意:不要有多余的空格、换行符!db_name='gxa0'要先写成生产的sid,等修改好控制文件后再改成开发测试库的sid!!
###########################################################################
*._log_archive_callout='local_first=true'
*._trace_files_public=TRUE
*.aq_tm_processes=0
*.archive_lag_target=3600
*.audit_file_dest='/paic/stg/oracle/10g/app/oracle/admin/gs30xa/adump'
*.audit_trail='NONE'
*.background_dump_dest='/paic/stg/oracle/10g/app/oracle/admin/gs30xa/bdump'
*.compatible='10.2.0.3'
*.control_files='/paic/s2cs5020/stg/cx2/oradata/gs30xa/control01.ctl','/paic/s2cs5020/stg/cx2/oradata/gs30xa/control02.ctl','/paic/s2cs5020/stg/cx2/oradata/gs30xa/control03.ctl'
*.core_dump_dest='/paic/stg/oracle/10g/app/oracle/admin/gs30xa/cdump'
*.db_block_size=8192
*.db_cache_size=82880000
*.db_domain='world'
*.db_name='gxa0'
*.java_pool_size=50000000
*.job_queue_processes=0
*.large_pool_size=60663296
*.log_archive_max_processes=10
*.log_buffer=10485760
*.O7_DICTIONARY_ACCESSIBILITY=FALSE
*.open_cursors=600
*.open_links=10
*.os_authent_prefix=''
*.pga_aggregate_target=60M
*.processes=320
*.resource_limit=TRUE
*.sga_target=500M
*.shared_pool_size=250000000
*.undo_management='AUTO'
*.undo_retention=86400
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/paic/stg/oracle/10g/app/oracle/admin/gs30xa/udump'
*.utl_file_dir=''
#######################################################################


4.应用prof_gs30xa文件:
cd
. ./prof_gs30xa
sqlplus / as sysdba
startup mount

5.修改controlfile:
exit
cd $ORACLE_BASE/admin/gs30xa/udump
sqlplus / as sysdba
alter database backup controlfile to trace;
shutdown immediate;
exit
ls -ltr
(然后复制最下面即最新时间点产生的trace文件名,如gs30xa_ora_10564.trc)
cp gs30xa_ora_10564.trc control.sql  (利用trace文件生成重建controlfile的脚本)
vi control.sql
只抽取如下部分,其余行都删掉:
##STARTUP NOMOUNT
##CREATE CONTROLFILE set DATABASE "GS30XA" RESETLOGS FORCE LOGGING  NOARCHIVELOG
##    MAXLOGFILES 32
##    MAXLOGMEMBERS 3
##    MAXDATAFILES 500
##    MAXINSTANCES 8
##    MAXLOGHISTORY 2336
##LOGFILE
##  GROUP 1 '/paic/xa/gbs/redo/oradata/gxa0/redo01.log'  SIZE 50M,
##  GROUP 2 '/paic/xa/gbs/redo/oradata/gxa0/redo02.log'  SIZE 50M,
##  GROUP 3 '/paic/xa/gbs/redo/oradata/gxa0/redo03.log'  SIZE 50M,
##  GROUP 4 '/paic/xa/gbs/redo/oradata/gxa0/redo04.log'  SIZE 50M,
##  GROUP 5 '/paic/xa/gbs/redo/oradata/gxa0/redo05.log'  SIZE 50M,
##  GROUP 6 '/paic/xa/gbs/redo/oradata/gxa0/redo06.log'  SIZE 50M,
##  GROUP 7 '/paic/xa/gbs/redo/oradata/gxa0/redo07.log'  SIZE 50M,
##  GROUP 8 '/paic/xa/gbs/redo/oradata/gxa0/redo08.log'  SIZE 50M,
##  GROUP 9 '/paic/xa/gbs/redo/oradata/gxa0/redo09.log'  SIZE 50M,
##  GROUP 10 '/paic/xa/gbs/redo/oradata/gxa0/redo10.log'  SIZE 50M,
##  GROUP 11 '/paic/xa/gbs/redo/oradata/gxa0/redo11.log'  SIZE 50M,
##  GROUP 12 '/paic/xa/gbs/redo/oradata/gxa0/redo12.log'  SIZE 50M
##-- STANDBY LOGFILE
##DATAFILE
##  '/paic/xa/gbs/data/oradata/gxa0/system01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/undotbs01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/sysaux01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/users01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/auddata01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/abbsdata01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/abbsindx01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/dbadata01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/dmlbakdata01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/i3_orcl01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbs01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbs02.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbs03.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbs04.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsbak01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsbase01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsindex01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsindex02.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbslogtmpdata01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbslogtmpidx01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsrep01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsrept01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsusers01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gresv01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gresvdata01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gresvidx01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/tools01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsindex03.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsmisindex01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsmis01.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/gbsindex04.dbf',
##  '/paic/xa/gbs/data/oradata/gxa0/dmlbakdata02.dbf'
##CHARACTER SET ZHS16GBK
##;

需要修改的地方有:
(1)CREATE CONTROLFILE set DATABASE "GS30XA" RESETLOGS FORCE LOGGING  NOARCHIVELOG
注意:::
将old“ REUSE DATABASE "GXA0"” 改为new“ SET DATABASE "GS30XA"”
将old“ NORESETLOGS  NOARCHIVELOG” 改为new“ RESETLOGS FORCE LOGGING  NOARCHIVELOG”
(2)将路径都改为新datafile的路径,最好拷到UE中改,改好后重新拷到文件中
old LOGFILE:
  GROUP 1 '/paic/xa/gbs/redo/oradata/gxa0/redo01.log'  SIZE 50M,
  GROUP 2 '/paic/xa/gbs/redo/oradata/gxa0/redo02.log'  SIZE 50M,
  GROUP 3 '/paic/xa/gbs/redo/oradata/gxa0/redo03.log'  SIZE 50M,
  GROUP 4 '/paic/xa/gbs/redo/oradata/gxa0/redo04.log'  SIZE 50M,
  GROUP 5 '/paic/xa/gbs/redo/oradata/gxa0/redo05.log'  SIZE 50M,
  GROUP 6 '/paic/xa/gbs/redo/oradata/gxa0/redo06.log'  SIZE 50M,
  GROUP 7 '/paic/xa/gbs/redo/oradata/gxa0/redo07.log'  SIZE 50M,
  GROUP 8 '/paic/xa/gbs/redo/oradata/gxa0/redo08.log'  SIZE 50M,
  GROUP 9 '/paic/xa/gbs/redo/oradata/gxa0/redo09.log'  SIZE 50M,
  GROUP 10 '/paic/xa/gbs/redo/oradata/gxa0/redo10.log'  SIZE 50M,
  GROUP 11 '/paic/xa/gbs/redo/oradata/gxa0/redo11.log'  SIZE 50M,
  GROUP 12 '/paic/xa/gbs/redo/oradata/gxa0/redo12.log'  SIZE 50M
new LOGFILE:
  GROUP 1 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo01.log'  SIZE 50M,
  GROUP 2 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo02.log'  SIZE 50M,
  GROUP 3 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo03.log'  SIZE 50M,
  GROUP 4 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo04.log'  SIZE 50M,
  GROUP 5 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo05.log'  SIZE 50M,
  GROUP 6 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo06.log'  SIZE 50M,
  GROUP 7 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo07.log'  SIZE 50M,
  GROUP 8 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo08.log'  SIZE 50M,
  GROUP 9 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo09.log'  SIZE 50M,
  GROUP 10 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo10.log'  SIZE 50M,
  GROUP 11 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo11.log'  SIZE 50M,
  GROUP 12 '/paic/s2cs5020/stg/cx2/oradata/gs30xa/redo12.log'  SIZE 50M

old DATAFILE:
  '/paic/xa/gbs/data/oradata/gxa0/system01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/undotbs01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/sysaux01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/users01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/auddata01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/abbsdata01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/abbsindx01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/dbadata01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/dmlbakdata01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/i3_orcl01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbs01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbs02.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbs03.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbs04.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsbak01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsbase01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsindex01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsindex02.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbslogtmpdata01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbslogtmpidx01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsrep01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsrept01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsusers01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gresv01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gresvdata01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gresvidx01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/tools01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsindex03.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsmisindex01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsmis01.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/gbsindex04.dbf',
  '/paic/xa/gbs/data/oradata/gxa0/dmlbakdata02.dbf'
 
 

new DATAFILE:
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/system01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/undotbs01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/sysaux01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/users01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/auddata01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/abbsdata01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/abbsindx01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/dbadata01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/dmlbakdata01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/i3_orcl01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbs01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbs02.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbs03.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbs04.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsbak01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsbase01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsindex01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsindex02.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbslogtmpdata01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbslogtmpidx01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsrep01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsrept01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsusers01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gresv01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gresvdata01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gresvidx01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/tools01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsindex03.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsmisindex01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsmis01.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/gbsindex04.dbf',
  '/paic/s2cs5020/stg/cx2/oradata/gs30xa/dmlbakdata02.dbf'

修改完后保存退出 :wq!

6.修改init文件
cd $ORACLE_HOME/dbs
vi initgs30xa.ora
然后将db_name修改成开发测试库的sid:*.db_name='gs30xa'

7.将原来的control文件备份成成其他名字,然后删除
cd /paic/s2cs5020/stg/cx2/oradata/gs30xa
s2cs5020:10g:gs30xa > rm control01.ctl
s2cs5020:10g:gs30xa > rm control02.ctl
s2cs5020:10g:gs30xa > rm control03.ctl

rm control01.ctl
rm control02.ctl
rm control03.ctl


7.执行control.sql
cd $ORACLE_BASE/admin/gs30xa/udump
sqlplus / as sysdba

SQL> @control.sql
ORACLE instance started.

Total System Global Area  524288000 bytes
Fixed Size                  2178744 bytes
Variable Size             372883784 bytes
Database Buffers          138412032 bytes
Redo Buffers               10813440 bytes

Control file created.

SQL> alter database open resetlogs;

Database altered.

SQL> select * from v$database;


8.
8i的temp表空间是datafile,不用再重建。
9i以及10g的temp表空间是tempfile,需要重建。

SQL> alter tablespace TEMP add tempfile '/paic/z4as8020/stg/bank3/oradata/bsesb/temp01.dbf' size 500m reuse;
alter tablespace TEMP add tempfile '/paic/s2cs5020/stg/cx2/oradata/gs30cs/temp01.dbf' size 500m reuse;
Tablespace altered.

SQL> alter tablespace I3_ORCL_TMP add tempfile '/paic/s2cs5020/stg/cx2/oradata/gs30xa/i3_orcl_tmp01.dbf' size 100m reuse;
alter tablespace I3_ORCL_TMP add tempfile '/paic/s2cs5020/stg/cx2/oradata/gs30cs/i3_orcl_tmp01.dbf' size 100m reuse;

9.生成spfile,并重启数据库保证参数调整生效。
SQL> Shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> create spfile from pfile;

File created.

SQL> exit

10.配置监听和连接串
s2cs5020:10g:gs30xa > cd $ORACLE_HOME/network/admin/
s2cs5020:10g:gs30xa > ls
listener.ora      listener.ora.bak  samples           shrept.lst        tnsnames.ora
s2cs5020:10g:gs30xa > vi listener.ora
增加监听(说明:端口随意指定,只要没有被占用就行):
gs30xa =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 10.31.9.62)(PORT = 1558))
      )
    )
  )

SID_LIST_gs30xa =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = gs30xa.world)
      (ORACLE_HOME = /paic/stg/oracle/10g/app/oracle/product/10.2.0)
      (SID_NAME = gs30xa)
      )
    )

配置tnsname.ora,增加连接串:
GS30XA =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.31.9.62)(PORT = 1558))
    (connect_data =
      (sid = GS30XA)
    )
  )

启动监听:
s2cs5020:10g:gs30xa > lsnrctl start gs30xa(gs30xa替换成新建库的sid)
Service "gs30xa.world" has 1 instance(s).
  Instance "gs30xa", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
启动成功

11.删除连接导生产的db_link
cd $ORACLE_BASE/admin/gs30xa0/udump
sqlplus / as sysdba
SQL> startup mount
SQL> alter database open;
SQL> set heading off
SQL> set feedback off
SQL> select distinct 'alter user '||owner||' profile default identified by Paic1234 account unlock;' from dba_db_links;
执行产生的sql,修改用户密码
SQL> spool $sid
SQL> SELECT 'CONN '||OWNER||'/Paic1234@gs30xa'||CHR(10)||'DROP DATABASE LINK '||DB_LINK||';' FROM DBA_DB_LINKS;注意要改语句中的sid!
SQL> spool off

SQL> host
s2cs5020:10g:gs30xa >vi xa.sql---检查一下脚本内容
s2cs5020:10g:gs30xa > exit
SQL> @xa.sql


12.初始化所有用户密码

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27165054/viewspace-735537/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27165054/viewspace-735537/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值