LoginSignup
1
0

RHEL7,8にSSM AgentとCloudWatch Agentをインストールする

Last updated at Posted at 2021-10-02

はじめに

RHEL 7,8 に、SSM Agent と CloudWatch Agentのインストール調査メモ

1.SSMAgent バージョンのインストール方法

1-1.参考情報

インストール方法はここに説明ありました。

東京リージョン(ap-northeast-1)の amazon-cloudwatch-agent.rpm モジュールでインストールする場合のインストールコマンドはこんな感じ。

SSMAgentインストール(RHEL7)
sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
sudo systemctl enable amazon-ssm-agent
sudo systemctl start amazon-ssm-agent
SSMAgentインストール(RHEL8)
sudo dnf install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
sudo systemctl enable amazon-ssm-agent
sudo systemctl start amazon-ssm-agent
  • バージョン確認
    • [RHEL7の場合] yum info amazon-ssm-agent
    • [RHEL8の場合] dnf info amazon-ssm-agent

※余談※
コマンドyumは廃止され、dnfに置き換わるみたいです。どうやら、yumはPython2系でPython2のサポートが切れているため、Python3系のdnfに乗り換えが必要になったようです。

1-2.RHEL8で検証してみる

以下のAMIでEC2を起動しSSM Agentをイントールしてみます。

Red Hat Enterprise Linux 8 (HVM), SSD Volume Type - ami-0bccc42bba4dedac1 (64 ビット x86) / ami-0cdc4f61f73af4679 (64 ビット Arm)

$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.4 (Ootpa)

最初に、SSM Agentがインストールされていないことを確認します。yum , dnf どちらのコマンドでも確認できました。

$ sudo su -
Last login: Fri Oct  1 23:15:48 UTC 2021 on pts/0
#
# dnf info amazon-ssm-agent
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 0:00:43 ago on Fri 01 Oct 2021 11:16:03 PM UTC.
Error: No matching Packages to list
#
# yum info amazon-ssm-agent
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 0:01:06 ago on Fri 01 Oct 2021 11:16:03 PM UTC.
Error: No matching Packages to list
#

インストールしてみます

# sudo dnf install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
# sudo systemctl enable amazon-ssm-agent
# sudo systemctl start amazon-ssm-agent

バージョンを確認

# dnf info amazon-ssm-agent
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 0:12:55 ago on Fri 01 Oct 2021 11:16:03 PM UTC.
Installed Packages
Name         : amazon-ssm-agent
Version      : 3.1.338.0
Release      : 1
Architecture : x86_64
Size         : 111 M
Source       : amazon-ssm-agent-3.1.338.0-1.src.rpm
Repository   : @System
From repo    : @commandline
Summary      : Manage EC2 Instances using SSM APIs
URL          : http://docs.aws.amazon.com/ssm/latest/APIReference/Welcome.html
License      : Apache License, Version 2.0
Description  : This package provides Amazon SSM Agent for managing EC2 Instances using SSM APIs

#
# yum info amazon-ssm-agent
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 0:13:07 ago on Fri 01 Oct 2021 11:16:03 PM UTC.
Installed Packages
Name         : amazon-ssm-agent
Version      : 3.1.338.0
Release      : 1
Architecture : x86_64
Size         : 111 M
Source       : amazon-ssm-agent-3.1.338.0-1.src.rpm
Repository   : @System
From repo    : @commandline
Summary      : Manage EC2 Instances using SSM APIs
URL          : http://docs.aws.amazon.com/ssm/latest/APIReference/Welcome.html
License      : Apache License, Version 2.0
Description  : This package provides Amazon SSM Agent for managing EC2 Instances using SSM APIs

#

1-3.RHEL7で検証してみる

以下のAMI(AMI ID : ami-0be4c0b05bbeb2afd)でEC2を起動しSSM Agentをイントールしてみます。

Red Hat Enterprise Linux (RHEL) 7 (HVM)
Linux/Unix, Red Hat Enterprise Linux 7.7_HVM | 64 ビット Amazon マシンイメージ (AMI) x86 | 更新済み: 2019/10/15

$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.7 (Maipo)

最初に、SSM Agentがインストールされていないことを確認します。

# yum info amazon-ssm-agent
Loaded plugins: amazon-id, search-disabled-repos
Error: No matching Packages to list

SSM Agentをインストールします。

# sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm
# sudo systemctl enable amazon-ssm-agent
# sudo systemctl start amazon-ssm-agent

SSM Agentをインストールできたことを確認するため、SSM Agentのバージョンを確認します。

# yum info amazon-ssm-agent
Loaded plugins: amazon-id, search-disabled-repos
Installed Packages
Name        : amazon-ssm-agent
Arch        : x86_64
Version     : 3.1.338.0
Release     : 1
Size        : 111 M
Repo        : installed
From repo   : /amazon-ssm-agent
Summary     : Manage EC2 Instances using SSM APIs
URL         : http://docs.aws.amazon.com/ssm/latest/APIReference/Welcome.html
License     : Apache License, Version 2.0
Description : This package provides Amazon SSM Agent for managing EC2 Instances using SSM APIs

#

2.CloudWatch Agent バージョンのインストール方法

2-1.参考情報

インストール方法はここに説明ありました。

