目的:将数据库实例名变为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