免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4756 | 回复: 1
打印 上一主题 下一主题

Solaris 10: 如何转换legacy_run服务 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-03-04 10:49 |只看该作者 |倒序浏览
跟大家公享一篇挺不错的文档, 源于 http://www2.petervg.nl/cgi-bin/docs.cgi?a=read&doc=211

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[23].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 Oct  2 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 Oct  2 12:56 petervgd
-rwxr-xr-x   1 root     root         162 Oct  2 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 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[23].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_S95petervgd  framework    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.

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
2 [报告]
发表于 2013-06-05 10:52 |只看该作者
grea t!很好很强大!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP