我修改后的ccf.sql文件内容如下
STARTUP NOMOUNT
CREATE CONTROLFILE set DATABASE "cnhtm" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '+DATA/cnhtm/onlinelog/group_1.LOG' SIZE 100M,
GROUP 2 '+DATA/cnhtm/onlinelog/group_2.LOG' SIZE 100M,
GROUP 3 '+DATA/cnhtm/onlinelog/group_3.LOG' SIZE 100M,
GROUP 4 '+DATA/cnhtm/onlinelog/group_4.LOG' SIZE 100M
DATAFILE
'+DATA/cnhtm/datafile/system01.DBF',
'+DATA/cnhtm/datafile/undotbs101.DBF',
'+DATA/cnhtm/datafile/sysaux01.DBF',
'+DATA/cnhtm/datafile/users01.DBF',
'+DATA/cnhtm/datafile/example01.DBF',
'+DATA/cnhtm/datafile/tbs_lmt01.DBF',
'+DATA/cnhtm/datafile/tbs_lmt_201.DBF',
'+DATA/cnhtm/datafile/tbs_lmt_301.DBF'
CHARACTER SET ZHS16GBK
;
--RECOVER DATABASE USING BACKUP CONTROLFILE;
ALTER DATABASE OPEN RESETLOGS;
ALTER TABLESPACE TEMP ADD TEMPFILE '+DATA/cnhtm/tempfile/temp.269.705923003'
SIZE 104857600 REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
2.7、修改数据文件、在线日志文件名
如果上一步修改了ccf.sql文件中的datafile和logfile段的文件名,这里要将这些文件名重命令为与其一致。
因为我的实验环境使用了ASM,在Oracle 10.2中ASM中不能重命名和复制文件,我采用了创建别名的方式,操作如下:
oracle@oracle[/oracle/admin/cnhtm/udump]> export ORACLE_SID=+ASM
oracle@oracle[/oracle/admin/cnhtm/udump]> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Dec 20 12:08:52 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
idle> alter diskgroup data add directory '+data/CNHTM';
Diskgroup altered.
idle> alter diskgroup data add directory '+data/CNHTM/DATAFILE';
Diskgroup altered.
idle> alter diskgroup data add alias
2 '+data/CNHTM/DATAFILE/EXAMPLE01.DBF'
3 for
4 '+data/ORCL/DATAFILE/EXAMPLE.261.705922745';
Diskgroup altered.
......
idle> alter diskgroup data add alias
2 '+data/CNHTM/DATAFILE/USERS01.DBF'
3 for
4 '+data/ORCL/DATAFILE/USERS.266.705922777';
Diskgroup altered.
idle> alter diskgroup data add directory '+data/CNHTM/ONLINELOG';
Diskgroup altered.
......
idle> alter diskgroup data add alias
2 '+data/CNHTM/ONLINELOG/group_4.LOG'
3 for
4 '+data/ORCL/ONLINELOG/group_7.273.705923695';
Diskgroup altered.
2.8、如果归档日志目录名中包含sid,那么修改归档目录名
我的测试环境,归档目录使用的是flash_recovery_area,所以需要将这个目录中的ORCL目录重命名为CNHTM
2.9、使用spfile生成pfile
注意这里没有启动数据库,只是链接到idle状态
oracle@oracle[/home/oracle]> export ORACLE_SID=cnhtm
oracle@oracle[/home/oracle]> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Dec 20 11:49:20 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
idle> create pfile='?/dbs/initcnhtm.ora' from spfile;
File created.
idle> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
2.10、进入$ORACLE_HOME/dbs目录
2.11、编辑initcnhtm.ora文件
搜索所有的orcl,重命令为cnhtm,搜索所有的ORCL,重命名为CNHTM
2.12、删除控制文件
将原来的控制文件删除或重命名
控制文件的位置名称可以通过查看2.11步骤中的*.control_files来确定
如果控制文件在ASM中,可以进入asmcmd命令,然后用rm命令删除
2.13、进入$ORACLE_BASE/admin目录
将orcl目录重命名为cnhtm
2.14、使用修改过的pfile生成spfile
oracle@oracle[/oracle/admin/cnhtm/udump]> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Dec 20 11:59:56 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
idle> create spfile from pfile='?/dbs/initcnhtm.ora';
File created.
2.15、调用2.6步骤修改好的ccf.sql
idle> @/oracle/admin/cnhtm/udump/ccf.sql
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218292 bytes
Variable Size 67111180 bytes
Database Buffers 92274688 bytes
Redo Buffers 7168000 bytes
Control file created.
Database altered.
Database altered.
Tablespace altered.
2.16、检查数据库状态
idle> conn / as sysdba
Connected.
sys@CNHTM>select open_mode from v$database;
OPEN_MODE
----------
READ WRITE
sys@CNHTM> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string cnhtm
db_unique_name string cnhtm
global_names boolean FALSE
instance_name string cnhtm
lock_name_space string
log_file_name_convert string
service_names string cnhtm
发现数据库名(db_name)已经修改为cnhtm