Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1011116
  • 博文数量: 584
  • 博客积分: 2293
  • 博客等级: 大尉
  • 技术积分: 3045
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-28 11:15
文章分类

全部博文(584)

文章存档

2012年(532)

2011年(47)

2009年(5)

我的朋友

分类: Oracle

2012-01-30 10:55:10

http://blog.sina.com.cn/s/blog_69b504430100w3rp.html

Solaris 10: 如何转换legacy_run服务跟大家公享一篇挺不错的文档, 源于

Convert legacy_run service without reboot
Table of Contents

1 Introduction
2 Current environment
3 Convert daemon into SMF service
3.1 Stop current daemon
3.2 Create service method
3.3 Create service manifest
3.4 Create new SMF service
4 Run new SMF service
5 Check new environment
6 Remove legacy_run entry
7 Disclaimer

1 Introduction
At boot your server starts a daemon with a script in /etc/init.d (/etc/rc.d). In Solaris 10 this will be a legacy_run service and it won't use any of the extra features provided by SMF.

So you decide to convert the legacy_run service into a real SMF service. After all the hard work you managed to convert the legacy_run service into a real service but how do you remove the legacy_run service from your server? svcs still shows the legacy_run service.

2 Current environment
server # svcs | grep petervg
legacy_run 13:06:32 lrc:/etc/rc3_d/S95petervgd

server # ps -o pid,ppid,args -e | grep petervg
509 1 /usr/bin/ksh /opt/petervgd/petervgd

server # cd /opt/petervgd
server # ls -l
total 2
-rwxr-xr-x 1 root root 55 Oct2 12:56 petervgd
3 Convert daemon into SMF service
3.1 Stop current daemon
server # /etc/init.d/petervgd stop
petervg went asleep
Terminated

server # rm /etc/rc3.d/S95petervgd
3.2 Create service method
We can use an old-style Start/Stop script for a SMF service method.

server # cd /opt/petervgd
server # mv /etc/init.d/petervgd ./petervgd.method

server # ls -l
total 4
-rwxr-xr-x 1 root root 55 Oct2 12:56 petervgd
-rwxr-xr-x 1 root root 162 Oct2 12:57 petervgd.method
Add the following line to the beginning of the method:
. /lib/svc/share/smf_include.sh

server # cat petervg.method
#! /usr/bin/ksh

. /lib/svc/share/smf_include.sh

case "$1" in
start)echo "petervg woke up"
/opt/petervgd/petervgd &
;;
stop) echo "petervg went asleep"
pkill petervgd
;;
esac

# eos
3.3 Create service manifest
Each service needs a description file which lists properties of the service like name, dependencies, use of contract, etc.

server # cp /var/svc/manifest/application/print/cleanup.xml petervgd.xml

server # vi /petervgd.xml
Change/Add/Delete any settings that needs to be modified in the manifest. Do not forget to

vmstat 中 faults sy一项越来越大,代表什么意思?

change the name of the service into something different then application/print/cleanup.

3.4 Create new SMF service
server # svccfg import petervgd.xml
server # svcs "*petervg*"
STATE STIME FMRI
legacy_run 13:06:32 lrc:/etc/rc3_d/S95petervgd
disabled 14:47:32 svc:/site/petervgd:default
4 Run new SMF service
server # ps -o pid,ppid,args -e | grep petervg

server # svcadm enable petervgd

server # ps -o pid,ppid,args -e | grep peter
1426 1 /usr/bin/ksh /opt/petervgd/petervgd
5 Check new environment
server # svcs "*petervg*"
STATE STIME FMRI
legacy_run 13:06:32 lrc:/etc/rc3_d/S95petervgd
online 14:58:54 svc:/site/petervgd:default
There you have it. Your daemon is now running as a SMF service.

6 Remove legacy_run entry
One way of removing the legacy_run entry is rebooting your server. At the next boot the system will not find anything about your daemon in /etc/rc.d and therefor not start the legacy_run service.

The second method is by manually removing the entries about your legacy_run service from the /etc/repository.db database.

server # svccfg -s smf/legacy_run
svc:/smf/legacy_run>

svc:/smf/legacy_run> listpg *peter*
rc3_d_S95petervgdframework NONPERSISTENT

svc:/smf/legacy_run> delpg rc3_d_S95petervgd
svc:/smf/legacy_run> exit
#

# svcs "*petervg*"
STATE STIME FMRI
online 14:58:54 svc:/site/petervgd:default

7 Disclaimer
I'm in no way responsible for what you do. Not even when you do it after reading my documents.
阅读(1687) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~