ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 改db_name和instance_name

改db_name和instance_name

原创 Linux操作系统 作者:psufnxk2000 时间:2013-09-02 23:39:04 0 删除 编辑
 
    
    11.2.0.3 
一  改instance_name.  把instance_name从 ogg改为 ogg1
    
 1.1 SQL> show parameter instance_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_name                        string      ogg
SQL> 
    
    SQL> create pfile='/u01/init.ora' from spfile;

File created.
SQL> ! cat /u01/init.ora
ogg.__oracle_base='/u01/apppp'#ORACLE_BASE set from environment
*._shared_io_pool_size=0
*.audit_file_dest='/u01/apppp/admin/ogg1/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/apppp/oradata/ogg1/control01.ctl','/u01/apppp/fast_recovery_area/ogg1/control02.ctl'
*.db_block_size=8192
*.db_cache_size=12582912
*.db_domain=''
*.db_name='ogg'
*.db_recovery_file_dest_size=209715200
*.db_recovery_file_dest='/data/archive'
*.diagnostic_dest='/u01/apppp'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ogg1XDB)'
*.instance_name='ogg'
*.java_pool_size=4194304
*.large_pool_size=4194304
*.log_archive_dest='/data/archive'
*.open_cursors=300
*.pga_aggregate_target=104857600
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sec_max_failed_login_attempts=5
*.sga_target=0
*.shared_pool_size=142606336
*.streams_pool_size=0
*.undo_tablespace='UNDOTBS1'


把instance_name改为 ogg1

SQL> startup nomount pfile='/u01/init.ora';
ORACLE instance started.

Total System Global Area  171225088 bytes
Fixed Size                  2226496 bytes
Variable Size             150996672 bytes
Database Buffers           12582912 bytes
Redo Buffers                5419008 bytes
SQL> create spfile from pfile='/u01/init.ora';

File created.

SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  171225088 bytes
Fixed Size                  2226496 bytes
Variable Size             150996672 bytes
Database Buffers           12582912 bytes
Redo Buffers                5419008 bytes
Database mounted.
Database opened.

[oracle@localhost ~]$ lsnrctl reload

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 02-SEP-2013 10:54:23

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
The command completed successfully


[oracle@localhost ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 02-SEP-2013 10:54:30

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                02-SEP-2013 09:05:46
Uptime                    0 days 1 hr. 48 min. 44 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/apppp/db_1/network/admin/listener.ora
Listener Log File         /u01/apppp/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "ogg" has 1 instance(s).
  Instance "ogg1", status READY, has 1 handler(s) for this service...
Service "ogg1XDB" has 1 instance(s).
  Instance "ogg1", status READY, has 1 handler(s) for this service...
The command completed successfully



二 改db_name
SQL> 
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  171225088 bytes
Fixed Size                  2226496 bytes
Variable Size             150996672 bytes
Database Buffers           12582912 bytes
Redo Buffers                5419008 bytes
Database mounted.
SQL> ! /u01/apppp/db_1/bin/nid target=sys/oracle dbname=ogg1

DBNEWID: Release 11.2.0.3.0 - Production on Mon Sep 2 10:57:56 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to database OGG (DBID=2926465068)

Connected to server version 11.2.0

Control Files in database:
    /u01/apppp/oradata/ogg1/control01.ctl
    /u01/apppp/fast_recovery_area/ogg1/control02.ctl

Change database ID and database name OGG to OGG1? (Y/[N]) => Y

Proceeding with operation
Changing database ID from 2926465068 to 4004215796
Changing database name from OGG to OGG1
    Control File /u01/apppp/oradata/ogg1/control01.ctl - modified
    Control File /u01/apppp/fast_recovery_area/ogg1/control02.ctl - modified
    Datafile /u01/apppp/oradata/ogg1/system01.db - dbid changed, wrote new name
    Datafile /u01/apppp/oradata/ogg1/sysaux01.db - dbid changed, wrote new name
    Datafile /u01/apppp/oradata/ogg1/undotbs01.db - dbid changed, wrote new name
    Datafile /u01/apppp/oradata/ogg1/users01.db - dbid changed, wrote new name
    Datafile /data/song_ts01.db - dbid changed, wrote new name
    Datafile /data/tbs_compress01.db - dbid changed, wrote new name
    Datafile /data/tbs_song02_01.bd - dbid changed, wrote new name
    Datafile /u01/apppp/oradata/ogg1/temp01.db - dbid changed, wrote new name
    Control File /u01/apppp/oradata/ogg1/control01.ctl - dbid changed, wrote new name
    Control File /u01/apppp/fast_recovery_area/ogg1/control02.ctl - dbid changed, wrote new name
    Instance shut down

Database name changed to OGG1.
Modify parameter file and generate a new password file before restarting.
Database ID for database OGG1 changed to 4004215796.
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.


改 ~/.bash_profile
改 /u01/init.ora里的 db_name='ogg1'
改 listener.ora里的名字
修改/etc/oratab 文件
orapwd


[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on Mon Sep 2 11:01:40 2013

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

SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup nomount pfile='/u01/init.ora';
ORACLE instance started.

Total System Global Area  171225088 bytes
Fixed Size                  2226496 bytes
Variable Size             150996672 bytes
Database Buffers           12582912 bytes
Redo Buffers                5419008 bytes
SQL> create spfile from pfile ='/u01/init.ora';

File created.

SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> 
SQL> 
SQL> startup  
ORACLE instance started.

Total System Global Area  171225088 bytes
Fixed Size                  2226496 bytes
Variable Size             150996672 bytes
Database Buffers           12582912 bytes
Redo Buffers                5419008 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;

Database altered.

SQL> 

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

上一篇: 压缩表dml
下一篇: 闪回表
请登录后发表评论 登录
全部评论

注册时间:2011-05-31

  • 博文量
    215
  • 访问量
    626166