系统管理指南:基本管理

对服务管理工具进行故障排除

Procedure调试未启动的服务

在该过程中,打印服务处于禁用状态。

  1. 成为超级用户或同等角色。

    角色包含授权和具有一定权限的命令。有关角色的更多信息,请参见《系统管理指南:安全性服务》中的“配置 RBAC(任务列表)”

  2. 请求有关挂起服务的信息。


    # svcs -xv
    svc:/application/print/server:default (LP Print Service)
     State: disabled since Wed 13 Oct 2004 02:20:37 PM PDT
    Reason: Disabled by an administrator.
       See: http://sun.com/msg/SMF-8000-05
       See: man -M /usr/share/man -s 1M lpsched
    Impact: 2 services are not running:
            svc:/application/print/rfc1179:default
            svc:/application/print/ipp-listener:default

    -x 选项提供有关受到影响的服务实例的其他信息。

  3. 启用服务。


    # svcadm enable application/print/server
    

Procedure如何修复已损坏的系统信息库

以下过程显示如何将已损坏的系统信息库替换为缺省的系统信息库副本。系统信息库守护进程 svc.configd 在启动之后不会对配置系统信息库执行完整性检查。配置系统信息库存储在 /etc/svc/repository.db 中。配置系统信息库可能会由于以下某种原因而损坏:

如果完整性检查失败,svc.configd 守护进程会向控制台写入一条以下类似的消息:


svc.configd: smf(5) database integrity check of:

    /etc/svc/repository.db

  failed.  The database might be damaged or a media error might have
  prevented it from being verified.  Additional information useful to
  your service provider is in:

    /etc/svc/volatile/db_errors

  The system will not be able to boot until you have restored a working
  database.  svc.startd(1M) will provide a sulogin(1M) prompt for recovery
  purposes.  The command:

    /lib/svc/bin/restore_repository

  can be run to restore a backup version of your repository. See
  http://sun.com/msg/SMF-8000-MY for more information.

随后,svc.startd 守护进程将退出,并启动 sulogin,以便您进行维护。

  1. sulogin 提示符下输入 root 口令。借助 suloginroot 用户可以进入系统维护模式从而修复系统。

  2. 运行以下命令:


    # /lib/svc/bin/restore_repository
    

    运行此命令可指导您完成恢复未经损坏的备份所必需的步骤。SMF 会在系统的任何关键时刻自动提取系统信息库的备份。有关更多信息,请参见SMF 系统信息库备份

    在启动 /lib/svc/bin/restore_repository 命令之后,会显示一条以下类似的消息:


    Repository Restore utility
    See http://sun.com/msg/SMF-8000-MY for more information on the use of
    this script to restore backup copies of the smf(5) repository.
    
    If there are any problems which need human intervention, this script
    will give instructions and then exit back to your shell.
    
    Note that upon full completion of this script, the system will be
    rebooted using reboot(1M), which will interrupt any active services.

    如果要恢复的系统不是本地区域,则该脚本将说明如何使用读取和写入权限来重新挂载 //usr 文件系统,以便恢复数据库。该脚本会在列显这些说明之后退出。请按照这些说明执行操作,同时应特别注意可能出现的任何错误。

    在使用写入权限挂载了 root ( /) 文件系统之后,或者如果该系统是本地区域,则系统将提示您选择要恢复的系统信息库备份:


    The following backups of /etc/svc/repository.db exists, from
    oldest to newest:
    
    ... list of backups ...

    基于备份类型和备份时间来确定备份的名称。以 boot 开头的备份在系统引导之后、首次更改系统信息库之前完成。以 manifest_import 开头的备份在 svc:/system/manifest-import:default 完成其进程之后完成。备份时间以 YYYYMMDD_HHMMSS 格式提供。

  3. 输入相应的响应。

    通常会选择最新的备份选项。

    Please enter one of:
            1) boot, for the most recent post-boot backup
            2) manifest_import, for the most recent manifest_import backup.
            3) a specific backup repository from the above list
            4) -seed-, the initial starting repository. (All customizations
               will be lost.)
            5) -quit-, to cancel.
    
    Enter response [boot]:

    如果在未指定要恢复的备份的情况下按 Enter 键,则会选择用 [] 括起的缺省响应。选择 -quit- 会退出 restore_repository 脚本,并返回到 shell 提示符。


    注 –

    选择 -seed- 会恢复 seed 系统信息库。此系统信息库设计用于初始安装和升级过程。如非绝对必要,请勿使用 seed 系统信息库进行恢复。


    在选择了要恢复的备份之后,系统将对其进行验证并检查其完整性。如有任何问题,restore_repository 命令会列显错误消息并提示您进行其他选择。在选择了有效的备份之后,系统会列显如下信息,并提示您进行最终确认。

    After confirmation, the following steps will be taken:
    
    svc.startd(1M) and svc.configd(1M) will be quiesced, if running.
    /etc/svc/repository.db
        -- renamed --> /etc/svc/repository.db_old_YYYYMMDD_HHMMSS
    /etc/svc/volatile/db_errors
        -- copied --> /etc/svc/repository.db_old_YYYYMMDD_HHMMSS_errors
    repository_to_restore
        -- copied --> /etc/svc/repository.db
    and the system will be rebooted with reboot(1M).
    
    Proceed [yes/no]?
  4. 键入 yes 修复故障。

    restore_repository 命令执行了列出的所有操作之后,系统将重新引导。

