remove the service in oracle rac 10205

删除service

NAME=ora.rac.testservice.cs
TYPE=application
TARGET=ONLINE
STATE=ONLINE on rac1

可以看到有一个service(testservice)注册到了crs中,但需要注意的话,用户尽管使用了dbca创建service,但是TAF的策略还是需要借助dbms_service包来搞定,
而你所看见的service很可能是个半残品,service的配置不仅要体现在CRS中(OCR),而且还要体现在show parameter的参数文件中、dba_services的数据字典中。

下面来尝试删除这个service…..

查看这个service的当前状态:
[oracle@rac2 ~]$ srvctl config service -d rac -s testservice -a
testservice PREF: rac1 AVAIL: rac2 TAF: basic

“PREF”是rac1,avail是rac2,TAF策略是basic,而type之类的就没看到

先把启动的service关闭掉

[oracle@rac2 ~]$ srvctl stop service -d rac -s testservice
使用crs_stat查看一下注册在OCR中的状态,有两条记录offline了。


[oracle@rac2 ~]$ crs_stat -t
Name Type Target State Host
————————————————————
ora.rac.db application ONLINE ONLINE rac1
ora….c1.inst application ONLINE ONLINE rac1
ora….c2.inst application ONLINE ONLINE rac2
ora….vice.cs application OFFLINE OFFLINE
ora….ac1.srv application OFFLINE OFFLINE
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….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

尽管testservice已经被stop掉了,我们查看一下service的状态。

[oracle@rac2 ~]$ srvctl config service -d rac -s testservice -a
testservice PREF: rac1 AVAIL: rac2 TAF: basic
testservice的配置信息还是记录在配置文件中的,只是被暂时stop掉了。

将它disable,看看有何结果?

[oracle@rac2 ~]$ srvctl disable service -d rac -s testservice
[oracle@rac2 ~]$ srvctl config service -d rac -s testservice -a
testservice PREF: rac1 AVAIL: rac2 TAF: basic
Service testservice is disabled.
被disable之后,service的状态会被显示的告知:”is disable”

彻底remove这个service的配置
[oracle@rac2 ~]$ srvctl remove service -d rac -s testservice
testservice PREF: rac1 AVAIL: rac2
Service testservice is disabled.
Remove service testservice from the database rac? (y/[n]) y
会提示你是否要remove掉这个service?

testservice的配置信息已经没有了,再次想查看其信息时,会反馈”找不到”。
[oracle@rac2 ~]$ srvctl config service -d rac -s testservice -a
PRKO-2017 : Service testservice does not exist for database rac.

crs中少了两条记录(之前被offline的)
[oracle@rac2 ~]$ crs_stat -t
Name Type Target State Host
————————————————————
ora.rac.db application ONLINE ONLINE rac1
ora….c1.inst application ONLINE ONLINE rac1
ora….c2.inst application ONLINE ONLINE rac2
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….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中的相关service记录已经清除干净了,但数据字典中还会残留一些信息,如下:
SQL> select name,enabled from dba_services;

NAME ENA
—————————————- —
SYS$BACKGROUND NO
SYS$USERS NO
seeddataXDB NO
seeddata NO
racXDB NO
rac.world NO
testservice NO

testservice的信息还驻留在dba_services视图中,轮到dbms_service包出场了。
SQL> begin
2 dbms_service.delete_service(service_name=>’testservice’);
3 end;
4 /
begin
*
ERROR at line 1:
ORA-44303: service name exists
ORA-06512: at “SYS.DBMS_SERVICE”, line 442
ORA-06512: at “SYS.DBMS_SERVICE”, line 342
ORA-06512: at line 2

遇到报错,但查询一下dba_services,testservice的记录消失了..(奇怪了),再次执行dbms_service.delete_service后,会报错类似”service name not exist”的错误。

SQL> select name,enabled from dba_services;

NAME ENA
—————————————————————- —
SYS$BACKGROUND NO
SYS$USERS NO
seeddataXDB NO
seeddata NO
racXDB NO
rac.world NO

–EOF–