システム運用管理者の徒然日記

日々勉強、日々仲間に助けられ、何とか過ごしております。

日々勉強、日々仲間に助けられ、何とか過ごしております。

Zabbix

Zabbix エージェントのインストール手順

・CentOS 7.4(minimalインストール)
・firewalld サービス停止済み


##################
# Zabbix エージェントのインストール
##################

##
## ユーティリティのインストール
##
yum -y install openssh-client
yum -y install wget
yum -y install yum-utils

##
## Zabbix リポジトリの追加
##
wget https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
rpm -ivh /root/zabbix-release-4.0-1.el7.noarch.rpm

##
## Zabbix エージェントのインストール
##
yum -y install zabbix-agent

##
## Zabbix エージェントの設定
##
cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.org
vi /etc/zabbix/zabbix_agentd.conf
----------------------------------------
Server=127.0.0.1
:
ServerActive=127.0.0.1
:
Hostname=Zabbix server
----------------------------------------
 ↓
----------------------------------------
Server=<ZabbixサーバのIPアドレス>
:
ServerActive=<ZabbixサーバのIPアドレス>
:
Hostname=<Zabbixエージェントをインストールしたホスト名>
----------------------------------------

※ ServerActive は、ログ監視で使用する設定。
  通常の監視では、Zabbixサーバからポーリングでデータを取得するが、
  ログ監視では、ZabbixエージェントからZabbixサーバへデータを送信し、
  その際に、この値を参照する。


systemctl restart zabbix-agent
systemctl status zabbix-agent | grep Active
## Active (running) であることを確認

systemctl enable zabbix-agent
systemctl is-enabled zabbix-agent
## enabled であることを確認


##################
# 監視ホストの登録
##################

1, 「http://<zabbixサーバのIPアドレス>/zabbix」へログインする。
Username:Admin
Password:zabbix

2, 「設定」-「ホスト」- 右上の「ホストの作成」をクリックする。

3, 「ホスト」タブが選択されているため、以下を入力する。
ホスト名 :<Zabbixエージェントの Hostname で指定した名前と同様にする>
表示名 :<Zabbixの管理画面で表示される名前>
グループ :「選択」より該当グループを選ぶ
エージェントのインターフェース
IPアドレス :<監視ホストのIPアドレス>

4, 「テンプレート」タブをクリックし、「新規テンプレートをリンク」の「選択」をクリックして、テンプレート一覧から該当のテンプレートを選択し、直下にある "追加" をクリックして「テンプレートとのリング」に追加表示されたことを確認する。
  (ここでは、Template OS Linux を選択)

5, 上記確認後、最配下にある「追加」をクリックする。


##################
# 監視状況の確認
##################

1, 「監視データ」-「ダッシュボード」をクリックし、サマリーの状況を確認する。
   "システム情報" のウィンドウの右上にある「…」をクリックし、リフレッシュ間隔を1分に変更。

2, 「監視データ」-「概要」をクリックし、過去の障害状況を確認する。

3, 「監視データ」-「最新データ」をクリックし、過去の障害状況を確認する。
   "ホストグループ" の「選択」ボタンより、"Linux Servers" と "Zabbix servers" を選択し、「適用」をクリック。
   列の右にある "グラフ" をクリックすると、推移が確認できる。

4, 「監視データ」-「スクリーン」をクリックし、ホストやアプリケーション単位での稼働状況を確認する。
   スクリーンを作成する際は、"全てのスクリーン" を表示させ、右上の「スクリーンの作成」をクリックして作成する。


=========================================

※ 補足事項 ※

・SNMPによる監視を行うためには、監視ホスト側に net-snmp のインストールが必要。
・SNMPの応答範囲を定義するため、監視ホスト側の snmpd.conf の修正が必要。
・監視ホストとのSNMPの疎通が取れるか確認するため、Zabbixサーバ側に net-snmp-utils のインストールが必要。


Zabbix 4.0(PostgreSQL)の構築手順

CentOS 7.4 の minimalインストール後からの構築手順。
(IPアドレス、DNSは設定済み)


##################
# Base設定
##################

##
## SE Linux 無効化
##
vi /etc/selinux/config
----------------------------------------
SELINUX=Enforcing
----------------------------------------
 ↓
----------------------------------------
SELINUX=disabled
----------------------------------------

##
## ファイアウォール 無効化
##
systemctl stop firewalld
systemctl status firewalld | grep Active
## inactive (dead) であることを確認

systemctl disable firewalld
systemctl is-enabled firewalld
## Disabled であることを確認

##
## システムのアップデート
##
yum -y update
shutdown -r now

getenforce
## disabled であることを確認

##
## 時刻の修正
##
yum -y install chrony
yum -y install ntpdate
ntpdate 0.centos.pool.ntp.org
hwclock -w
hwclock ; date

