下面是更改的部分步骤,但是启动问题还是存在,求达人完整。

单实例的数据库修改SID比较简单,只需要修改pfile相关参数,就可以挂载数据库。 RAC环境其实一样,只不过除了修改pfile,还需要修改 OCR信息。


首先来看看RAC的状态:

[root@rac1 tmp]# /u01/app/crs/bin/crs_stat -t

Name Type Target State Host

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

ora.orcl.db application ONLINE ONLINE rac1

ora....l1.inst application ONLINE ONLINE rac1

ora....l2.inst application ONLINE ONLINE rac2

ora....SM1.asm application ONLINE ONLINE rac1

ora....C1.lsnr application ONLINE ONLINE rac1

ora.rac1.gsd application ONLINE ONLINE rac1

ora.rac1.ons application ONLINE ONLINE rac1

ora.rac1.vip application ONLINE ONLINE rac1

ora....SM2.asm application ONLINE ONLINE rac2

ora....C2.lsnr application ONLINE ONLINE rac2

ora.rac2.gsd application ONLINE ONLINE rac2

ora.rac2.ons application ONLINE ONLINE rac2

ora.rac2.vip application ONLINE ONLINE rac2


现在RAC状态一切正常,所有服务已经启动。下面来试下如何修改2台RAC机器的SID,分别修改为:orcl3, orcl4


1. 创建pfile,然后把orcl1--->orcl3 orcl2--->orcl4,并传输给另外一个节点,其他参数不任何变更

SQL> conn /as sysdba

Connected.

SQL> create pfile='/tmp/pfile' from spfile;


File created.


[oracle@rac1 companion]$ scp /tmp/pfile 192.168.18.9:/tmp

pfile 100% 1290 1.3KB/s 00:00


[oracle@rac1 companion]$ cat /tmp/pfile

orcl4.__db_cache_size=75497472

orcl3.__db_cache_size=58720256

orcl3.__java_pool_size=4194304

orcl4.__java_pool_size=4194304

orcl3.__large_pool_size=4194304

orcl4.__large_pool_size=4194304

orcl4.__shared_pool_size=79691776

orcl3.__shared_pool_size=96468992

orcl3.__streams_pool_size=0

orcl4.__streams_pool_size=0

*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'

*.background_dump_dest='/u01/app/oracle/admin/orcl/bdump'

*.cluster_database_instances=2

*.cluster_database=true

*.compatible='10.2.0.1.0'

*.control_files='+DATA1/orcl/controlfile/current.260.696461787'

*.core_dump_dest='/u01/app/oracle/admin/orcl/cdump'

*.db_block_size=8192

*.db_create_file_dest='+DATA1'

*.db_domain='oracle.com'

*.db_file_multiblock_read_count=16

*.db_name='orcl'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'

orcl4.instance_number=2

orcl3.instance_number=1

*.job_queue_processes=10

*.log_archive_dest_1='LOCATION=+DATA1/orcl/'

*.log_archive_format='%t_%s_%r.dbf'

*.open_cursors=300

*.pga_aggregate_target=16777216

*.processes=150

*.remote_listener='LISTENERS_ORCL'

*.remote_login_passwordfile='exclusive'

*.sga_target=167772160

orcl4.thread=2

orcl3.thread=1

*.undo_management='AUTO'

orcl3.undo_tablespace='UNDOTBS1'

orcl4.undo_tablespace='UNDOTBS2'

*.user_dump_dest='/u01/app/oracle/admin/orcl/udump'


2. 停止2台节点的数据库(2个节点运行,当然也可以使用srvctl)

SQL> conn /as sysdba

Connected.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>

再来看看状态:

[root@rac1 tmp]# /u01/app/crs/bin/crs_stat -t

Name Type Target State Host

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

ora.orcl.db application OFFLINE OFFLINE

ora....l1.inst application OFFLINE OFFLINE

ora....l2.inst application OFFLINE OFFLINE

ora....SM1.asm application ONLINE ONLINE rac1

ora....C1.lsnr application ONLINE ONLINE rac1

ora.rac1.gsd application ONLINE ONLINE rac1

ora.rac1.ons application ONLINE ONLINE rac1

ora.rac1.vip application ONLINE ONLINE rac1

ora....SM2.asm application ONLINE ONLINE rac2

ora....C2.lsnr application ONLINE ONLINE rac2

ora.rac2.gsd application ONLINE ONLINE rac2

ora.rac2.ons application ONLINE ONLINE rac2

ora.rac2.vip application ONLINE ONLINE rac2


可以看到instance都已经停止。


3. 修改 .bash_profile的ORACLE_SID的环境变量,其他的不需要修改(2个节点)

export ORACLE_SID=orcl3


export ORACLE_SID=orcl4



