ORACLE 修改SID

ORACLE 修改SID

转自 http://blog.csdn.net/huzia/article/details/6798141

1、关闭数据库

 

[html]  view plain  copy
 
 print?
  1. SQL> shutdown immediate   
  2. Database closed.  
  3. Database dismounted.  
  4. ORACLE instance shut down.  


2、退出SQLPLUS

[html]  view plain  copy
 
 print?
  1. SQL> exit  
  2. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production  
  3. With the Partitioning, OLAP, Data Mining and Real Application Testing options  


3、更改环境变量

[html]  view plain  copy
 
 print?
  1. [oracle@localhost ~]$ export ORACLE_SID=nihao  
  2. [oracle@localhost ~]$ export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH  

 

4、修改配置文件(修改/etc/oratab文件,将sid名由旧的修改为新的,如从orcl修改为nihao)

[html]  view plain  copy
 
 print?
  1. [oracle@localhost ~]$ more /etc/oratab  
  2. # This file is used by ORACLE utilities.  It is created by root.sh  
  3. # and updated by the Database Configuration Assistant when creating  
  4. # a database.  
  5.   
  6. # A colon, ':', is used as the field terminator.  A new line termina  
  7. tes  
  8. # the entry.  Lines beginning with a pound sign, '#', are comments.  
  9. #  
  10. # Entries are of the form:  
  11. #   $ORACLE_SID:$ORACLE_HOME:<N|Y>:  
  12. #  
  13. # The first and second fields are the system identifier and home  
  14. # directory of the database respectively.  The third filed indicates  
  15. # to the dbstart utility that the database should , "Y", or should n  
  16. ot,  
  17. # "N", be brought up at system boot time.  
  18. #  
  19. # Multiple entries with the same $ORACLE_SID are not allowed.  
  20. #  
  21. #  
  22. orcl:/oracle/app/oracle/product/11.2.0/dbhome_1:Y  


把最后一行的orcl字样改成nihao;

更改后的样子是:

[html]  view plain  copy
 
 print?
  1. [oracle@localhost ~]$ more /etc/oratab  
  2. # This file is used by ORACLE utilities.  It is created by root.sh  
  3. # and updated by the Database Configuration Assistant when creating  
  4. # a database.  
  5.   
  6. # A colon, ':', is used as the field terminator.  A new line termina  
  7. tes  
  8. # the entry.  Lines beginning with a pound sign, '#', are comments.  
  9. #  
  10. # Entries are of the form:  
  11. #   $ORACLE_SID:$ORACLE_HOME:<N|Y>:  
  12. #  
  13. # The first and second fields are the system identifier and home  
  14. # directory of the database respectively.  The third filed indicates  
  15. # to the dbstart utility that the database should , "Y", or should n  
  16. ot,  
  17. # "N", be brought up at system boot time.  
  18. #  
  19. # Multiple entries with the same $ORACLE_SID are not allowed.  
  20. #  
  21. #  
  22. nihao:/oracle/app/oracle/product/11.2.0/dbhome_1:Y  


 

5、更改数据库系统文件,进入到$ORACLE_HOME/dbs目录将所有文件名中包含原来的sid的地方修改为对应的新sid的(这里有orcl改为nihao)
        如我对如下文件修改为其后对应的文件和文件夹。

    (1)进入$ORACLE_HOME/dbs目录

[html]  view plain  copy
 
 print?
  1. [oracle@localhost ~]$ cd $ORACLE_HOME/dbs  
  2. [oracle@localhost dbs]$   


   (2)查看该目录下有什么内容

       

