Zabbixをインストール

要件

  • CentOS7 minimal
  • Apatch 2.4.6
  • MariaDB 5.5
  • PHP 7.1
  • Zabbix 3.4

※ 本記事は同一ホスト内にZabbixとMariaDBを設置したっ場合を想定する。

LAMP環境の構築

リポジトリの登録

yum -y install epel-release rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm yum -y update

Zabbixのインストール

yum --enablerepo=remi,remi-php72 install \ zabbix-server-mysql zabbix-web-mysql zabbix-web-japanese zabbix-agent \ mariadb mariadb-server

MariaDBの起動

systemctl start mariadb systemctl enable mariadb

データベースの初期設定

  • セキュリティの設定
  • パスワード設定
  • 不要な権限の削除
mysql_secure_installation

以下のように表示される。                                

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

SQLによるDatabaseに対する権限付与

mysql -u root -p

Zabbix用のデータベースを作成

データベースの作成

create database zabbix character set utf8 collate utf8_bin;

ユーザーの作成と権限の付与

grant all privileges on zabbix.* to zabbix@localhost identified by 'password';

MariaDBから抜ける

exit;

初期スキーマとデータをインポートする。(DBユーザのパスワードを入力)

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbix -p zabbix

Zabbix の設定ファイルを編集

/etc/zabbix/zabbix_server.conf を編集

DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=password

/etc/httpd/conf.d/zabbix.conf を編集 . 以下を追加する。

<IfModule mod_php7.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 Asia/Tokyo </IfModule>

PHPの設定

/etc/php.ini を編集 . 以下をように値を変える。

max_execution_time = 300 max_input_time = 300 post_max_size = 16M date.timezone = Asia/Tokyo

ファイアウォールの設定

firewall-cmd --add-port=80/tcp --permanent firewall-cmd --reload

SELinuxにポリシーを追加

type=AVC msg=audit(1459755315.910:254): avc: denied { setrlimit } for pid=25766 comm="zabbix_server" scontext=unconfined_u:system_r:zabbix_t:s0 tcontext=unconfined_u:system_r:zabbix_t:s0 tclass=process type=SYSCALL msg=audit(1459755315.910:254): arch=c000003e syscall=160 success=no exit=-13 a0=4 a1=7ffdd96e5f00 a2=0 a3=7ffdd96e5c80 items=0 ppid=1 pid=25766 auid=0 uid=498 gid=499 euid=498 suid=498 fsuid=498 egid=499 sgid=499 fsgid=499 tty=(none) ses=1 comm="zabbix_server" exe="/usr/sbin/zabbix_server_mysql" subj=unconfined_u:system_r:zabbix_t:s0 key=(null)

サービスの起動

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

ブラウザでつなぐ

http://<IP>/zabbix/
Username:Admin Password:zabbix