4. 通过pfile启动数据库(2个节点运行)

SQL> conn /as sysdba

Connected to an idle instance.

SQL> startup pfile='/tmp/pfile';

ORACLE instance started.


Total System Global Area 167772160 bytes

Fixed Size 1218316 bytes

Variable Size 88082676 bytes

Database Buffers 75497472 bytes

Redo Buffers 2973696 bytes

Database mounted.

Database opened.

再查看相关RAC状态:


[root@rac1 tmp]# /u01/app/crs/bin/crs_stat -t

Name Type Target State Host

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

ora.orcl.db application OFFLINE OFFLINE

ora....l1.inst application OFFLINE OFFLINE

ora....l2.inst application OFFLINE OFFLINE

ora....SM1.asm application ONLINE ONLINE rac1

ora....C1.lsnr application ONLINE ONLINE rac1

ora.rac1.gsd application ONLINE ONLINE rac1

ora.rac1.ons application ONLINE ONLINE rac1

ora.rac1.vip application ONLINE ONLINE rac1

ora....SM2.asm application ONLINE ONLINE rac2

ora....C2.lsnr application ONLINE ONLINE rac2

ora.rac2.gsd application ONLINE ONLINE rac2

ora.rac2.ons application ONLINE ONLINE rac2

ora.rac2.vip application ONLINE ONLINE rac2


可以看到,虽然启动,但是由于OCR信息并没有修改,所有CRS显示出来并不正确。接下来就是要更新OCR的信息。


在修改之前,先来做个测试:

在RAC1运行;

SQL> create table test(id number);


Table created.


SQL> insert into test values(1);


1 row created.


SQL> commit;


Commit complete.

在RAC2查看是否有问题:


SQL> select * from test;


ID

----------

1


再继续看:


SQL> show parameter instance_name


NAME TYPE VALUE

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

instance_name string orcl3


SQL> show parameter instance_name


NAME TYPE VALUE

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

instance_name string orcl4


可以看到,数据库中instance_name已经修改了。


5. 最后就是更新OCR


首先先移除原来的SID信息:

先移除数据库注册信息

Srvctl remove databse –d orcl

再移除数据库实例注册信息

[oracle@rac1 ~]$ srvctl remove instance -d orcl -i orcl1

Remove instance orcl1 from the database orcl? (y/[n]) y

[oracle@rac1 ~]$ srvctl remove instance -d orcl -i orcl2

Remove instance orcl2 from the database orcl? (y/[n]) y


查看CRS状态:

[root@rac1 tmp]# /u01/app/crs/bin/crs_stat -t

Name Type Target State Host

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

ora.orcl.db application OFFLINE OFFLINE

ora....SM1.asm application ONLINE ONLINE rac1

ora....C1.lsnr application ONLINE ONLINE rac1

ora.rac1.gsd application ONLINE ONLINE rac1

ora.rac1.ons application ONLINE ONLINE rac1

ora.rac1.vip application ONLINE ONLINE rac1

ora....SM2.asm application ONLINE ONLINE rac2

ora....C2.lsnr application ONLINE ONLINE rac2

ora.rac2.gsd application ONLINE ONLINE rac2

ora.rac2.ons application ONLINE ONLINE rac2

ora.rac2.vip application ONLINE ONLINE rac2


信息已经移除,接下来就是重新注册新的instance了。


[oracle@rac1 ~]$ srvctl add instance -d orcl -i orcl3 -n rac1

[oracle@rac1 ~]$ srvctl add instance -d orcl -i orcl4 -n rac2


查看CRS状态:


[root@rac1 tmp]# /u01/app/crs/bin/crs_stat -t

Name Type Target State Host

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

ora.orcl.db application OFFLINE OFFLINE

ora....l3.inst application OFFLINE OFFLINE

ora....l4.inst application OFFLINE OFFLINE

ora....SM1.asm application ONLINE ONLINE rac1

ora....C1.lsnr application ONLINE ONLINE rac1

ora.rac1.gsd application ONLINE ONLINE rac1

ora.rac1.ons application ONLINE ONLINE rac1

ora.rac1.vip application ONLINE ONLINE rac1

ora....SM2.asm application ONLINE ONLINE rac2

ora....C2.lsnr application ONLINE ONLINE rac2

ora.rac2.gsd application ONLINE ONLINE rac2

ora.rac2.ons application ONLINE ONLINE rac2

ora.rac2.vip application ONLINE ONLINE rac2


已经注册成功,可以发现instance变为orcl3,orcl4了。


后面缺少重建SPFILE文件的步骤。。。。

感觉可以用create spfile from pfile='/tmp/pfile';,来覆盖

但是不确定


oracle视频教程请关注:http://down.51cto.com/4202939/up