CentOS7にZabbix4.0をインストールします。
Zabbix4.0の必要条件は下記のようになっています。
MySQL     5.0.3 or later     InnoDB engine is required.
Apache    1.3.12 or later     
PHP       5.4.0 or later     
PHP extensions:
gd        2.0 or later
bcmath    php-bcmath
ctype     php-ctype
libXML    2.6.15 or later php-xml or php5-dom, if provided as a separate package by the distributor.
xmlreader       php-xmlreader, if provided as a separate package by the distributor.
xmlwriter       php-xmlwriter, if provided as a separate package by the distributor.
session         php-session, if provided as a separate package by the distributor.
sockets         php-net-socket (--enable-sockets). Required for user script support.
mbstring        php-mbstring (--enable-mbstring)
gettext         php-gettext (--with-gettext). Required for translations to work.
mysqli          Required if MySQL is used as Zabbix backend database.
そこで、Moodleなどをインストールするときと同様にCentOS7を標準インストールします。

SElinuxを無効化設定します。
# cd  /etc/selinux
# vi config (設定ファイルの編集)
SELINUX=enforcing
 ↓
SELINUX=disabled (無効化設定します)

# reboot (マシンをリブートします)

OSモジュールをアップデートします。
# yum -y update
# reboot

データベースがインストールされているか一応チェックしてみます
# rpm -qa | grep mariadb
mariadb-server-5.5.37-1.el7_0.x86_64
mariadb-5.5.37-1.el7_0.x86_64
mariadb-libs-5.5.37-1.el7_0.x86_64
無ければインストールします
# yum  install mariadb-server mariadb mariadb-libs

Apacheがインストールされているかチェックします。無ければ追加インストールします。
# rpm -qa | grep httpd
# yum  install httpd httpd-devel  mod_ssl

新しいバージョンのPHPをインストールするために、EPELのリポジトリのインストールを行います。
# yum  install epel-release
# vi /etc/yum.repos.d/epel.repo
enabled=1 変更enabled=0 (普段は無効状態に設定しておきます)

REMIレポジトリをインストールします
# rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

# vi /etc/yum.repos.d/epel.repo
enabled=0 にする

# vi /etc/yum.repos.d/remi.repo
enabled=0にする

# vi /etc/yum.repos.d/remi-safe.repo
enabled=0にする

Zabbix用にphp7.2をインストールします
# yum  install --enablerepo=epel,remi,remi-php72 OpenIPMI-libs OpenIPMI-modalias OpenIPMI-perl libzip pcre-devel php php-bcmath php-devel php-fpm php-gd php-intl php-ldap php-mbstring php-mysqlnd php-opcache php-pear php-pecl-apcu php-pecl-zip php-soap php-xml php-xmlrpc unixODBC unixODBC-devel vlgothic-p-fonts gd-last libargon2 libzip5 php-cli php-common php-fedora-autoloader php-json php-pdo php-process fping unixODBC

# systemctl restart httpd.service
# systemctl enable httpd.service

Fiewallの設定をします
デフォルトではポート22/TCP(ssh)しか開いていないのでhttp,https,smtpなど必要なポートを追加します
Zabbix用にはポート10050/TCPを開きます。

httpd(Apache)の設定をします
Webサイトデータを載せるディレクトリを /data/html にしました。
# mkdir /data (データを載せるディレクトリを作ります)
# mkdir /data/html (ドキュメントルートに設定するディレクトリを作ります)

# cd /etc/httpd/conf (httpdの設定ファイルがあるディレクトリに移動します)
# ls
# cp httpd.conf httpd.conf.org (一応、オリジナルの設定ファイルを名前を付けてコピー保存しておきます)
# vi httpd.conf (設定ファイルを修正します)

DocumentRoot “/var/www/html”
 ↓
DocumentRoot “/data/html”    <--こちらに修正

<Directory “/var/www/html”>
 ↓
<Directory “/data/html”>     <--こちらに修正

DirectoryIndex index.html
 ↓
DirectoryIndex index.php index.html  <--こちらに修正

mimetypeの設定追加をします
# vi /etc/mime.types
application/x-httpd-php                php
application/x-httpd-php-source    phps

phpの設定をします
phpのログを記録するディレクトリを作ります
# mkdir /var/log/php
# chown apache:apache /var/log/php (apacheから書き込めるようにします)
# chmod 755 /var/log/php

オリジナルの設定ファイルを残しておきます
# cp /etc/php.ini /etc/php.ini.org

phpの設定ファイルを修正します
# vi /etc/php.ini
;date.timezone =
 ↓
date.timezone = 'Asia/Tokyo'

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
 ↓
error_reporting = E_ALL & ~E_NOTICE

;error_log = php_errors.log
 ↓
error_log = "/var/log/php/php_errors.log" (さきほど作ったディレクトリにログを残すようにします)

memory_limit = 128M
 ↓
memory_limit = 256M

post_max_size = 8M
 ↓
post_max_size = 51M

upload_max_filesize = 2M
 ↓
upload_max_filesize = 51M

;mbstring.language = Japanese
 ↓
mbstring.language = Japanese

