分类: Oracle
2013-07-24 09:59:26
修改数据库名 db_name
1.修改pfile中的db_name=ora10g 改为db_name=beijing
[oracle@dcw dbs]$ pwd
/u01/oracle/product/10.2.0/dbs
[oracle@dcw dbs]$ vim initora10g.ora
*.db_name='beijing'
2.重新启动数据库 出错
idle> startup
ORACLE instance started.
Total System Global Area 230686720 bytes
Fixed Size 1218676 bytes
Variable Size 75499404 bytes
Database Buffers 150994944 bytes
Redo Buffers 2973696 bytes
ORA-01103: database name 'ORA10G' in control file is not 'BEIJING'
idle> select status from v$instance;
STATUS
----------
STARTED
idle> 说明数据库名不仅仅在参数文件里 控制文件也包含 所以要重建控制文件 因为是二进制的 不能编辑
3.正常关闭数据库 重建控制文件 创建前先把原来的控制文件删除 已存在不能创建
以防万一提前 备份一份SQL> alter database backup controlfile to trace as '/home/oracle/control.sql';
SQL>CREATE CONTROLFILE REUSE DATABASE ORA10G set database beijing resetlogs
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/oracle/oradata/ora10g/redo01.log修改数据库名 db_name' SIZE 50M,
GROUP 2 '/u01/oracle/oradata/ora10g/redo02.log' SIZE 50M,
GROUP 3 '/u01/oracle/oradata/ora10g/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u01/oracle/oradata/ora10g/system01.dbf',
'/u01/oracle/oradata/ora10g/undotbs01.dbf',
'/u01/oracle/oradata/ora10g/sysaux01.dbf',
'/u01/oracle/oradata/ora10g/users01.dbf',
'/u01/oracle/oradata/ora10g/my_16k_tbs01.dbf'
CHARACTER SET AL32UTF8
/
Control file created.
idle> select status from v$instance;
STATUS
----------
MOUNTED修改数据库名 db_name
4. 启动数据库 需要使用resetlogs模式重置联机日志文件
idle> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
idle> alter database open resetlogs;
Database altered.
idle> select status from v$instance;
STATUS
----------
OPEN
idle> show parameter name 库名改了
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string beijing
db_unique_name string beijing
global_names boolean FALSE
instance_name string ora10g
lock_name_space string
log_file_name_convert string
service_names string beijing
idle>
********************************************************************************************
修改实例名 instance_name
1.先正常停掉原来的库 使数据库时一致的
idle> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
idle>
2.修改操作系统和实例关联的信息 ORACLE_SID
以及根据ORACLE_SID参数去寻找的参数文件名和口令文件名
[oracle@seker ~]$ mv $ORACLE_HOME/dbs/orapwora10g $ORACLE_HOME/dbs/orapwbeijing
[oracle@seker ~]$ mv $ORACLE_HOME/dbs/initora10g.ora $ORACLE_HOME/dbs/initbeijing.ora
[oracle@seker ~]$ export ORACLE_SID=beijing
[oracle@seker ~]$ sql /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Feb 22 01:15:22 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
idle> conn / as sysdba
Connected to an idle instance.
idle> startup
ORACLE instance started.
Total System Global Area 230686720 bytes
Fixed Size 1218676 bytes
Variable Size 75499404 bytes
Database Buffers 150994944 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
idle> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string beijing
db_unique_name string beijing
global_names boolean FALSE
instance_name string beijing
lock_name_space string
log_file_name_convert string
service_names string beijing
idle>
修改 /etc/oratab 中的数据库名
[oracle@dcw dbs]$ vim /etc/oratab
beijing:/u01/oracle/product/10.2.0:Y
dcw:/u01/oracle/product/10.2.0:N
beijing:/u01/oracle/product/10.2.0:N
[oracle@dcw dbs]$ vim ~oracle/.bash_profile
export ORACLE_SID=beijing