[html]  view plain  copy
 
 print?
  1. [oracle@localhost dbs]$ ll  
  2. 总计 72  
  3. -rw-rw---- 1 oracle oinstall 1544 09-14 11:27 hc_DBUA0.dat  
  4. -rw-rw---- 1 oracle dba      1544 09-21 17:02 hc_orcl.dat  
  5. -rw-r--r-- 1 oracle dba      2851 2009-05-15 init.ora  
  6. -rw-r----- 1 oracle dba        24 08-28 12:25 lkORCL  
  7. -rw-r----- 1 oracle dba      1536 09-21 10:30 orapworcl  
  8. drwx------ 2 oracle oinstall 4096 08-31 07:57 peshm_DBUA0_0  
  9. drwx------ 2 oracle dba      4096 08-28 12:22 peshm_orcl_0  
  10. -rw-r----- 1 oracle dba      2560 09-21 10:30 spfileorcl.ora  


   (3)

总共5个含有orcl或者ORCL的地方,够要改。

[html]  view plain  copy
 
 print?
  1. [oracle@localhost dbs]$ mv hc_orcl.dat hc_nihao.dat  
  2. [oracle@localhost dbs]$ mv lkORCL lkNIHAO  
  3. [oracle@localhost dbs]$ mv orapworcl orapwnihao  
  4. [oracle@localhost dbs]$ mv peshm_orcl_0/ peshm_nihao/  
  5. [oracle@localhost dbs]$ mv spfileorcl.ora spfilenihao.ora   


(4)查看更改以后的结果

[html]  view plain  copy
 
 print?
  1. [oracle@localhost dbs]$ ll  
  2. 总计 80  
  3. -rw-rw---- 1 oracle oinstall 1544 09-14 11:27 hc_DBUA0.dat  
  4. -rw-rw---- 1 oracle dba      1544 09-21 18:14 hc_nihao.dat  
  5. -rw-r--r-- 1 oracle dba      2851 2009-05-15 init.ora  
  6. -rw-r----- 1 oracle dba        24 08-28 12:25 lkNIHAO  
  7. -rw-r----- 1 oracle dba      1536 09-21 10:30 orapwnihao  
  8. drwx------ 2 oracle oinstall 4096 08-31 07:57 peshm_DBUA0_0  
  9. drwx------ 2 oracle dba      4096 08-28 12:22 peshm_nihao  
  10. -rw-r----- 1 oracle dba      3584 09-21 18:37 spfilenihao.ora  

如果有问题,要回过头来检查这里,个人备注。

6、启动数据库

[html]  view plain  copy
 
 print?
  1. [oracle@localhost ~]$ sqlplus "/as sysdba"  
  2.   
  3. SQL*Plus: Release 11.2.0.1.0 Production on Wed Sep 21 18:11:47 2011  
  4.   
  5. Copyright (c) 1982, 2009, Oracle.  All rights reserved.  
  6.   
  7. Connected to an idle instance.  
  8.   
  9. SQL> startup  
  10. ORACLE instance started.  
  11.   
  12. Total System Global Area  443592704 bytes  
  13. Fixed Size                  1337100 bytes  
  14. Variable Size             272632052 bytes  
  15. Database Buffers          163577856 bytes  
  16. Redo Buffers                6045696 bytes  
  17. Database mounted.  
  18. Database opened.  


7、查看实例名

[html]  view plain  copy
 
 print?
  1. SQL> select instance from v$thread;  
  2.   
  3. INSTANCE  
  4. --------------------------------------------------------------------------------  
  5. nihao  


8、退出sqlplus

[html]  view plain  copy
 
 print?
  1. SQL> exit  
  2. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production  
  3. With the Partitioning, OLAP, Data Mining and Real Application Testing options  


9、查看系统环境变量

[html]  view plain  copy
 
 print?
  1. [oracle@localhost ~]$ env | grep ORACLE  
  2. ORACLE_SID=nihao  
  3. ORACLE_BASE=/oracle/app/oracle  
  4. ORACLE_HOME=/oracle/app/oracle/product/11.2.0/dbhome_1  
  5. [oracle@localhost ~]$   


   其中第二行,很明白的告诉大家,启动成功,更改生效。

posted @ 2016-02-23 14:04 心灵捕手 阅读( ...) 评论( ...)   编辑 收藏
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值