;mbstring.internal_encoding = EUC-JP
 ↓
mbstring.internal_encoding = UTF-8

;mbstring.http_input = auto
 ↓
mbstring.http_input = pass

;mbstring.http_output = SJIS
 ↓
mbstring.http_output = pass

;mbstring.encoding_translation = Off
 ↓
mbstring.encoding_translation = Off

;mbstring.detect_order = auto (そのまま)

;mbstring.substitute_character = none
 ↓
mbstring.substitute_character = none;

;mbstring.func_overload = 0
 ↓
mbstring.func_overload = 0

;mbstring.strict_detection = Off
 ↓
mbstring.strict_detection = Off

max_execution_time = 30
   ↓
max_execution_time = 300

max_input_time = 60
   ↓
max_input_time = 300

# cd /data/html (httpdのドキュメントルートに移動します)
# vi test.php (phpが本当に動くかチェック用のファイルを作ります)
下記の3行を記入します。
<?php
phpinfo();
?>

phpの設定変更を反映させるためにhttpdをリスタートします
# systemctl restart httpd

ブラウザでこのサーバーにアクセスしてPHPテスト画面が出ればOKです。
http://( FQDN )/test.php

MaiaDBの設定をします
# systemctl start mariadb (データベースサーバーをスタートします)
# systemctl enable mariadb (パワーONでOSが立ち上がるとmariadbも自動で立ち上がるように設定します)

# mysql_secure_installation (mariadbの初期設定をします)
Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password:  (適当なパスワード)
Re-enter new password:(適当なパスワード)
Remove anonymous users? [Y/n]Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n]  Y
Reload privilege tables now? [Y/n] Y
Thanks for using MariaDB!

# cp /etc/my.cnf /etc/my.cnf.org
データベースフォーマットを指定します
# vi /etc/my.cnf
innodb_file_per_table = 1
innodb_file_format = Barracuda

# mysql -u root -p(先ほど設定したパスワード) (rootで入ります)
>  select host,user,password from mysql.user;(ユーザーとパスワードの状況をチェックします)
> create database zabbix character set utf8 collate utf8_bin;
> grant all on zabbix.* to zabbix@localhost identified by 'zabbixユーザー用のパスワード';
> show databases;
> exit

Zabbixのインストール
# cd /usr/local/src
必要なソフトをインストールします
# wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64//iksemel-1.4-6.sdl7.x86_64.rpm
# rpm -Uvh iksemel-1.4-6.sdl7.x86_64.rpm

# wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
# wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-server-mysql-4.0.1-1.el7.x86_64.rpm
# wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-web-4.0.1-1.el7.noarch.rpm
# wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-web-japanese-4.0.1-1.el7.noarch.rpm
# wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-web-mysql-4.0.1-1.el7.noarch.rpm
# wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-get-4.0.1-1.el7.x86_64.rpm
# wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.1-1.el7.x86_64.rpm

# rpm -ivh --nodeps zabbix-server-mysql-4.0.1-1.el7.x86_64.rpm zabbix-web-4.0.1-1.el7.noarch.rpm  zabbix-web-japanese-4.0.1-1.el7.noarch.rpm zabbix-web-mysql-4.0.1-1.el7.noarch.rpm zabbix-agent-4.0.1-1.el7.x86_64.rpm zabbix-release-4.0-1.el7.noarch.rpm zabbix-get-4.0.1-1.el7.x86_64.rpm

データベースに初期データを読み込ませます
# cd /usr/share/doc/zabbix-server-mysql-4.0.1
# gunzip create.sql.gz
# mysql -u root -pさっき設定したパスワード zabbix < create.sql

データベースアクセス用のパスワードをZabbixに設定します
# vi /etc/zabbix/zabbix_server.conf
# DBPassword=
↓ パスワード設定
DBPassword=2018zabbix
# vi /etc/httpd/conf.d/zabbix.conf
# php_value date.timezone Europe/Riga
↓ タイムゾーンの設定
php_value date.timezone Asia/Tokyo

# systemctl restart httpd
# systemctl start zabbix-server
# systemctl enable zabbix-server
# systemctl start zabbix-agent
# systemctl enable zabbix-agent

# zabbix_get -s 127.0.0.1 -k agent.version
4.0.1     ←バージョンが表示されればOKです

ブラウザで http://[FQDN]/zabbix を開いて初期設定を行います
Zabbix photo01
データベースへの接続情報を入力します。
Zabbix photo02
Zabbix photo03
ログイン情報:
ユーザー         Admin
初期パスワード  zabbix
Zabbix photo04
ログインすると下記のようなダッシュボードが表示されます。
Zabbix photo05

検出対象のlinuxサーバーにZabbixエージェントをインストール
# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.1-1.el7.x86_64.rpm
# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-get-4.0.1-1.el7.x86_64.rpm

エージェントの起動
# systemctl start zabbix-agent
# systemctl enable zabbix-agent

# zabbix_get -s 127.0.0.1 -k agent.version
4.0.1     ←バージョンが表示されればOKです



最終更新日時: 2023年 10月 13日(金曜日) 10:49