zabbix エージェント
インストールマニュアル
[CentOS 6 / 7 系]
第 1.2 版 2018 年 04 月 10 日
目次
1. はじめに ... 1
1.1. 本書の内容 ... 1
1.2. 本書の記述範囲 ... 1
2. 事前準備 ... 2
2.1. wget のインストール ... 2
2.2. zabbix のダウンロード ... 3
2.3. zabbix エージェントのダウンロード ... 4
3. インストール ... 5
3.1. zabbix のインストール ... 5
3.2. zabbix エージェントのインストール ... 6
3.3. インストールの確認 ... 6
4. zabbix エージェント設定 ... 6
4.1. zabbix_agentd.conf 編集 ... 6
4.2. Server の設定 ... 7
4.3. ListenPort の設定 ... 7
4.4. ListenIP の設定 ... 8
4.5. ServerActive の設定 ... 8
4.6. Hostname の設定... 9
5. zabbix エージェント起動 ... 9
5.1. zabbix エージェントの稼動状況確認 ... 9
5.2. zabbix エージェントの起動 ... 10
5.3. zabbix エージェントのプロセス確認 ... 11
6. OS 起動時の設定 ... 11
7. iptables の設定(CentOS6) ... 12
8. firewalld の設定(CentOS7) ... 13
8.1. firewalld の稼働状況確認 ... 13
8.2. firewalld の設定 ... 13
8.3. firewalld の設定確認... 13
9. ルーティングテーブルの設定 ... 14
9.1. ルーティングテーブルの設定確認 ... 14
9.2. ルーティングテーブルの設定 ... 14
9.3. ネットワークサービスの再起動 ... 15
9.4. ルーティングテーブルの設定確認 ... 15
1
1. はじめに 1.1. 本書の内容 本ドキュメントでは、zabbix エージェント(Cent6/7 系)のインストール手順について記載したものです。 1.2. 本書の記述範囲 wget のインストール zabbix パッケージのダウンロード/インストール zabbix エージェントのダウンロード/インストール 初期セットアップ2
2. 事前準備 zabbix エージェントインストール前の事前準備について記載します。 なお、zabbix のバージョンは「2.2.16」を使用します。 2.1. wget のインストール すでにインストール済みの場合は、「2.2. zabbix リポジトリのダウンロード」へ進んでください。 以下のコマンドを入力し、wget のインストール状況を確認します。 【Cent6/7 共通】 [root@localhost ~]# rpm -q wget パッケージ wget はインストールされていません。 以下のコマンドを入力し、wget をインストールします。 【Cent6/7 共通】[root@localhost ~]# yum -y install wget 読み込んだプラグイン:fastestmirror, priorities Loading mirror speeds from cached hostfile * base: ftp.tsukuba.wide.ad.jp * extras: ftp.tsukuba.wide.ad.jp ~ 省略 ~ インストール: wget.x86_64 0:1.14-15.el7_4.1 完了しました! 以下のコマンドを入力し、wget がインストールされたことを確認します。 【Cent6/7 共通】 [root@localhost ~]# rpm -q wget wget-1.14-15.el7_4.1.x86_64
3
2.2. zabbix のダウンロード以下のコマンドを入力し、zabbix をダウンロードします。 【Cent6 の場合】
※32bit 版を使用している場合は、x86_64 を i386 に置き換えて実施してください。
[root@localhost ~]# wget http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-2.2.16-1.el6.x86_64.rpm --2018-04-03 17:00:42-- http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix- 2.2.16-1.el6.x86_64.rpm repo.zabbix.com を DNS に問いあわせています... 162.243.159.138 repo.zabbix.com|162.243.159.138|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 200 OK 長さ: 160172 (156K) [application/x-redhat-package-manager] `zabbix-2.2.16-1.el6.x86_64.rpm' に保存中 100%[======================================>] 160,172 259K/s 時間 0.6s 2018-04-03 17:00:58 (259 KB/s) - `zabbix-2.2.16-1.el6.x86_64.rpm' へ保存完了 [160172/160172] 【Cent7 の場合】
[root@localhost ~]# wget http://repo.zabbix.com/zabbix/2.2/rhel/7/x86_64/zabbix-2.2.16-1.el7.x86_64.rpm --2018-04-02 14:54:00-- http://repo.zabbix.com/zabbix/2.2/rhel/7/x86_64/zabbix-2.2.16-1.el7.x86_64.rpm repo.zabbix.com (repo.zabbix.com) を DNS に問いあわせています... 162.243.159.138 repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 200 OK 長さ: 158656 (155K) [application/x-redhat-package-manager] `zabbix-2.2.16-1.el7.x86_64.rpm' に保存中 100%[======================================>] 158,656 424KB/s 時間 0.4s 2018-04-02 14:54:07 (424 KB/s) - `zabbix-2.2.16-1.el7.x86_64.rpm' へ保存完了 [158656/158656]
4
2.3. zabbix エージェントのダウンロード以下のコマンドを入力し、zabbix エージェントをダウンロードします。 【Cent6 の場合】
※32bit 版を使用している場合は、x86_64 を i386 に置き換えて実施してください。
[root@localhost ~]# wget http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-agent-2.2.16-1.el6.x86_64.rpm --2018-04-03 17:03:14-- http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-agent-2.2.16-1.el6.x86_64.rpm repo.zabbix.com を DNS に問いあわせています... 162.243.159.138 repo.zabbix.com|162.243.159.138|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 200 OK 長さ: 165400 (162K) [application/x-redhat-package-manager] `zabbix-agent-2.2.16-1.el6.x86_64.rpm' に保存中 100%[===================================================================== =========================================================>] 165,400 267K/s 時間 0.6s 2018-04-03 17:03:15 (267 KB/s) - `zabbix-agent-2.2.16-1.el6.x86_64.rpm' へ保存完了 [165400/165400] 【Cent7 の場合】
[root@localhost ~]# wget http://repo.zabbix.com/zabbix/2.2/rhel/7/x86_64/zabbix-agent-2.2.16-1.el7.x86_64.rpm --2018-04-02 15:19:56-- http://repo.zabbix.com/zabbix/2.2/rhel/7/x86_64/zabbix-agent-2.2.16-1.el7.x86_64.rpm repo.zabbix.com (repo.zabbix.com) を DNS に問いあわせています... 162.243.159.138 repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 200 OK 長さ: 174764 (171K) [application/x-redhat-package-manager] `zabbix-agent-2.2.16-1.el7.x86_64.rpm' に保存中 100%[===================================================================== =========================================================>] 174,764 468KB/s 時間 0.4s 2018-04-02 15:19:57 (468 KB/s) - `zabbix-agent-2.2.16-1.el7.x86_64.rpm' へ保存完了 [174764/174764]
5
以下のコマンドを入力し、ダウンロードされたことを確認してください。 【Cent6/7 共通】 [root@localhost ~]# ls zabbix-2.2.16-1.el7.x86_64.rpm zabbix-agent-2.2.16-1.el7.x86_64.rpm 3. インストール zabbix エージェントのインストール手順について記載します。 3.1. zabbix のインストール 以下のコマンドを入力し、zabbix をインストールします。 【Cent6 の場合】 ※32bit 版を使用している場合は、x86_64 を i386 に置き換えて実施してください。[root@localhost ~]# rpm -ivh zabbix-2.2.16-1.el6.x86_64.rpm
準備しています... ################################# [100%] 更新中 / インストール中...
1:zabbix-2.2.16-1.el6 ################################# [100%]
【Cent7 の場合】
[root@localhost ~]# rpm -ivh zabbix-2.2.16-1.el7.x86_64.rpm
準備しています... ################################# [100%] 更新中 / インストール中...
6
3.2. zabbix エージェントのインストール以下のコマンドを入力し、zabbix エージェントをインストールします。 【Cent6 の場合】
※32bit 版を使用している場合は、x86_64 を i386 に置き換えて実施してください。
[root@localhost ~]# rpm -ivh zabbix-agent-2.2.16-1.el6.x86_64.rpm
準備しています... ################################# [100%] 更新中 / インストール中...
1:zabbix-agent-2.2.16-1.el6 ################################# [100%]
【Cent7 の場合】
[root@localhost ~]# rpm -ivh zabbix-agent-2.2.16-1.el7.x86_64.rpm
準備しています... ################################# [100%] 更新中 / インストール中... 1:zabbix-agent-2.2.16-1.el7 ################################# [100%] 3.3. インストールの確認 以下のコマンドを入力し、インストール状況を確認します。 【Cent6/7 共通】
[root@localhost ~]# rpm -qa | grep zabbix zabbix-2.2.16-1.el7.x86_64 zabbix-agent-2.2.16-1.el7.x86_64 4. zabbix エージェント設定 【Cent6/7 共通】 4.1. zabbix_agentd.conf 編集 zabbix の設定ファイルは/etc/zabbix/配下にあります。 /etc/zabbix/zabbix_agentd.conf を編集します。 [root@localhost ~]# ls -l /etc/zabbix/ 合計 8
-rw-r--r-- 1 root root 7569 12 月 9 2016 zabbix_agentd.conf drwxr-xr-x 2 root root 38 4 月 3 09:28 zabbix_agentd.d [root@localhost ~]# vi /etc/zabbix/zabbix_agentd.conf
7
4.2. Server の設定zabbix_agentd.conf より、zabbix サーバの IP アドレスを設定します。 (85 行目付近)
##### Passive checks related
### Option: Server
# List of comma delimited IP addresses (or hostnames) of Zabbix servers. # Incoming connections will be accepted only from the hosts listed here.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally. # # Mandatory: no # Default: # Server= Server=127.0.0.1 IP アドレスを 10.175.128.11 に変更 Server=10.175.128.11 4.3. ListenPort の設定 zabbix_agentd.conf より、ListenPort の設定をします。 (93 行目付近) ### Option: ListenPort
# Agent will listen on this port for connections from the server. # # Mandatory: no # Range: 1024-32767 # Default: # ListenPort=10050 コメントアウトを外してください。 Port はデフォルト 10050 を利用します。 ListenPort=10050
8
4.4. ListenIP の設定 zabbix_agentd.conf より、zabbix エージェントが使用する IP アドレスの設定をします。 IP アドレスはご自身の環境に合わせて設定してください。 (101 行目付近) ### Option: ListenIP# List of comma delimited IP addresses that the agent should listen on.
# First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks. # # Mandatory: no # Default: # ListenIP=0.0.0.0 コメントアウトを外してください。 zabbix エージェントが使用する IP アドレス(監視用 IP アドレス)を入力してください。 ListenIP=0.0.0.0 4.5. ServerActive の設定 zabbix_agentd.conf より、zabbix サーバの IP アドレスを設定します。 (126 行目付近)
##### Active checks related
### Option: ServerActive
# List of comma delimited IP:port (or hostname:port) pairs of Zabbix servers for active checks.
# If port is not specified, default port is used.
# IPv6 addresses must be enclosed in square brackets if port for that host is specified. # If port is not specified, square brackets for IPv6 addresses are optional.
# If this parameter is not specified, active checks are disabled.
# Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1] # # Mandatory: no # Default: # ServerActive= ServerActive=127.0.0.1 IP アドレスを 10.175.128.11 に変更 ServerActive=10.175.128.11
9
4.6. Hostname の設定 zabbix_agentd.conf より、zabbix エージェントが稼動するホスト名を設定します。 ホスト名はご自身の環境に合わせて設定してください。 (137 行目付近) 【Cent6/7 共通】 ### Option: Hostname# Unique, case sensitive hostname.
# Required for active checks and must match hostname as configured on the server. # Value is acquired from HostnameItem if undefined.
# # Mandatory: no # Default: # Hostname= Hostname=Zabbix server zabbix エージェントが稼動するホスト名を入力してください。 5. zabbix エージェント起動 5.1. zabbix エージェントの稼動状況確認 以下のコマンドを入力し、zabbix エージェントの稼働状況を確認します。 【Cent6 の場合】
[root@localhost ~]# service zabbix-agent status zabbix_agentd は停止しています
【Cent7 の場合】
[root@localhost ~]# systemctl status zabbix-agent ● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
10
5.2. zabbix エージェントの起動以下のコマンドを入力し、zabbix エージェントの起動を実行します。 【Cent6 の場合】
[root@localhost ~]# service zabbix-agent start
Starting Zabbix agent: [ OK ]
【Cent7 の場合】
[root@localhost ~]# systemctl start zabbix-agent
コマンド入力後、再度 zabbix エージェントの稼動状況を確認します。 【Cent6 の場合】
[root@localhost ~]# service zabbix-agent status zabbix_agentd (pid 1648) を実行中...
【Cent7 の場合】
[root@localhost ~]# systemctl status zabbix-agent ● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
Active: active (running) since 火 2018-04-03 11:56:16 JST; 5min ago Process: 1160 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 1162 (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
tq1162 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf tq1163 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
tq1164 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection] tq1165 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection] tq1166 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection] mq1167 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
4 月 03 11:56:16 localhost.localdomain systemd[1]: Starting Zabbix Agent...
4 月 03 11:56:16 localhost.localdomain systemd[1]: PID file /run/zabbix/zabbix_agentd.pid not readable (yet?) after start.
11
5.3. zabbix エージェントのプロセス確認以下のコマンドを入力し、zabbix エージェントのプロセスを確認します。 【Cent6/7 共通】
[root@localhost ~]# ps -awef | grep zabbix | grep -v grep
root 1105 972 0 10:42 pts/0 00:00:00 vi /etc/zabbix/zabbix_agentd.conf zabbix 1162 1 0 11:56 ? 00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 1163 1162 0 11:56 ? 00:00:05 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 1164 1162 0 11:56 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 1165 1162 0 11:56 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 1166 1162 0 11:56 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 1167 1162 0 11:56 ? 00:00:01 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
6. OS 起動時の設定
デフォルトでは、OS 起動時は zabbix エージェントは停止した状態です。OS 起動時に自動起動するように以下 のコマンドで設定します。
【Cent6 の場合】
[root@localhost ~]# chkconfig --list zabbix-agent
zabbix-agent 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@localhost ~]# chkconfig zabbix-agent on
[root@localhost ~]# chkconfig --list zabbix-agent
zabbix-agent 0:off 1:off 2:on 3:on 4:on 5:on 6:off
12
【Cent7 の場合】[root@localhost ~]# systemctl list-unit-files -t service zabbix-agent.service UNIT FILE STATE
zabbix-agent.service disabled
1 unit files listed.
[root@localhost ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@localhost ~]# systemctl list-unit-files -t service zabbix-agent.service UNIT FILE STATE
zabbix-agent.service enabled
1 unit files listed.
enabled になっていることを確認します。
7. iptables の設定(CentOS6)
iptables が設定されている場合、TCP10050、10051 をブロックしないように設定します。 以下のコマンドを入力し、iptables の設定をします。
[root@localhost ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter
:INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
13
8. firewalld の設定(CentOS7)
firewalld が設定されている場合、TCP10050、10051 をブロックしないように設定します。
8.1. firewalld の稼働状況確認
以下のコマンドを入力し、firewalld の稼動状況を確認します。
[root@localhost ~]# firewall-cmd --state running
起動していることを確認します。
8.2. firewalld の設定
以下のコマンドを入力し、TCP10050、10051 をブロックしないように設定します。
[root@localhost ~]# firewall-cmd --add-port=10050/tcp --permanent success
[root@localhost ~]# firewall-cmd --add-port=10051/tcp --permanent success
設定が完了したら、firewalld を再起動させます。
[root@localhost ~]# systemctl restart firewalld.service
8.3. firewalld の設定確認
以下のコマンドを入力し、firewalld の設定を確認します。
[root@localhost ~]# firewall-cmd --list-all --zone=public public (active) target: default icmp-block-inversion: no interfaces: enp0s3 sources: services: ssh dhcpv6-client ports: 10050/tcp 10051/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: ports に TCP10050、10051 が設定されていることを確認します。
14
9. ルーティングテーブルの設定 監視用に NIC を追加した場合等、zabbix サーバへのルーティング設定が必要になる場合があります。本項で はルーティングテーブルの設定方法について記載します。 9.1. ルーティングテーブルの設定確認 以下のコマンドを入力し、ルーティングテーブルを確認します。 【Cent6 の場合】 [root@localhost ~]# route Kernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 * 255.255.255.0 U 0 0 0 eth1 link-local * 255.255.0.0 U 1002 0 0 eth2 link-local * 255.255.0.0 U 1003 0 0 eth1 default 192.168.1.254 0.0.0.0 UG 0 0 0 eth1 【Cent7 の場合】 [root@localhost ~]# ip route
default via 192168.1.254 dev enp0s8 proto static metric 100 default via 198.51.100.254 dev enp0s9 proto static metric 101
192.168.1.0/24 dev enp0s8 proto kernel scope link src 192.168.1.1 metric 100 198.51.100.0/24 dev enp0s9 proto kernel scope link src 198.51.100.1 metric 100
9.2. ルーティングテーブルの設定 以下のコマンドを入力し、ルーティングテーブルを設定します。 【Cent6/7 共通】 [root@localhost ~]# vi /etc/sysconfig/network-scripts/route-eth2 ルーティングを設定したい NIC を入力してください。 zabbix サーバへのセグメントを入力してください。
10.175.128.0/24 via 198.51.100.254 dev eth2
ルーティングを設定したい NIC を入力してください。 ゲートウェイアドレスを入力して下さい。
15
9.3. ネットワークサービスの再起動以下のコマンドを入力し、ネットワークサービスを再起動します。 【Cent6 の場合】
[root@localhost ~]# service network restart
インターフェース eth0 を終了中: [ OK ] ループバックインターフェースを終了中 [ OK ] ループバックインターフェイスを呼び込み中 [ OK ] ~ 省略 ~ [ OK ] 【Cent7 の場合】
[root@localhost ~]# systemctl restart network
9.4. ルーティングテーブルの設定確認
以下のコマンドを入力し、ルーティングテーブルが設定されたことを確認します。 【Cent6 の場合】
[root@localhost ~]# route Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface 10.175.128.0 198.51.100.254 255.255.255.0 UG 0 0 0 eth2 192.168.1.0 * 255.255.255.0 U 0 0 0 eth1 link-local * 255.255.0.0 U 1002 0 0 eth2 link-local * 255.255.0.0 U 1003 0 0 eth1 default 192.168.1.254 0.0.0.0 UG 0 0 0 eth1 【Cent7 の場合】 [root@localhost ~]# route
default via 192168.1.254 dev enp0s8 proto static metric 100 default via 198.51.100.254 dev enp0s9 proto static metric 101
10.175.128.0/24 via 198.51.100.254 dev enp0s9 proto static metric 100 192.168.1.0/24 dev enp0s8 proto kernel scope link src 192.168.1.1 metric 100 198.51.100.0/24 dev enp0s9 proto kernel scope link src 198.51.100.1 metric 100