centos7.2 oracle10g 如何修改sid实例名

前端之家收集整理的这篇文章主要介绍了centos7.2 oracle10g 如何修改sid实例名前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

主机名改变后需要更改改下面的文件

1.监听里的host需要更改如下:

/u01/app/oracle/product/10.2.0/db_1/network/admin

修改如下文件主机名

sed –i 's/ora10/oracle10/g'/u01/app/oracle/product/10.2.0/db_1/network/admin/ listener.ora

[oracle@host-192-168-246-161 admin]$ cat listener.ora

# listener.ora Network Configuration File:/u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME =PLSExtProc)

(ORACLE_HOME =/u01/app/oracle/product/10.2.0/db_1)

(PROGRAM = extproc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS =(PROTOCOL = TCP)(HOST = oracle10)(PORT= 1521))

(ADDRESS =(PROTOCOL = IPC)(KEY = EXTPROC0))

)

)

2.修改主机名

hostnamectl set-hostnameoracle

vi /etc/hosts

192.168.246.161oracle10

修改实例名sid

1.检查原来数据库

[oracle@oracle admin]$ echo $ORACLE_SID

ora10

[oracle@oracle admin]$ sqlplus / as sysdba

sql*Plus: Release 10.2.0.1.0 - Production on Fri Sep 8 11:04:152017

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

sql> select instance from v$thread;

INSTANCE

--------------------------------

ora10

2.修改Oracle用户的ORACLE_SID环境变量,如由orc10修改为oracle10

[oracle@oracle admin]$ cat ~/.bash_profile | grep -i sid

export ORACLE_SID=ora10

[oracle@oracle admin]$ sed -i 's/ora10/oracle10/g' ~/.bash_profile

[oracle@oracle admin]$ cat ~/.bash_profile | grep -i sid

export ORACLE_SID=oracle10

3.使新修改的ORACLE_SID环境变量生效

[oracle@oracle dbs]$ source ~/.bash_profile

[oracle@oracle dbs]$ echo $ORACLE_SID

oracle10

4.修改/etc/oratab文件,将sid名由旧的修改为新的,如从orc10修改为oracle10

[oracle@oracle admin]$ vi /etc/oratab

oracle10:/u01/app/oracle/product/10.2.0/db_1:Y

[oracle@oracle admin]$cd $ORACLE_HOME/dbs

[oracle@oracle dbs]$ pwd

/u01/app/oracle/product/10.2.0/db_1/dbs

5.将所有文件名中包含原来的sid修改为对应的新sid的如我对如下文件修改为其后对应的文件

hc_orc10.dat->hc_oracl10.dat

lkORCL->lkORACLE10

orapworcl->orapworacle10

snapcf_orcl.f->snapcf_oracle10.f

spfileorcl.ora->spfileoracle10.ora

mv hc_orc10.dat hc_oracl10.dat

mv lkORCL lkORACLE10

mv orapworcl orapworacle10

mv snapcf_orcl.f snapcf_oracle10.f

mv spfileorcl.ora spfileoracle10.ora

[oracle@oracle dbs]$orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle entries=5force=y

[oracle@oracle dbs]$ ls -lrt orapw*

-rw-r----- 1 oracle oinstall 2048 Sep 8 11:36 orapworacle10

[oracle@oracle ora10]$ cp$ORACLE_BASE/admin/ora10/pfile/init.ora.852017173323 /u01/app/oracle/product/10.2.0/db_1/dbs/initoracle10.ora

[oracle@oracle dbs]$ sqlplus / as sysdba

sql*Plus: Release 10.2.0.1.0 - Production on Fri Sep 8 11:44:592017

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

Connected to an idle instance.

sql> startup

ORACLE instance started.

Total System Global Area 4966055936 bytes

Fixed Size2027544 bytes

Variable Size889196520 bytes

Database Buffers4060086272 bytes

Redo Buffers14745600 bytes

Database mounted.

Database opened.

sql>

检查数据库实例名

1. 通过如下语句检查数据库实例名,发现实例名已经由orcl变成oracle10

idle> select instance from v$thread;

INSTANCE
--------------------------------------------------------------------------------
oracle10

2.修改数据库名(dbname)

虽然已经修改过了实例名(sid),但是数据库名称(dbname还是原来的名称orcl)

dle> conn / as sysdba
Connected.
sql> show parameter name

NAME TYPE VALUE

------------------------------------ -----------------------------------------

db_file_name_convertstring

db_name string ora10

db_unique_name string ora10

global_names boolean FALSE

instance_name string oracle10

lock_name_space string

