GNU/Linux >> Linux の 問題 >  >> Linux

Red HatEnterpriseLinuxおよびCentOSパブリッククラウドサーバーで自動更新を手動で有効にする

サーバーをセキュリティ修正で最新の状態に保つことは、サーバーの約束を回避するのに役立ちます。パッケージの更新ですべてのセキュリティ侵害を防ぐことはできませんが、サーバーを最新の状態に保つことは、セキュリティ手順の重要な要素である必要があります。

この記事では、RedHat®EnterpriseLinux®(RHEL)およびCentOS®Rackspaceパブリッククラウドサーバーで自動更新を有効にして、重要な更新がインストールされ、最新であることを確認する方法について説明します。

RHEL6およびCentOS6

次の手順を使用して、RHEL6およびCentOS6Rackspaceパブリッククラウドサーバーで自動更新を有効にします。

  1. サーバーに接続したら、yum-cronをインストールします 次のコマンドを実行します:

    $ yum -y install yum-cron
    
  2. yum-cronを表示するには 構成ファイルの場合は、次のコマンドを使用します。

    $ vi /etc/sysconfig/yum-cron
    

    ファイルは任意のテキストエディタで開くこともできます。

    次の例に示すように、デフォルトでは、構成は更新をダウンロードしてインストールするように設定されています。

    # Pass any given parameter to yum, as run in all the scripts invoked
    # by this package.  Be aware that this is global, and yum is invoked in
    # several modes by these scripts for which your own parameter might not
    # be appropriate
    YUM_PARAMETER=
    
    # Don't install, just check (valid: yes|no)
    CHECK_ONLY=no
    
    # Check to see if you can reach the repos before updating (valid: yes|no)
    CHECK_FIRST=no
    
    # Don't install, just check and download (valid: yes|no)
    # Implies CHECK_ONLY=yes (gotta check first to see what to download)
    DOWNLOAD_ONLY=no
    
  3. (オプション) インストール時間、インストールされたパッケージ、インストールエラーなど、パッケージの自動更新の通知を設定するには、MAILTO=で始まる行を編集します。 次の例に示すように、通知を受信するためのメールアドレスを追加するには:

    # if MAILTO is set and the mail command is available, the mail command
    # is used to deliver yum output
    
    # by default MAILTO is unset, so crond mails the output by itself
    # example:  MAILTO=root
    [email protected]
    
  4. ファイルを保存します。

    vimを使用している場合 構成ファイルを編集するには、 escを押します。 次に、:wqと入力します 変更を保存します。

    ファイルを保存すると、ファイルが正しく書き込まれたことを示す次のメッセージが表示されます。

    APT::Periodic::Update-Package_Lists "1";
    APT::Periodic::Download-Upgradable-Packages "1";
    APT::Periodic::Unattended-Upgrade "1";
    APT::Periodic::AutocleanInterval "14";
    
  5. yum-cronを開始します 次のコマンドを実行してサービスを提供します:

    $ /etc/inid.d/yum-cron start
    
  6. サーバーの再起動時にサービスを自動的に開始するには、次のコマンドを実行します。

    $ chkconfig yum-cron on
    

RHEL7およびCentOS7

次の手順を使用して、RHEL7およびCentOS7Rackspaceパブリッククラウドサーバーで自動更新を有効にします。

  1. RHEL7またはCentOS7サーバーに接続した後、yum-cronをインストールします 次のコマンドを実行します:

    $ yum -y install yum-cron
    
  2. yum-cronを表示するには 構成ファイルの場合は、次のコマンドを使用します。

    $ vi /etc/sysconfig/yum-cron
    

    ファイルは任意のテキストエディタで開くこともできます。

    次の例に示すように、デフォルトでは、更新は自動的にダウンロードされますが、インストールされません。

    # Whether a message should be emitted when updates are available,
    # were downloaded, or applied.
    update_messages = yes
    
    # Whether updates should be downloaded when they are available.
    download_updates = yes
    
    # Whether updates should be applied when they are available. Note
    # that download_updates must also be yes for the update to be applied.
    apply_updates = no
    
    # Maximum amount of time to randomly sleep, in minutes.  The program
    # will sleep for a random amount of time between 0 and random_sleep
    # minutes before running.  This is useful for e.g. staggering the
    # times that multiple systems will access update servers.  If
    # random_sleep is 0 or negative, the program will run immediately.
    # 6x60 = 360
    random_sleep = 360
    
  3. 自動更新をダウンロードしてインストールするには、download_updatesを確認してください。 およびapply_updates yesに設定されています 。

  4. (オプション) yumの出力が次のようになるように、構成ファイルで通知を設定できます。 何が完了したか、問題がある場合は何が失敗したかを通知するために、更新が電子メールで送信されます。次のセクションを編集します:

    1. [emitters] 構成ファイルのセクションで、emit_viaを確認します stdioに設定されています 、次の例に示すように:

      [emitters]
      # Name to use for this system in messages that are emitted.  If
      # system_name is None, the hostname will be used.
      system_name = None
      
      # How to send messages.  Valid options are stdio and email.  If
      # emit_via includes stdio, messages will be sent to stdout; this is useful
      # to have cron send the messages.  If email_via includes email, this
      # program will send email itself according to the configured options.
      # If emit_via is None or left blank, no message will be sent.
      emit_via = stdio
      
    2. [email]で 構成ファイルのセクションで、email_toを編集します 次の例に示すように、出力の送信先となる電子メールアドレスを追加するフィールド:

      [email]
      # The address to send email messages from.
      # NOTE: 'localhost' will be replaced with the value of system_name.
      email_from = root@localhost
      
      # List of addresses to send messages to.
      email_to = [email protected]
      
      # Name of the host to connect to to send email messages.
      email_host = localhost
      
  5. ファイルを保存します。

    vimを使用している場合 構成ファイルを編集するには、 escを押します。 次に、:wqと入力します 変更を保存します。

    ファイルを保存すると、ファイルが正しく書き込まれたことを示す次のメッセージが表示されます。

    "/etc/yum/yum-cron.conf" 81L, 2620C written
    
  6. yum-cronかどうかを確認します 次のコマンドを実行すると、サービスが開始されます。

    $ systemctl status yum-cron
    

    サービスが実行されていない(非アクティブ)場合は、次のコマンドを実行してサービスを開始します。

    $ systemctl start yum-cron
    
  7. サービスが実行されているので、サーバーの再起動後にサービスが自動的に開始されることを確認する必要があります。次のコマンドを実行して、yum-cronかどうかを確認します 有効になっている:

    $ systemctl list-unit-files –type=service
    

    yum-cron.serviceを見つけます リスト内のプロセス。有効にすると、サーバーの起動時にサービスが開始されます。無効になっている場合は、次のコマンドを使用して有効にします。

    $ systemctl enable yum-cron
    

Linux
  1. Red Hat Enterprise Linuxを登録し、Ansibleにサブスクリプションを添付します

  2. Red Hat EnterpriseLinux7および8でのIPv6アドレスの設定

  3. MicrosoftAzure用にカスタマイズされたRedHatEnterpriseLinux7イメージを構築する

  1. AzureでRedHatEnterpriseLinuxを実行する際の考慮事項

  2. CentOSとRedHatのSSHポートを変更する

  3. CentOSおよびRedHatにEPELおよびIUSリポジトリをインストールします

  1. Red HatEnterpriseLinuxインストールISOイメージの最適化

  2. Red Hat Enterprise Linuxを無料で入手するにはどうすればよいですか?

  3. Windows2012およびWindows2008パブリッククラウドサーバーで自動更新を手動で有効にする