web-dev-qa-db-ja.com

Windowsサーバーでのサービスの開始順序とは

ほとんどのサーバーで正常に動作しているWindowsサービスがあります。しかし、1つのサーバーでは、ネットワークサービスが開始される前に開始されることがわかります。これによりサービスがハングし、その結果OSが起動しなくなります。また、スタックします。サービスの通常の開始順序は何ですか?私のWindowsサービスはTCP=接続を行います。遅延開始を追加する必要がありますか?その場合、すべてのサービスがこれらのネットワークサービスに従って遅延開始を行う必要はありませんか?どんな助けも大歓迎です。

7
mayooran

遅延開始の使用は、1つの考えられる解決策です。

別の可能性は、依存関係を追加して、サービスが必要な順序で起動するようにすることです。たとえば、NSIサービスが実行されるまでネットワーク接続が確立されないため、たとえばNSIサービスの前にサービスを開始したくない場合があります。したがって、依存関係を追加します。

から [〜#〜] msdn [〜#〜]

自動開始サービスがデマンド開始サービスに依存している場合、デマンド開始サービスも自動的に開始されます。

(開始順序の詳細については、MSDNの記事も参照してください。)

これら2つの方法のどちらでも機能する可能性がありますが、私があなただったら、この1つのサーバーの違いを理解することにもっと興味があります。システム設定を変更して、この1台のサーバーを他のサーバーと比較して「特別なスノーフレーク」にする前に、何が起こっているのか、なぜその理由を常に完全に理解することをお勧めします。

編集

「Windowsでのサービスの開始順序は何ですか」という質問についてもっと考えさせられました。つまり、exact順序であり、その質問は今までにないと思います少なくとも公にではなく、徹底的に回答されました。

これは、非常に複雑であることが一因であると思います。 Windowsサービスの正確な起動順序は常に変化しています。 「アーリースタートサービス」、「フェーズ1サービス」、「フェーズ2サービス」、サービスグル​​ープ、依存関係などにより開始されるサービスなどがあります。Windowsのバージョンやエディションによって若干異なります。 、および構成や展開オプションによっても異なります。したがって、「自動開始サービスの後に遅延開始サービスが開始する」など、最も一般的で相対的な用語以外で公式に文書化されているとは限りません。

それはまた、それが少し非決定的な状況であるという理由もあります。サービスコントロールマネージャー(ユーザーモードではservices.exe)がサービスに開始信号を送信し、その部分の順序はかなり決定的ですが、開始信号が送信される時間とサービスが実際に開始する時間は2つの異なるもの。 Windowsのプリエンプティブな性質のため、SCMがサービスAに開始コントロールを最初に送信した場合でも、サービスBの前にサービスAが開始することを常に保証することはできません。 (何らかの同期メカニズムを使用する場合を除きます。)

とにかく、起動時に少なくとも一部のSCMログを有効にして、SCMがすべてのサービスを時系列で開始するのを確認できると考えました。

これはWindows 10、RS1/1607です。前に述べたように、基本的に他のビルドでは結果が若干異なります。結果は長さと内容について編集されています。最初に、サービスが実行状態になった時系列の順序を示すのが最も興味深いと思います。必ずしもSCMがサービスを開始しようとした順序ではありません。

07/06/17-13:05:39.7425860 [SCM] service PlugPlay, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:39.8150411 [SCM] service Power, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000000
07/06/17-13:05:39.8629388 [SCM] service DcomLaunch, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000080
07/06/17-13:05:39.8699565 [SCM] service RpcEptMapper, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000000
07/06/17-13:05:39.8745944 [SCM] service RpcSs, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c0
07/06/17-13:05:39.9107503 [SCM] service BrokerInfrastructure, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00001080
07/06/17-13:05:39.9276072 [SCM] service LSM, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000000
07/06/17-13:05:40.0868049 [SCM] service SystemEventsBroker, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000012c1
07/06/17-13:05:40.4599977 [SCM] service nsi, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:40.4641823 [SCM] service lmhosts, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:40.4705790 [SCM] service TermService, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:40.4708935 [SCM] service CoreMessagingRegistrar, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000000
07/06/17-13:05:40.4943177 [SCM] service gpsvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000141
07/06/17-13:05:40.4975091 [SCM] service gpsvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000541
07/06/17-13:05:40.5067210 [SCM] service TimeBrokerSvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000241
07/06/17-13:05:40.5877317 [SCM] service UmRdpService, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000085
07/06/17-13:05:40.6327091 [SCM] service Dnscache, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000059
07/06/17-13:05:40.6501216 [SCM] service CertPropSvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000085
07/06/17-13:05:40.6716164 [SCM] service Dhcp, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:40.6785583 [SCM] service Schedule, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000012c5
07/06/17-13:05:40.7442193 [SCM] service LanmanWorkstation, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000043
07/06/17-13:05:40.7560620 [SCM] service EventLog, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000205
07/06/17-13:05:40.8915301 [SCM] service SessionEnv, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000281
07/06/17-13:05:40.9149615 [SCM] service ProfSvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:40.9173657 [SCM] service NlaSvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c1
07/06/17-13:05:40.9429894 [SCM] service netprofm, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c1
07/06/17-13:05:40.9494092 [SCM] service UserManager, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:41.0502482 [SCM] service NcbService, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000081
07/06/17-13:05:41.2351873 [SCM] service vmickvpexchange, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000003
07/06/17-13:05:41.2897569 [SCM] service vmictimesync, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000003
07/06/17-13:05:41.3259511 [SCM] service vmicshutdown, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000003
07/06/17-13:05:41.3284648 [SCM] service vmicvss, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000103
07/06/17-13:05:41.3444338 [SCM] service Themes, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:41.3548424 [SCM] service vmicrdv, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000003
07/06/17-13:05:41.3823139 [SCM] service WPDBusEnum, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000004c1
07/06/17-13:05:41.3843401 [SCM] service WinHttpAutoProxySvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000041
07/06/17-13:05:41.3856439 [SCM] service vmicheartbeat, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000003
07/06/17-13:05:41.3874138 [SCM] service EventSystem, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:41.5580789 [SCM] service SENS, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000041
07/06/17-13:05:41.6772846 [SCM] service FontCache, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:41.9209576 [SCM] service AudioEndpointBuilder, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c1
07/06/17-13:05:42.0189267 [SCM] service VSS, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:42.0210403 [SCM] service Audiosrv, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c1
07/06/17-13:05:42.0484759 [SCM] service SamSs, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000000
07/06/17-13:05:42.2429764 [SCM] service Wcmsvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000012c5
07/06/17-13:05:42.2906325 [SCM] service ShellHWDetection, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c1
07/06/17-13:05:42.5323497 [SCM] service Spooler, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000004c1
07/06/17-13:05:42.5431893 [SCM] service ScDeviceEnum, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000481
07/06/17-13:05:42.5485449 [SCM] service wudfsvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000000
07/06/17-13:05:42.5989161 [SCM] service NetSetupSvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:42.6021970 [SCM] service WbioSrvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000441
07/06/17-13:05:42.6391087 [SCM] service SCardSvr, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000481
07/06/17-13:05:42.7007534 [SCM] service NgcCtnrSvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:42.7017472 [SCM] service BFE, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000041
07/06/17-13:05:42.7098576 [SCM] service Winmgmt, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000007
07/06/17-13:05:42.7222523 [SCM] service Netlogon, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000003
07/06/17-13:05:42.8153049 [SCM] service iphlpsvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c9
07/06/17-13:05:42.8854162 [SCM] service CryptSvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000085
07/06/17-13:05:42.8857247 [SCM] service DPS, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:43.0717978 [SCM] service LanmanServer, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:44.1651270 [SCM] service PcaSvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000085
07/06/17-13:05:44.3247890 [SCM] service TrkWks, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:44.3303880 [SCM] service DiagTrack, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000013c5
07/06/17-13:05:44.3364873 [SCM] service MpsSvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:44.3497466 [SCM] service SysMain, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c5
07/06/17-13:05:44.3573408 [SCM] service WpnService, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000401
07/06/17-13:05:44.3581205 [SCM] service WdiServiceHost, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:44.7769374 [SCM] service sppsvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:45.1100224 [SCM] service wisvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000005
07/06/17-13:05:45.2168257 [SCM] service fhsvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000004c5
07/06/17-13:05:45.2489211 [SCM] service WinDefend, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c5
07/06/17-13:05:45.3731715 [SCM] service wuauserv, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c5
07/06/17-13:05:45.3899756 [SCM] service WinHttpAutoProxySvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000041
07/06/17-13:05:45.3958062 [SCM] service StateRepository, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x0000000d
07/06/17-13:05:45.6152215 [SCM] service tiledatamodelsvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000181
07/06/17-13:05:47.3504859 [SCM] service SCardSvr, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000481
07/06/17-13:05:47.5248612 [SCM] service WdNisSvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:47.9543134 [SCM] service SCardSvr, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000481
07/06/17-13:05:47.9543975 [SCM] service SCardSvr, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000481
07/06/17-13:05:48.5741736 [SCM] service CDPUserSvc_33f2e, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000000c1
07/06/17-13:05:50.7171925 [SCM] service W32Time, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x0000007d
07/06/17-13:05:51.0991216 [SCM] service wlidsvc, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000081
07/06/17-13:05:51.2245142 [SCM] service KeyIso, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000001
07/06/17-13:05:51.4173887 [SCM] service WSearch, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x000010c5
07/06/17-13:05:52.7271615 [SCM] service Appinfo, state 0x00000004(SERVICE_RUNNING), exit 0, sexit 0, controls 0x00000081

次に、SCMが開始コントロールを送信したWindowsサービスの時系列リストを示します。このリストは短いことに注意してください。また、常に同じ順序であるとは限りません。

07/06/17-13:05:40.4600357 [SCM] Successfully sent start control to service gpsvc, user S-1-5-18
07/06/17-13:05:40.4601289 [SCM] Successfully sent start control to service lmhosts, user S-1-5-18
07/06/17-13:05:40.4601542 [SCM] Successfully sent start control to service CoreMessagingRegistrar, user S-1-5-90-0-1
07/06/17-13:05:40.4602090 [SCM] Successfully sent start control to service TermService, user S-1-5-18
07/06/17-13:05:40.4602341 [SCM] Successfully sent start control to service NcbService, user S-1-5-18
07/06/17-13:05:40.4602536 [SCM] Successfully sent start control to service W32Time, user S-1-5-18
07/06/17-13:05:40.4660675 [SCM] Successfully sent start control to service TimeBrokerSvc, user S-1-5-18
07/06/17-13:05:40.5068238 [SCM] Successfully sent start control to service Schedule, user S-1-5-18
07/06/17-13:05:40.5435413 [SCM] Successfully sent start control to service RdpVideoMiniport, user S-1-5-20
07/06/17-13:05:40.5877716 [SCM] Successfully sent start control to service UmRdpService, user S-1-5-20
07/06/17-13:05:40.6336400 [SCM] Successfully sent start control to service CertPropSvc, user S-1-5-20
07/06/17-13:05:40.8919486 [SCM] Successfully sent start control to service SessionEnv, user S-1-5-20
07/06/17-13:05:40.9437595 [SCM] Successfully sent start control to service netprofm, user S-1-5-18
07/06/17-13:05:40.9437849 [SCM] Successfully sent start control to service UserManager, user S-1-5-18
07/06/17-13:05:41.2444548 [SCM] Successfully sent start control to service vmickvpexchange, user S-1-5-18
07/06/17-13:05:41.2898074 [SCM] Successfully sent start control to service vmicvss, user S-1-5-18
07/06/17-13:05:41.2898367 [SCM] Successfully sent start control to service vmicshutdown, user S-1-5-18
07/06/17-13:05:41.2902957 [SCM] Successfully sent start control to service vmictimesync, user S-1-5-18
07/06/17-13:05:41.3260049 [SCM] Successfully sent start control to service WPDBusEnum, user S-1-5-18
07/06/17-13:05:41.3444823 [SCM] Successfully sent start control to service vmicheartbeat, user S-1-5-18
07/06/17-13:05:41.3548887 [SCM] Successfully sent start control to service WinHttpAutoProxySvc, user S-1-5-20
07/06/17-13:05:41.3549103 [SCM] Successfully sent start control to service vmicrdv, user S-1-5-18
07/06/17-13:05:41.9211318 [SCM] Successfully sent start control to service VSS, user S-1-5-18
07/06/17-13:05:42.5324545 [SCM] Successfully sent start control to service ScDeviceEnum, user S-1-5-18
07/06/17-13:05:42.5989696 [SCM] Successfully sent start control to service NetSetupSvc, user S-1-5-18
07/06/17-13:05:42.7008186 [SCM] Successfully sent start control to service NgcCtnrSvc, user S-1-5-18
07/06/17-13:05:44.1651981 [SCM] Successfully sent start control to service WdiServiceHost, user S-1-5-19
07/06/17-13:05:44.3231928 [SCM] Successfully sent start control to service NcaSvc, user S-1-5-18
07/06/17-13:05:44.7769902 [SCM] Successfully sent start control to service sppsvc, user S-1-5-20
07/06/17-13:05:45.1100675 [SCM] Successfully sent start control to service wisvc, user S-1-5-18
07/06/17-13:05:45.2169191 [SCM] Successfully sent start control to service wuauserv, user S-1-5-18
07/06/17-13:05:45.2169410 [SCM] Successfully sent start control to service fhsvc, user S-1-5-18
07/06/17-13:05:45.6471780 [SCM] Successfully sent start control to service NcaSvc, user S-1-5-18
07/06/17-13:05:47.3489415 [SCM] Successfully sent start control to service WdNisSvc, user S-1-5-18
07/06/17-13:05:49.4258072 [SCM] Successfully sent start control to service CDPSvc, user S-1-5-18
07/06/17-13:05:50.9283667 [SCM] Successfully sent start control to service WSearch, user S-1-5-18
07/06/17-13:05:51.0034313 [SCM] Successfully sent start control to service wlidsvc, user S-1-5-18
07/06/17-13:05:51.1906412 [SCM] Successfully sent start control to service KeyIso, user S-1-5-18
07/06/17-13:05:52.5810658 [SCM] Successfully sent start control to service Appinfo, user S-1-5-18
10
Ryan Ries