Oracle 11gR2修改数据库实例名sid

目的:将数据库实例名变为pri

一、检查当前数据库的实例名

操作系统中环境变量对应的ORACLE_SID

[oracle@centoslinux ~]$ echo $ORACLE_SID
orcl

数据库中实例名instance

SQL> show parameter instance_name;

NAME
------------------------------------
TYPE
--------------------------------------------------------------------------------
VALUE
------------------------------
instance_name
string
orcl
SQL> 

原ORACLE_SID 和instance 为orcl

二、关闭数据库

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> quit      
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@centoslinux ~]$ 

 三、修改操作系统环境变量 ORACLE_SID=pri

由orcl变为pri

临时修改:

[oracle@centoslinux ~]$ export ORACLE_SID=pri
[oracle@centoslinux ~]$ echo $ORACLE_SID      
pri

永久修改

[oracle@centoslinux ~]$ vi  .bash_profile
export ORACLE_SID=pri

使修改立即生效

[oracle@centoslinux ~]$ source .bash_profile

四、修改/etc/oratab,将sid名由旧的改为新的,由orcl改为pri

[oracle@centoslinux ~]$ vi /etc/oratab
pri:/opt/oracle/product/11.2.0/dbhome_1:N

五、修改/ORACLE_HOEM/dbs下所有文件名orcl改为pti

[oracle@centoslinux ~]$ cd /opt/oracle/product/11.2.0/dbhome_1/dbs/
[oracle@centoslinux dbs]$ ls
core_23809  core_25881  hc_DBUA0.dat  hc_orcl2.dat  initorcl1.ora     initorcl.ora.bk  lkORCL1    orapworcl1     snapcf_orcl1.f  spfileorcl1.ora     spfileorcl.ora
core_24484  core_26798  hc_mydb.dat   hc_orcl.dat   initorcl1.ora.bk  lkMYDB           lkORCL2    orapworcl2     snapcf_orcl2.f  spfileorcl1.ora.bk  spfileorcl.ora.bk
core_25824  core_27821  hc_orcl1.dat  init.ora      initorcl.ora      lkORCL           orapworcl  snapcf_mydb.f  snapcf_orcl.f   spfileorcl2.ora

修改了一下文件

[oracle@centoslinux dbs]$ mv hc_orcl.dat hc_pri.dat
[oracle@centoslinux dbs]$ mv initorcl.ora initpri.ora
[oracle@centoslinux dbs]$ mv orapworcl orapwpri
[oracle@centoslinux dbs]$ mv snapcf_orcl.f snapcf_pri.f
[oracle@centoslinux dbs]$ mv spfileorcl.ora spfilepri.ora

六、因为文件名修改了,密码文件也失效了

重建密码文件orapwdpri

[oracle@centoslinux dbs]$ orapwd file=$ORACLE_HOME/dbs/orapwpri password=oracle
 entries=5 force=y 
[oracle@centoslinux dbs]$ ls -lt orapwpri 
-rw-r----- 1 oracle oinstall 2048 Jun  7 14:28 orapwpri

七、重启数据库

[oracle@centoslinux dbs]$ sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Jun 7 14:30:25 2020

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

Enter password: 
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  626327552 bytes
Fixed Size                  2215944 bytes
Variable Size             331354104 bytes
Database Buffers          281018368 bytes
Redo Buffers               11739136 bytes
Database mounted.
Database opened.
SQL> 

八、查看instance name

SQL> show parameter instance_name;

NAME
------------------------------------
TYPE
--------------------------------------------------------------------------------
VALUE
------------------------------
instance_name
string
pri
SQL> 

 九、使用navicat for oracle远程登录

可直接登录成功

参考:https://blog.csdn.net/cuiyan1982/article/details/52574487

 

 

 

 

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

终有一刻

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值