ORACLE 修改SID

mac2022-06-30  81

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

1、关闭数据库

 

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

2、退出SQLPLUS

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

3、更改环境变量

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

 

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

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

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

更改后的样子是:

[html]  view plain  copy    print? [oracle@localhost ~]$ more /etc/oratab  # This file is used by ORACLE utilities.  It is created by root.sh  # and updated by the Database Configuration Assistant when creating  # a database.    # A colon, ':', is used as the field terminator.  A new line termina  tes  # the entry.  Lines beginning with a pound sign, '#', are comments.  #  # Entries are of the form:  #   $ORACLE_SID:$ORACLE_HOME:<N|Y>:  #  # The first and second fields are the system identifier and home  # directory of the database respectively.  The third filed indicates  # to the dbstart utility that the database should , "Y", or should n  ot,  # "N", be brought up at system boot time.  #  # Multiple entries with the same $ORACLE_SID are not allowed.  #  #  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? [oracle@localhost ~]$ cd $ORACLE_HOME/dbs  [oracle@localhost dbs]$   

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

       

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

   (3)

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

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

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

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

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

6、启动数据库

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

7、查看实例名

[html]  view plain  copy    print? SQL> select instance from v$thread;    INSTANCE  --------------------------------------------------------------------------------  nihao  

8、退出sqlplus

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

9、查看系统环境变量

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

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

转载于:https://www.cnblogs.com/Dennis-mi/articles/5209704.html

最新回复(0)