mac_xuyi 发表于 2011-12-22 11:29

Solaris 中系统服务的管理

Solaris 中系统服务的管理








Solaris系统,跟windows类似,也是有服务概念的.最常用的服务,有ssh,telnet.在windows中,服务的管理是通过运行services.msc,进入系统服务管理界面中管理的.在Solaris底下,也有类似工具.

1.服务查看
    svcs可以查看系统中的服务.加上-a开关后,可以查看被disable了的服务,即被禁止启动了的服务.
----------------------------------------------------------------
bash-3.00# svcs -a | less
STATE          STIME    FMRI
legacy_run   15:00:58 lrc:/etc/rc3_d/S52imq
legacy_run   15:00:58 lrc:/etc/rc3_d/S80mipagent
legacy_run   15:00:58 lrc:/etc/rc3_d/S84appserv
disabled       15:00:21 svc:/system/metainit:default
disabled       15:00:21 svc:/system/device/mpxio-upgrade:default
disabled       15:00:22 svc:/network/ipsec/ike:default

    关于服务状态,从man smf中了解到,Solaris系统中的服务有以下状态:
   UNINITIALIZED    This is the initial state forallservice
                      instances.Instancesare moved to mainte-
                      nance, offline, or adisabledstateupon
                      evaluation   by   svc.startd(1M)   or   the
                      appropriate restarter.

   OFFLINE          The instance is enabled, but notyetrun-
                      ning or available to run. If restarter exe-
                      cution of the service start methodorthe
                      equivalent   method   is   successful,the
                      instancemovesto   the   online   state.
                      Failures   mightleadtoadegradedor
                      maintenancestate.Administrativeaction
                      can lead to the uninitialized state.

   ONLINE         The instance is enabled and runningoris
                      availabletorun.The specific nature of
                      theonlinestate   is   application-model
                      specificandisdefined by the restarter
                      responsibleforthe   service   instance.
                      Onlineis the expected operating state for
                      aproperlyconfiguredservicewithall
                      dependenciessatisfied.Failuresofthe
                      instance can lead to a degraded ormainte-
                      nancestate. Failures of services on which
                      the instance depends can lead to offline or
                      degraded states.

   DEGRADED         The instanceisenabledandrunningor
                      available to run. The instance, however, is
                      functioning at a limited capacityincom-
                      parisontonormaloperation. Failures of
                      the instance can leadtothemaintenance
                      state.Failuresofservices on which the
                      instance depends canleadtoofflineor
                      degradedstates.Restorationof capacity
                      should result in a transition to the online
                      state.

   MAINTENANCE      The instance is enabled, butnotableto
                      run.Administrativeaction is required to
                      restore the instance to offline andsubse-
                      quentstates.The maintenance state might
                      be a temporarily reached state if an admin-
                      istrative operation is underway.

   DISABLED         The instance is disabled. Enabling the ser-
                      vice results in a transition to the offline
                      state and eventually totheonlinestate
                      with all dependencies satisfied.

   LEGACY-RUN       This staterepresentsalegacyinstance
                      thatis not managed by the service manage-
                      ment facility. Instances in this state have
                      beenstartedatsome point, but might or
                      might not be running. Instances can only be
                      observedusingthefacilityand are not
                      transferred into other states.

----------------------------------------------------------------
2.服务起停
    svcadm用来对服务进行起停禁用管理.
用法:svcadm [-v] [命令 [参数 ...]]

      svcadm enable [-rst] <服务> ... - 启用服务并使服务联机
      svcadm disable [-st] <服务> ... - 禁用服务并使服务脱机
      svcadm restart <服务> ...               - 重新启动指定的服务
      svcadm refresh <服务> ...               - 重新读取服务配置
      svcadm mark [-It] <状态> <服务> ...   - 设置维护状态
      svcadm clear <服务> ...         - 清除维护状态
      svcadm milestone [-d] <里程碑>- 进入服务里程碑
   
3.服务配置与修改
    可以通过svccfg来修改系统的服务,不过由于对Solaris了解的不深,所以我也不太敢去修改系统中的服务.
   
    暂时就记录这么多.

财版 发表于 2011-12-22 16:47

学习了

o0不知火舞0o 发表于 2011-12-26 12:10

谢谢楼主了
页: [1]
查看完整版本: Solaris 中系统服务的管理