Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6524549
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: Oracle

2012-03-11 19:35:27

环境:
OS:Red Hat Linux As5
DB:10.2.0.1
 
数据库安装好后可以使用nid更改数据库名称(db_name),nid用法如下:
[oracle@hxl_str ~]$ nid -help
DBNEWID: Release 10.2.0.1.0 - Production on Mon Mar 12 03:08:50 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Keyword     Description                    (Default)
----------------------------------------------------
TARGET      Username/Password              (NONE)
DBNAME      New database name              (NONE)
LOGFILE     Output Log                     (NONE)
REVERT      Revert failed change           NO
SETNAME     Set a new database name only   NO
APPEND      Append to output log           NO
HELP        Displays these messages        NO

下面通过nid更改db_name和dbid:

1.加载数据库,nid需要数据库在mount下执行

sql>startup mount

2.将数据名更改为oraclstr,这里没有设置setname,说明dbid也一同更改

[oracle@hxl_str ~]$ nid target=sys/sys dbname=oraclstr

DBNEWID: Release 10.2.0.1.0 - Production on Mon Mar 12 02:29:35 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to database ORACL (DBID=1823104615)

Connected to server version 10.2.0

Control Files in database:
    /u01/app/oracle/oradata/oracl/control01.ctl
    /u01/app/oracle/oradata/oracl/control02.ctl
    /u01/app/oracle/oradata/oracl/control03.ctl
Change database ID and database name ORACL to ORACLSTR? (Y/[N]) => Y

Proceeding with operation
Changing database ID from 1823104615 to 4148550416
Changing database name from ORACL to ORACLSTR
    Control File /u01/app/oracle/oradata/oracl/control01.ctl - modified
    Control File /u01/app/oracle/oradata/oracl/control02.ctl - modified
    Control File /u01/app/oracle/oradata/oracl/control03.ctl - modified
    Datafile /u01/app/oracle/oradata/oracl/system01.dbf - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/oracl/undotbs01.dbf - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/oracl/sysaux01.dbf - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/oracl/users01.dbf - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/oracl/temp01.dbf - dbid changed, wrote new name
    Control File /u01/app/oracle/oradata/oracl/control01.ctl - dbid changed, wrote new name
    Control File /u01/app/oracle/oradata/oracl/control02.ctl - dbid changed, wrote new name
    Control File /u01/app/oracle/oradata/oracl/control03.ctl - dbid changed, wrote new name
    Instance shut down

Database name changed to ORACLSTR.
Modify parameter file and generate a new password file before restarting.
Database ID for database ORACLSTR changed to 4148550416.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.

3.修改oracle用户的环境变量(若不想修改oracle_sid,这步可以省略)
编辑.bash_profile,修改ORACLE_SID=oraclstr

4.修改参数文件
4.1 生成初始化参数便于修

create pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initoraclstr.ora' from spfile
编辑initoracl.ora
修改将db_name修改如下
db_name=oraclstr

4.2 创建spfile
create spfile from pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initoraclstr.ora';
如没有修改db_name参数的话启动的时候会报如下错误:
SQL> startup
ORACLE instance started.

Total System Global Area  734003200 bytes
Fixed Size                  1221564 bytes
Variable Size             201329732 bytes
Database Buffers          528482304 bytes
Redo Buffers                2969600 bytes
ORA-01103: database name 'ORACLSTR' in control file is not 'ORACL'

5.创建密码文件
orapwd file='/u01/app/oracle/product/10.2.0/db_1/dbs/orapworalstr' password=sys entries=10 force=y

6. 打开数据库
SQL> startup
ORACLE instance started.
Total System Global Area  734003200 bytes
Fixed Size                  1221564 bytes
Variable Size             201329732 bytes
Database Buffers          528482304 bytes
Redo Buffers                2969600 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs; --  注意更改了db_name后需要resetlogs打开数据库,若SETNAME=Y即只更改数据库名,并没有修改dbid则不需要resetlogs打开数据库.
7.全备份数据库

--The End--


阅读(1240) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~