ITPub博客

首页 > Linux操作系统 > Linux操作系统 > service的创建与使用

service的创建与使用

原创 Linux操作系统 作者:lsq_008 时间:2012-09-03 14:12:34 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/10972173/viewspace-742540/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
十余年大型金融及电信系统数据库管理经验,曾服务于中国建设银行、中国移动。对oracle,mysql数据库有深入了解。 擅长python开发,独立开发了开源数据库自动化监控运维平台Power Monitor。

注册时间:2008-02-29

  • 博文量
    335
  • 访问量
    1369103