log_file_name_convert string

service_names string ora10

可以通过如下步骤修改数据库名(dbname

1. 首先切换一下在线日志,使数据库做checkpoint

sys@ORCL> alter system archive log current;

System altered.

2. 生成重建控制文件的脚本

sys@ORCL> alter database backup controlfile to trace resetlogs;

Database altered.

3. 关闭数据库,需要干净关闭,不能shutdownabort

sys@ORCL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

sql> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production

With the Partitioning,OLAP and Data Mining options

4.进入$ORACLE_BASE/admin/<sid>/udump目录中,找到最新生成的trc文件,这就是重建控制文件的脚本

cd/u01/app/oracle/admin/ora10/udump

5. 将找到的trc文件复制一份,并命名为ccf.sql

[oracle@oracle udump]$ cp oracle10_ora_2768.trc ccf.sql

查找STARTUPNOMOUNT语句,将这一行上面的所有行都删除
查找所有以--开始的行,把这些行删除
查找所有的orcl修改为cnhtm,所有的ORCL修改为CNHTM
找到CREATE CONTROLFILEREUSE DATABASE...语句,将其中的REUSE修改为SET
找到RECOVER DATABASE USINGBACKUP CONTROLFILE语句,将其用双横线(--)注释掉

6.修改实例名称和目录

[oracle@oracle ~]$ sed -i 's/ora10/oracle10/g'/u01/app/oracle/admin/ora10/udump/ccf.sql

[oracle@oracle ~]$ sed -i 's/ORA10/ORACLE10/g'/u01/app/oracle/admin/ora10/udump/ccf.sql

[oracle@oracle ~]$ mv /u01/app/oracle/oradata/ora10/u01/app/oracle/oradata/oracle10

[oracle@oracle ~]$ vi/u01/app/oracle/admin/oracle10/udump/ccf.sql

STARTUP NOMOUNT

CREATE CONTROLFILE SET DATABASE "ORACLE10"RESETLOGS ARCHIVELOG

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 292

LOGFILE

GROUP 1'/u01/app/oracle/oradata/oracle10/redo01.log' SIZE 50M,

GROUP 2'/u01/app/oracle/oradata/oracle10/redo02.log' SIZE 50M,

GROUP 3'/u01/app/oracle/oradata/oracle10/redo03.log' SIZE 50M

DATAFILE

'/u01/app/oracle/oradata/oracle10/system01.dbf',

'/u01/app/oracle/oradata/oracle10/undotbs01.dbf',

'/u01/app/oracle/oradata/oracle10/sysaux01.dbf',

'/u01/app/oracle/oradata/oracle10/users01.dbf',

'/u01/app/oracle/oradata/oracle10/example01.dbf'

CHARACTER SET ZHS16GBK

;

--RECOVER DATABASE USINGBACKUP CONTROLFILE

ALTER DATABASE OPEN RESETLOGS;

ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/oracle10/temp01.dbf'

SIZE 20971520 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;

7.如果归档日志目录名中包含sid,那么修改归档目录名

归档目录使用的是flash_recovery_area,所以需要将这个目录中的ORCL目录重命名为ORACLE10

[oracle@oracle ~]$ mv /u01/app/oracle/admin/ora10/u01/app/oracle/admin/oracle10

mv /u01/app/oracle/flash_recovery_area/ORA10 /u01/app/oracle/flash_recovery_area/ORACLE10

[oracle@oracle dbs]$ sed -i 's/ora10/oracle10/g'/u01/app/oracle/product/10.2.0/db_1/dbs/initoracle10.ora

8.删除之前的控制文件

rm -rf /u01/app/oracle/oradata/oracle10/control*

9. 加载修改好的ccf.sql

isql> @/u01/app/oracle/admin/oracle10/udump/ccf.sql

ORACLE instance started.

Total System Global Area 4966055936 bytes

Fixed Size 2027544 bytes

Variable Size 889196520 bytes

Database Buffers 4060086272 bytes

Redo Buffers 14745600 bytes

Control file created.

Database altered.

Tablespace altered.

10. 检查数据库状态

sql> conn / as sysdba

Connected.

sql> select open_mode from v$database;

OPEN_MODE

----------

READ WRITE

sql> show parameter name

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

db_file_name_convert string

db_name string oracle10

db_unique_name string oracle10

global_names boolean FALSE

instance_name string oracle10

lock_name_space string

log_file_name_convert string

service_names string oracle10

发现数据库名(db_name)已经修改为oracle10

原文链接:https://www.f2er.com/centos/375973.html

猜你在找的CentOS相关文章