東京リージョン(ap-northeast-1)の amazon-cloudwatch-agent.rpm モジュールでインストールする場合のインストールコマンドはこんな感じ。

$ sudo dnf install https://s3.ap-northeast-1.amazonaws.com/amazoncloudwatch-agent-ap-northeast-1/redhat/amd64/latest/amazon-cloudwatch-agent.rpm

このサイトにRHELのサポートバージョンの記載がありました。

サポートされるオペレーティングシステム
Red Hat Enterprise Linux (RHEL) バージョン 8、7.7、7.6、7.5、7.4、7.2、および 7.0

2-2.RHEL8で検証してみる

以下のAMIでEC2を起動しSSM Agentをイントールしてみます。

Red Hat Enterprise Linux 8 (HVM), SSD Volume Type - ami-0bccc42bba4dedac1 (64 ビット x86) / ami-0cdc4f61f73af4679 (64 ビット Arm)

$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.4 (Ootpa)

最初に、CloudWatch Agentがインストールされていないことを確認します。CloudWatch Agent をインストールすると/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.dディレクトリが作成されるそうです。(バージョン確認 dnf info amazon-cloudwatch-agent するの忘れてた)

# cd /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d
-bash: cd: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d: No such file or directory

CloudWatch Agentをインストールします。

$ sudo dnf install https://s3.ap-northeast-1.amazonaws.com/amazoncloudwatch-agent-ap-northeast-1/redhat/amd64/latest/amazon-cloudwatch-agent.rpm

CloudWatch Agent がインストールされたことを確認するためディレクトリとバージョンを確認しました。

# cd /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d
# ls
#
# dnf info amazon-cloudwatch-agent
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 0:29:58 ago on Fri 01 Oct 2021 11:16:03 PM UTC.
Installed Packages
Name         : amazon-cloudwatch-agent
Version      : 1.247349.0b251399
Release      : 1
Architecture : x86_64
Size         : 203 M
Source       : amazon-cloudwatch-agent-1.247349.0b251399-1.src.rpm
Repository   : @System
From repo    : @commandline
Summary      : Amazon CloudWatch Agent
License      : MIT License. Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Description  : This package provides daemon of Amazon CloudWatch Agent

#

2-3.RHEL7で検証してみる

以下のAMI(AMI ID : ami-0be4c0b05bbeb2afd)でEC2を起動しSSM Agentをイントールしてみます。

Red Hat Enterprise Linux (RHEL) 7 (HVM)
Linux/Unix, Red Hat Enterprise Linux 7.7_HVM | 64 ビット Amazon マシンイメージ (AMI) x86 | 更新済み: 2019/10/15

$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.7 (Maipo)

最初に、CloudWatch Agentがインストールされていないことを確認します。

# yum info amazon-cloudwatch-agent
Loaded plugins: amazon-id, search-disabled-repos
Error: No matching Packages to list

CloudWatch Agentをインストールします。

$ sudo yum install https://s3.ap-northeast-1.amazonaws.com/amazoncloudwatch-agent-ap-northeast-1/redhat/amd64/latest/amazon-cloudwatch-agent.rpm

CloudWatch Agent がインストールされたことを確認するためディレクトリとバージョンを確認しました。

# cd /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d
# pwd
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d
# ls
#
# yum info amazon-cloudwatch-agent
Loaded plugins: amazon-id, search-disabled-repos
Installed Packages
Name        : amazon-cloudwatch-agent
Arch        : x86_64
Version     : 1.247349.0b251399
Release     : 1
Size        : 203 M
Repo        : installed
From repo   : /amazon-cloudwatch-agent
Summary     : Amazon CloudWatch Agent
License     : MIT License. Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Description : This package provides daemon of Amazon CloudWatch Agent

#

3.自動更新について

SSM Agent , CloudWatch Agentを自動更新する方法を調べたメモ。動作確認をした程度で、ホントに自動更新できているかまでは確認していません。

3-1.SSM Agent の自動更新

AWS管理コンソールには、SSM Agentにの自動更新の設定あるようです。

AWS管理コンソールでSystems Managerの[ステートマネージャー]の[設定]タブを開き、SSMエージェントの自動更新ボタンで自動更新を有効にできるようです。

image.png

SSMエージェントの自動更新ボタンをクリックするとこのようになりました。

image.png

マネージドインスタンスにEC2ごとのSSM Agent のバージョンが表示されました。

image.png

ステートマネージャにも

3-2.Cloud Watch Agent の自動更新

AWS Systems Managerのステートマネージャーで設定できるようです。

ドキュメント AWS-ConfigureAWSPackage とし、パラメータの Name ボックスをAmazonCloudWatchAgent とすればよいそうです。

実行履歴に以下のメッセージが表示されました。

Initiating arn:aws:ssm:::package/AmazonCloudWatchAgent 1.247349.0b251399 install
Plugin aws:runShellScript ResultStatus Success
install output: Running sh install.sh
****** processing cwagent-otel-collector ******
cwagent-otel-collector has already been stopped
****** processing amazon-cloudwatch-agent ******
amazon-cloudwatch-agent has already been stopped
Successfully installed arn:aws:ssm:::package/AmazonCloudWatchAgent 1.247349.0b251399


改めて調べると知らないことが色々ありました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0