http://blog.sina.com.cn/s/blog_69b504430100w3rp.html
Solaris 10: 如何转换legacy_run服务跟大家公享一篇挺不错的文档, 源于 Convert legacy_run service without rebootTable of Contents1 Introduction2 Current environment3 Convert daemon into SMF service3.1 Stop current daemon3.2 Create service method3.3 Create service manifest3.4 Create new SMF service4 Run new SMF service5 Check new environment6 Remove legacy_run entry7 Disclaimer1 IntroductionAt 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 environmentserver # svcs | grep petervglegacy_run 13:06:32 lrc:/etc/rc3_d/S95petervgdserver # ps -o pid,ppid,args -e | grep petervg509 1 /usr/bin/ksh /opt/petervgd/petervgdserver # cd /opt/petervgdserver # ls -ltotal 2-rwxr-xr-x 1 root root 55 Oct2 12:56 petervgd3 Convert daemon into SMF service3.1 Stop current daemonserver # /etc/init.d/petervgd stoppetervg went asleepTerminatedserver # rm /etc/rc3.d/S95petervgd3.2 Create service methodWe can use an old-style Start/Stop script for a SMF service method.server # cd /opt/petervgdserver # mv /etc/init.d/petervgd ./petervgd.methodserver # ls -ltotal 4-rwxr-xr-x 1 root root 55 Oct2 12:56 petervgd-rwxr-xr-x 1 root root 162 Oct2 12:57 petervgd.methodAdd the following line to the beginning of the method:. /lib/svc/share/smf_include.shserver # cat petervg.method#! /usr/bin/ksh. /lib/svc/share/smf_include.shcase "$1" instart)echo "petervg woke up"/opt/petervgd/petervgd &;;stop) echo "petervg went asleep"pkill petervgd;;esac# eos3.3 Create service manifestEach 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.xmlserver # vi /petervgd.xmlChange/Add/Delete any settings that needs to be modified in the manifest. Do not forget tovmstat 中 faults sy一项越来越大,代表什么意思?
change the name of the service into something different then application/print/cleanup.3.4 Create new SMF serviceserver # svccfg import petervgd.xmlserver # svcs "*petervg*"STATE STIME FMRIlegacy_run 13:06:32 lrc:/etc/rc3_d/S95petervgddisabled 14:47:32 svc:/site/petervgd:default4 Run new SMF serviceserver # ps -o pid,ppid,args -e | grep petervgserver # svcadm enable petervgdserver # ps -o pid,ppid,args -e | grep peter1426 1 /usr/bin/ksh /opt/petervgd/petervgd5 Check new environmentserver # svcs "*petervg*"STATE STIME FMRIlegacy_run 13:06:32 lrc:/etc/rc3_d/S95petervgdonline 14:58:54 svc:/site/petervgd:defaultThere you have it. Your daemon is now running as a SMF service.6 Remove legacy_run entryOne 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_runsvc:/smf/legacy_run>svc:/smf/legacy_run> listpg *peter*rc3_d_S95petervgdframework NONPERSISTENTsvc:/smf/legacy_run> delpg rc3_d_S95petervgdsvc:/smf/legacy_run> exit## svcs "*petervg*"STATE STIME FMRIonline 14:58:54 svc:/site/petervgd:default7 DisclaimerI'm in no way responsible for what you do. Not even when you do it after reading my documents.
阅读(1690) | 评论(0) | 转发(0) |