service的创建与使用

本文详细介绍了在Oracle RAC环境中如何使用srvctl命令进行服务的创建、启动、停止及状态查询等操作。并通过实例展示了服务如何在不同实例间迁移及故障转移的过程。
1.DBCA创建service

2. srvctl创建service

--创建service
[oracle@rac01 admin]$ srvctl add service -d mbs -s batch -r mbs2 -a mbs1
--启动service 
[oracle@rac01 admin]$ srvctl start service -d mbs -s batch 
--查看service运行状态
[oracle@rac01 admin]$  srvctl status database -d mbs -f -v
Instance mbs1 is running on node rac01
Instance mbs2 is running on node rac02 with online services batch 

可见batch已经被注册到ocr中,且运行在实例mbs2上,此时关闭实例mbs2,则batch将在实例mbs1上运行。

[oracle@rac01 admin]$ srvctl stop instance -d mbs -i mbs2
[oracle@rac01 admin]$ srvctl status database -d mbs -f -v
Instance mbs1 is running on node rac01 with online services batch 
Instance mbs2 is not running on node rac02

重新启动实例mbs2,查看service的运行情况:

[oracle@rac01 admin]$ srvctl start instance -d mbs -i mbs2
[oracle@rac01 admin]$ srvctl status database -d mbs -f -v
Instance mbs1 is running on node rac01 with online services batch 
Instance mbs2 is running on node rac02

可见,service仍然运行在实例mbs1上,并没有回到mbs2。手动停止service,并在mbs2上运行service

[oracle@rac01 admin]$ srvctl stop service -d mbs -s batch -i mbs1
[oracle@rac01 admin]$ srvctl status database -d mbs -f -v
Instance mbs1 is running on node rac01
Instance mbs2 is running on node rac02
[oracle@rac01 admin]$ srvctl start service -d mbs -s batch -i mbs2
[oracle@rac01 admin]$ srvctl status database -d mbs -f -v
Instance mbs1 is running on node rac01
Instance mbs2 is running on node rac02 with online services batch 

service的使用:

tnsnames.ora里面配置如下:

BATCH =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac01-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac02-vip)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = batch)
    )
  )

[oracle@rac01 admin]$ sqlplus scott/tiger@batch

SQL*Plus: Release 10.2.0.5.0 - Production on Mon Sep 3 14:16:24 2012

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
mbs2

将实例mbs2停止,再重新连接到数据库:

[oracle@rac01 admin]$ srvctl stop instance -d mbs -i mbs2
[oracle@rac01 admin]$ sqlplus scott/tiger@batch

SQL*Plus: Release 10.2.0.5.0 - Production on Mon Sep 3 14:19:04 2012

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
mbs1

此时service已经自动运行到实例mbs1上了。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10972173/viewspace-742540/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10972173/viewspace-742540/

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值