by ora老菜 2012-2-21 15:44:29
环境:redhat Linux 5
oracle 10g
1.修改instance name和dbname
[root@oradb01 ~]# su - oracle
[oracle@oradb01 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 20 16:59:52 2012
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
SQL>
SQL>
SQL> select DBID,name from v$database;
DBID NAME
---------- ---------
1302877285 ORCL
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
orcl
mkdir -p test01
cd test01
mkdir -p adump bdump cdump udump dpdump
mkdir -p pfile
mkdir -p scripts
cp initorcl.ora inittest01.ora
vi inittest01.ora
修改:
[oracle@oradb01 dbs]$ vi inittest.ora
*.audit_file_dest='/u01/oracle/admin/test/adump'
*.background_dump_dest='/u01/oracle/admin/test/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/oracle/oradata/orcl/control01.ctl','/u01/oracle/oradata/orcl/control02.ctl','/u01/oracle/oradata/orcl/control03.ctl'
*.core_dump_dest='/u01/oracle/admin/test/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='test01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=/u01/oracle/archivelog'
*.open_cursors=300
*.pga_aggregate_target=20971520
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=125829120
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/oracle/admin/test/udump'
SQL>
SQL> alter database backup controlfile to trace;
Database altered.
SQL>
CREATE CONTROLFILE SET DATABASE "TEST" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/oracle/oradata/orcl/redo01.log' SIZE 50M,
GROUP 2 '/u01/oracle/oradata/orcl/redo02.log' SIZE 50M,
GROUP 3 '/u01/oracle/oradata/orcl/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u01/oracle/oradata/orcl/system01.dbf',
'/u01/oracle/oradata/orcl/undotbs01.dbf',
'/u01/oracle/oradata/orcl/sysaux01.dbf',
'/u01/oracle/oradata/orcl/users01.dbf',
'/u01/oracle/oradata/orcl/test01.dbf',
'/u01/oracle/oradata/orcl/ts_index.dbf'
CHARACTER SET ZHS16GBK
;
[oracle@oradb01 oracle]$ export ORACLE_SID=test
[oracle@oradb01 oracle]$
[oracle@oradb01 oracle]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 20 17:11:43 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 125829120 bytes
Fixed Size 1218076 bytes
Variable Size 62917092 bytes
Database Buffers 58720256 bytes
Redo Buffers 2973696 bytes
SQL>
SQL>
SQL> CREATE CONTROLFILE SET DATABASE "TEST" RESETLOGS ARCHIVELOG
MAXLOGMEMBERS 3
MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
GROUP 1 '/u01/oracle/oradata/orcl/redo01.log' SIZE 50M,
GROUP 3 '/u01/oracle/oradata/orcl/redo03.log' SIZE 50M
GROUP 2 '/u01/oracle/oradata/orcl/redo02.log' SIZE 50M,
GROUP 3 '/u01/oracle/oradata/orcl/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u01/oracle/oradata/orcl/system01.dbf',
'/u01/oracle/oradata/orcl/undotbs01.dbf',
15 '/u01/oracle/oradata/orcl/sysaux01.dbf',
16 '/u01/oracle/oradata/orcl/users01.dbf',
17 '/u01/oracle/oradata/orcl/test01.dbf',
18 '/u01/oracle/oradata/orcl/ts_index.dbf'
19 CHARACTER SET ZHS16GBK
20 /
Control file created.
SQL> alter database open resetlogs
2 /
Database altered.
SQL> alter database open resetlogs
2 /
Database altered.
SQL> select DBID,name from v$database;
DBID NAME
---------- ---------
1302877285 TEST
SQL>
SQL>
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
test
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
test
SQL> select user_name from dba_users;
select user_name from dba_users
*
ERROR at line 1:
ORA-00904: "USER_NAME": invalid identifier
SQL> select username from dba_users;
USERNAME
------------------------------
MGMT_VIEW
SYS
SYSTEM
DBSNMP
SYSMAN
SCOTT
TEST
TD
OUTLN
MDSYS
ORDSYS
USERNAME
------------------------------
CTXSYS
ANONYMOUS
EXFSYS
DMSYS
WMSYS
XDB
ORDPLUGINS
SI_INFORMTN_SCHEMA
OLAPSYS
MDDATA
DIP
USERNAME
------------------------------
TSMSYS
23 rows selected.
SQL> conn test/test
Connected.
SQL>
SQL>
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
TEST1 TABLE
TN1 TABLE
TEST2 TABLE
T1 TABLE
SQL>
SQL>
SQL>
SQL>
SQL> select * from t1;
A B
---------- ----------
1 aaa
2 bbb
3 ccc
4 ddd
SQL>
Ok,instance name修改成功。
2.继续试验修改db name
[oracle@oradb01 oracle]$ export ORACLE_SID=test
[oracle@oradb01 oracle]$
[oracle@oradb01 oracle]$
[oracle@oradb01 oracle]$
[oracle@oradb01 oracle]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 20 17:29:24 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 125829120 bytes
Fixed Size 1218076 bytes
Variable Size 62917092 bytes
Database Buffers 58720256 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL> select name,dbid,db_unique_name from v$database;
NAME DBID DB_UNIQUE_NAME
--------- ---------- ------------------------------
TEST 1302877285 test
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
test
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 125829120 bytes
Fixed Size 1218076 bytes
Variable Size 62917092 bytes
Database Buffers 58720256 bytes
Redo Buffers 2973696 bytes
SQL> alter database mount;
Database altered.
SQL> !
[oracle@oradb01 oracle]$ nid
DBNEWID: Release 10.2.0.1.0 - Production on Mon Feb 20 17:31:11 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
[oracle@oradb01 oracle]$ nid target=/ dbname=orcl
DBNEWID: Release 10.2.0.1.0 - Production on Mon Feb 20 17:31:23 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database TEST (DBID=1302877285)
Connected to server version 10.2.0
Control Files in database:
/u01/oracle/oradata/orcl/control01.ctl
/u01/oracle/oradata/orcl/control02.ctl
/u01/oracle/oradata/orcl/control03.ctl
Change database ID and database name TEST to ORCL? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 1302877285 to 1303575020
Changing database name from TEST to ORCL
Control File /u01/oracle/oradata/orcl/control01.ctl - modified
Control File /u01/oracle/oradata/orcl/control02.ctl - modified
Control File /u01/oracle/oradata/orcl/control03.ctl - modified
Datafile /u01/oracle/oradata/orcl/system01.dbf - dbid changed, wrote new name
Datafile /u01/oracle/oradata/orcl/undotbs01.dbf - dbid changed, wrote new name
Datafile /u01/oracle/oradata/orcl/sysaux01.dbf - dbid changed, wrote new name
Datafile /u01/oracle/oradata/orcl/users01.dbf - dbid changed, wrote new name
Datafile /u01/oracle/oradata/orcl/test01.dbf - dbid changed, wrote new name
Datafile /u01/oracle/oradata/orcl/ts_index.dbf - dbid changed, wrote new name
Control File /u01/oracle/oradata/orcl/control01.ctl - dbid changed, wrote new name
Control File /u01/oracle/oradata/orcl/control02.ctl - dbid changed, wrote new name
Control File /u01/oracle/oradata/orcl/control03.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to ORCL.
Modify parameter file and generate a new password file before restarting.
Database ID for database ORCL changed to 1303575020.
All previous backups and archived redo logs for this database are unusable.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.
[oracle@oradb01 dbs]$ vi inittest.ora
*.audit_file_dest='/u01/oracle/admin/test/adump'
*.background_dump_dest='/u01/oracle/admin/test/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/oracle/oradata/orcl/control01.ctl','/u01/oracle/oradata/orcl/control02.ctl','/u01/oracle/oradata/orcl/control03.ctl'
*.core_dump_dest='/u01/oracle/admin/test/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=/u01/oracle/archivelog'
*.open_cursors=300
*.pga_aggregate_target=20971520
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=125829120
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/oracle/admin/test/udump'
SQL>
SQL> startup mount pfile='/u01/oracle/product/10g/db_1/dbs/inittest.ora'
ORACLE instance started.
Total System Global Area 125829120 bytes
Fixed Size 1218076 bytes
Variable Size 62917092 bytes
Database Buffers 58720256 bytes
Redo Buffers 2973696 bytes
Database mounted.
SQL> alter database open resetlogs;
Database altered.
SQL> select name,dbid,db_unique_name from v$database;
NAME DBID DB_UNIQUE_NAME
--------- ---------- ------------------------------
ORCL 1303575020 orcl
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
test
3.下面来修改instance name
cp inittest.ora initorcl.ora
orapwd file=/u01/oracle/product/10g/db_1/dbs/orapdorcl password=oracle entries=5
[oracle@oradb01 oracle]$ export ORACLE_SID=orcl
[oracle@oradb01 oracle]$
[oracle@oradb01 oracle]$
[oracle@oradb01 oracle]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 20 17:38:59 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 125829120 bytes
Fixed Size 1218076 bytes
Variable Size 62917092 bytes
Database Buffers 58720256 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL> select name,dbid,db_unique_name from v$database;
NAME DBID DB_UNIQUE_NAME
--------- ---------- ------------------------------
ORCL 1303575020 orcl
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
orcl
修改tnsname.ora、 listener.ora(略)
Ok,完成
------------------------------------------------------------------------------------------------------------------------------
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/oracle/oradata/orcl/redo01.log' SIZE 50M,
GROUP 2 '/u01/oracle/oradata/orcl/redo02.log' SIZE 50M,
GROUP 3 '/u01/oracle/oradata/orcl/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u01/oracle/oradata/orcl/system01.dbf',
'/u01/oracle/oradata/orcl/undotbs01.dbf',
'/u01/oracle/oradata/orcl/sysaux01.dbf',
'/u01/oracle/oradata/orcl/users01.dbf',
'/u01/oracle/oradata/orcl/test01.dbf',
'/u01/oracle/oradata/orcl/ts_index.dbf'
CHARACTER SET ZHS16GBK
;
-----------------------------------------------------------------------
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/oracle/oradata/orcl/redo01.log' SIZE 50M,
GROUP 2 '/u01/oracle/oradata/orcl/redo02.log' SIZE 50M,
GROUP 3 '/u01/oracle/oradata/orcl/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u01/oracle/oradata/orcl/system01.dbf',
'/u01/oracle/oradata/orcl/undotbs01.dbf',
'/u01/oracle/oradata/orcl/sysaux01.dbf',
'/u01/oracle/oradata/orcl/users01.dbf',
'/u01/oracle/oradata/orcl/test01.dbf',
'/u01/oracle/oradata/orcl/ts_index.dbf'
CHARACTER SET ZHS16GBK
;