## NTPサーバの指定があれば実施
cp /etc/chrony.conf /etc/chrony.conf.org
vi /etc/chrony.conf
----------------------------------------
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
----------------------------------------
 ↓
----------------------------------------
server <NTP1のIPアドレス> iburst
server <NTP2のIPアドレス> iburst
----------------------------------------

diff /etc/chrony.conf /etc/chrony.conf.org
## 変更結果を確認


systemctl enable chronyd
systemctl is-enabled chronyd
## enabled であることを確認

systemctl restart chronyd
systemctl status chronyd | grep Active
## Active (running) であることを確認

ps auxww | egrep "chrony|PID" | grep -v grep
 ## プロセスが稼働していることを確認

chronyc sources
## NTPサーバの横に「*」が付いて同期が取れていることを確認

##
## ユーティリティのインストール
##
yum -y install openssh-client
yum -y install wget
yum -y install yum-utils

##
## epel リポジトリの追加
##
yum -y install epel-release

##
## PostgreSQL インストール
##
yum -y install postgresql-server

##
## DBの初期化
##
postgresql-setup initdb

systemctl enable postgresql
systemctl is-enabled postgresql
## enabled であることを確認

systemctl restart postgresql
systemctl status postgresql | grep Active
## Active (running) であることを確認


##################
# Zabbix 設定
##################

##
## Zabbix リポジトリの追加
##
wget https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
rpm -ivh /root/zabbix-release-4.0-1.el7.noarch.rpm

##
## Zabbix サーバ、エージェントのインストール
##
yum -y install zabbix-server-pgsql
yum -y install zabbix-web-pgsql
yum -y install zabbix-agent

##
## Zabbix用 DB作成
##
su - postgres
createuser zabbix -P -S -R -D
 Enter password for new role: ← ユーザー:zabbix のパスワードを入力
 Enter it again: ← パスワードの再入力

createdb -O zabbix -E UTF8 zabbix
exit


## DBのアクセス制御
cp /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.org
vi /var/lib/pgsql/data/pg_hba.conf
----------------------------------------
# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
# IPv6 local connections:
host    all             all             ::1/128                 ident
----------------------------------------
 ↓
----------------------------------------
# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
----------------------------------------

diff /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.org
## 変更結果を確認

systemctl restart postgresql

zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix

##
## 設定ファイルの修正
##
cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.org
vi /etc/zabbix/zabbix_server.conf
----------------------------------------
# DBPassword=
:
# DBPort=
----------------------------------------
 ↓
----------------------------------------
DBPassword=zabbix ← ここでは、zabbix というパスワードを指定
:
DBPort=5432
----------------------------------------

##
## Webインターフェース用 設定ファイルの修正
##
cp /etc/httpd/conf.d/zabbix.conf /etc/httpd/conf.d/zabbix.conf.org
vi /etc/httpd/conf.d/zabbix.conf
----------------------------------------
# php_value date.timezone Europe/Riga
----------------------------------------
 ↓
----------------------------------------
php_value date.timezone Asia/Tokyo
----------------------------------------

##
## サービスの起動設定
##
systemctl restart zabbix-server
systemctl status zabbix-server | grep Active
## Active (running) であることを確認

systemctl restart zabbix-agent
systemctl status zabbix-agent | grep Active
## Active (running) であることを確認

systemctl restart httpd
systemctl status httpd | grep Active
## Active (running) であることを確認


systemctl enable zabbix-server
systemctl is-enabled zabbix-server
## enabled であることを確認

systemctl enable zabbix-agent
systemctl is-enabled zabbix-agent
## enabled であることを確認

systemctl enable httpd
systemctl is-enabled httpd
## enabled であることを確認


##################
# Zabbix 起動
##################

##
## Webインターフェース上での設定
##
http://<ZabbixサーバーのIPアドレス>/zabbix/

 Welcome
- [Next step]

 Check of pre-requisites
- [Next step]

 Configure DB connection
Database type :PostgreSQL
Database host :localhost
Database port :5432
Database name :zabbix
User :zabbix
Password :zabbix
- [Next step]

 Zabbix server details
Host :<zabbixサーバのホスト名>
Port :10051
Name :<空白>
- [Next step]

Pre-installation summary
- [Next step]

Install
- [Finish]

##
## Zabbix ログイン
##
Username:Admin
Password:zabbix
## 初期パスワード(ユーザー名は大文字「A」)

##
## Webインターフェースの日本語化
##
## 日本語表示
右上の人型のアイコン(User Profile) - Language - Japanese (ja_JP) - [Update]

##
## 監視ホストの確認
##
「設定」-「ホスト」をクリック
 ## デフォルトで、Zabbixサーバ(自身)の監視は有効になっている


スポンサードリンク