Procedure如何在不启动任何服务的情况下引导

如果在启动服务时出现问题,有时系统会在引导过程中挂起。以下过程显示如何解决此问题。

  1. 在不启动任何服务的情况下引导。

    此命令指示 svc.startd 守护进程临时禁用所有的服务并在控制台上启动 sulogin


    ok boot -m milestone=none
    
  2. root 身份登录系统。

  3. 启用所有的服务。


    # svcadm milestone all
    
  4. 确定引导过程挂起的位置。

    在引导过程挂起时,通过运行 svcs -a 来确定哪些服务未在运行。在位于 /var/svc/log 中的日志文件中查找错误消息。

  5. 在问题得以修复之后,检验所有的服务是否已启动。

    1. 检验是否所有必需的服务都已联机。


      # svcs -x
      
    2. 检验是否满足 console-login 服务的相关性。

      以下命令检验控制台上的 login 进程是否将运行。


      # svcs -l system/console-login:default
      
  6. 继续执行正常的引导过程。

Procedure系统引导期间当 system/filesystem/local:default 服务失败时,如何强制出现 sulogin 提示符

引导 Solaris OS 时不需要的本地文件系统由 svc:/system/filesystem/local:default 服务挂载。当其中的任何文件系统无法挂载时,该服务将进入维护状态。系统将继续启动,并将启动不依赖 filesystem/local 的任何服务,而要求 filesystem/local 联机才能通过相关性启动的服务将不会启动。

要更改系统的配置,以在该服务失败后立即出现 sulogin 提示符(而不是允许系统继续启动),请按照下面的过程操作。

  1. 修改 system/console-login 服务。


    # svccfg -s svc:/system/console-login
    svc:/system/console-login> addpg site,filesystem-local dependency
    svc:/system/console-login> setprop site,filesystem-local/entities = fmri: svc:/system/filesystem/local
    
    svc:/system/console-login> setprop site,filesystem-local/grouping = astring: require_all
    
    svc:/system/console-login> setprop site,filesystem-local/restart_on = astring: none
    
    svc:/system/console-login> setprop site,filesystem-local/type = astring: service
    
    svc:/system/console-login> end
    
  2. 刷新该服务。


    # svcadm refresh console-login
    

示例 19–18 使用 Oracle Solaris JumpStart 强制出现 sulogin 提示符

将下面的命令保存到一个脚本中并将该脚本另存为 /etc/rcS.d/S01site-customfs


#!/bin/sh
#
# This script adds a dependency from console-login -> filesystem/local
# This forces the system to stop the boot process and drop to an sulogin prompt
# if any file system in filesystem/local fails to mount.

PATH=/usr/sbin:/usr/bin
export PATH

	svccfg -s svc:/system/console-login << EOF
addpg site,filesystem-local dependency
setprop site,filesystem-local/entities = fmri: svc:/system/filesystem/local
setprop site,filesystem-local/grouping = astring: require_all
setprop site,filesystem-local/restart_on = astring: none
setprop site,filesystem-local/type = astring: service
EOF

svcadm refresh svc:/system/console-login

[ -f /etc/rcS.d/S01site-customfs ] &&
    rm -f /etc/rcS.d/S01site-customfs

故障排除

system/filesystem/local:default 服务失败时,应当使用 svcs -vx 命令来标识该失败。在错误得以修复之后,可以使用下面的命令来清除错误状态并允许系统继续引导: svcadm clear filesystem/local