LoginSignup
1
6

More than 5 years have passed since last update.

CentOS7にZABBIX3.4をインストールしてみた。

Last updated at Posted at 2018-07-27

はじめに

CentOS7.3にZABBIXの最新版3.4系をインストールしてみました。
その時の備忘録です。

インストール手順

1.CentOS7を最小構成でインストールします。

2./etc/selinux/configを編集し、SELinuxを無効化します。

# sestatus
SELinux status:                 disabled

3.必要に応じてyum updateを行います。

# yum update

4.yum update後サーバを再起動します。

# reboot

5.Apache/DBなど必要なパッケージをインストールします。

# yum install -y httpd php mariadb mariadb-server

6.Zabbix3.4のレポジトリを追加します。

# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm を取得中
準備しています...              ################################# [100%]
更新中 / インストール中...
   1:zabbix-release-3.4-1.el7.centos  ################################# [100%]

7.ZABBIXのインストールを行います。

# yum install zabbix-server-mysql zabbix-web-mysql zabbix-web-japanese zabbix-agent zabbix-get

8.MariaDBの初期設定を行います。

※DBを起動
# systemctl start mariadb

※自動起動設定
# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

※自動起動設定確認
# systemctl is-enabled mariadb
enabled

※初期設定
# 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 <==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 <==anonymousユーザを削除するかどうか
 ... 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 <==リモートでのrootログインを許可するかどうか
 ... 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 <==データベース「test」を削除するかどうか
 - 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!

9.ZABBIX用のデータベースとユーザーを作成します。

# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by '<DBパスワード>';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> select user,host from mysql.user;
+--------+-----------+
| user   | host      |
+--------+-----------+
| root   | 127.0.0.1 |
| root   | ::1       |
| root   | localhost |
| zabbix | localhost |
+--------+-----------+
4 rows in set (0.00 sec)

MariaDB [(none)]> quit
Bye

10.DBにSQLを流し込みます。

# zcat /usr/share/doc/zabbix-server-mysql-3.4.11/create.sql.gz | mysql -uzabbix zabbix -p
Enter password: <==MariaDBのパスワード入力

11.ZABBIX設定ファイルにDB情報を書き込みます。

/etc/zabbix/zabbix_server.conf
※DBホストの設定
# echo "DBHost=localhost" >> /etc/zabbix/zabbix_server.conf

※確認
# grep DBHost /etc/zabbix/zabbix_server.conf 
### Option: DBHost
# DBHost=localhost
DBHost=localhost
/etc/zabbix/zabbix_server.conf
※DBパスワードの設定
# echo "DBPassword=<DBパスワード>" >> /etc/zabbix/zabbix_server.conf

※確認
# grep DBPassword /etc/zabbix/zabbix_server.conf 
#       For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
### Option: DBPassword
# DBPassword=
DBPassword=<DBパスワード>

12.Apache httpd の設定ファイルで、タイムゾーン(日本/東京)を指定します。

/etc/httpd/conf.d/zabbix.conf
<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
        php_value date.timezone Asia/Tokyo <==タイムゾーンを追加

13.Apacheを起動します。

# systemctl start httpd

※自動起動設定
# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

※自動起動設定確認
# systemctl is-enabled httpd
enabled

14.ZABBIXサーバを起動します。

# systemctl start zabbix-server

※自動起動設定
# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.

※自動起動設定確認
# systemctl is-enabled zabbix-server
enabled

15.ZABBIXエージェントを起動します。

# systemctl start zabbix-agent

※自動起動設定
# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.

※自動起動設定確認
# systemctl is-enabled zabbix-agent
enabled

※ZABBIXエージェントの動作確認。Zabbixのバージョンが表示されればOK
# zabbix_get -s 127.0.0.1 -k agent.version
3.4.11

以上。

1
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
6