以前、Amazon Linux に Zabbix Server 3.0 をインストールするというメモを書きました。 今回は CentOS7 に Zabbix Server 3.4 系をインストールする手順をメモします。
前提条件
以下の前提で進めます。
- CentOS7
- SELinux と firewalld は無効化されていること
PHP 7.x 系をインストールする
まず epel をインストールし、remi をインストールします。
yum install -y epel-release rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
remi から PHP をインストールします。 今回は 7.2 系をインストールしました。
yum -y --enablerepo=remi-php72 install \ httpd \ mariadb-server \ php72 \ php72-bcmath \ php72-gd \ php72-mbstring \ php72-mysqlnd
Zabbix のインストール
Zabbix のリポジトリを追加し、必要なものをインストールしていきます。 必須ではありませんが、zabbix-agent
をインストールしてサーバ自身も監視対象とします。
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm yum -y install \ zabbix-agent \ zabbix-get \ zabbix-server-mysql \ zabbix-web-japanese \ zabbix-web-mysql
MariaDB の設定
MariaDB の設定ファイルを修正します。 /etc/my.cnf.d/server.cnf
を以下のように書き換えます。
[mysqld] character-set-server = utf8 collation-server = utf8_bin skip-character-set-client-handshake innodb_file_per_table
設定ファイルの修正が完了したら MariaDB を再起動します。 合わせて自動起動の設定もしておきます。
systemctl enable mariadb systemctl start mariadb
データベースの作成
MariaDB 上に Zabbix 用のデータベースを作成しておきます。 まず MariaDB にログインします。
mysql -u root
ユーザ & データベースを作成します。
CREATE USER zabbix; CREATE DATABASE zabbix; GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'PASSWORD'; FLUSH PRIVILEGES; quit
SQL を流し込みます。
zcat /usr/share/doc/zabbix-server-mysql-3.4.1/create.sql.gz | mysql -u root zabbix
Zabbix の設定
Zabbix から MariaDB を参照する際のパスワードを設定します。 /etc/zabbix/zabbix_server.conf
の DBPassword
定義を書き換えます。
DBPassword=PASSWORD
タイムゾーンの修正
Apahce の設定ファイル中にタイムゾーンの設定があるので、修正しておきます。 /etc/httpd/conf.d/zabbix.conf
の php_value
を以下のように修正します。
php_value date.timezone Asia/Tokyo
PHP の設定ファイル修正
PHP の設定ファイル (php.ini
) を修正します。
sed -i -e "s/;date.timezone =/date.timezone = Asia\/Tokyo/g" /etc/php.ini sed -i -e "s/;always_populate_raw_post_data/always_populate_raw_post_data/g" /etc/php.ini sed -i -e "s/post_max_size = 8M/post_max_size = 16M/g" /etc/php.ini sed -i -e "s/max_execution_time = 30/max_execution_time = 300/g" /etc/php.ini sed -i -e "s/max_input_time = 60/max_input_time = 300/g" /etc/php.ini
起動
Zabbix サーバやエージェント、Apache を起動します。
systemctl enable zabbix-server systemctl start zabbix-server systemctl enable zabbix-agent systemctl start zabbix-agent systemctl enable httpd systemctl start httpd
これで Zabbix サーバのインストールは完了です。
参考
/etc/my.cnf.d/server.cnf の初期状態
# # These groups are read by MariaDB server. # Use it for options that only the server (but not clients) should see # # See the examples of server my.cnf files in /usr/share/mysql/ # # this is read by the standalone daemon and embedded servers [server] # this is only for the mysqld standalone daemon [mysqld] # this is only for embedded server [embedded] # This group is only read by MariaDB-5.5 servers. # If you use the same .cnf file for MariaDB of different versions, # use this group for options that older servers don't understand [mysqld-5.5] # These two groups are only read by MariaDB servers, not by MySQL. # If you use the same .cnf file for MySQL and MariaDB, # you can put MariaDB-only options here [mariadb] [mariadb-5.5]
/etc/httpd/conf.d/zabbix.conf の初期状態
# # Zabbix monitoring system php web frontend # Alias /zabbix /usr/share/zabbix <Directory "/usr/share/zabbix"> Options FollowSymLinks AllowOverride None Require all granted <IfModule mod_php5.c> php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value always_populate_raw_post_data -1 # php_value date.timezone Europe/Riga </IfModule> </Directory> <Directory "/usr/share/zabbix/conf"> Require all denied </Directory> <Directory "/usr/share/zabbix/app"> Require all denied </Directory> <Directory "/usr/share/zabbix/include"> Require all denied </Directory> <Directory "/usr/share/zabbix/local"> Require all denied </Directory>