LoginSignup
1
1

More than 5 years have passed since last update.

CentOS7.2 Zabbix3インストールのメモ

Last updated at Posted at 2016-12-17

CentOS7.2にzabbixをセットアップしたときのメモです。
自分が忘れない為の備忘録。

前提

CentOS7.2
MariaDB5.5
PHP5.6
zabbix3.0.5

httpdの設定は完了していることを前提
設定は別記事で紹介します

CentOS7.2を最小構成でインストール

アップデート
yum update

firewalldの設定

zabbixサーバーがzabbix-agentとhttpのアクセスを受けられるように設定を変更
httpsやsnmpトラップで設定する場合は適時設定してください。

firewall-cmd --add-port=10051/tcp --zone=public --permanent
firewall-cmd --add-service=http --zone=public --permanent

zabbix-agentをインストールしたサーバーがfirewalldを使用している場合は次のポートも開けます。

firewall-cmd --add-port=10050/tcp --zone=public --permanent

PHPインストール

標準リポジトリではPHP5.6が入らないのでEPELとRemiリポジトリを追加する

EPELリポジトリ

yum install epel-release

Remiリポジトリ

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

PHP5.6インストール

yum install --enablerepo=remi,remi-php56 php php-devel php-mysqld php-mbstring php-pdo php-gd

php.ini編集

/etc/php.ini
date.timezone = "Asia/Tokyo"

mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_input = UTF-8
mbstring.http_output = pass
mbstring.encoding_translation = On
mbstring.detect_order = auto
mbstring.substitute_charset = none

MariaDBインストール

yum install mariadb mariadb-server

文字コードをUTF-8にする
/etc/my.cnfの[mysqld]内に次を追加

/etc/my.cnf
[mysqld]
character-set-server=utf8

サーバー起動時にmariadbが起動するように設定

systemctl enable mariadb
systemctl start mariadb

初期セットアップ

mysql_secure_installation
Enter current password for root (enter for none):[enter]
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][enter]
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][enter]
 ... 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][enter]
 ... 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][enter]
 - 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][enter]
 ... 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!

zabbix用のDB作成

mysql -u root -p
zabbix用DB

CREATE DATABASE zabbix;
GRANT ALL PRIVILEGES ON zabbix.* to zabbix@localhost IDENTIFIED BY 'password';

zabbixインストール

今回は公開されているリポジトリを使用してyumインストールします。

yum install http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

zabbixインストール
serverとagentを両方ともセットアップします

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

初期データを先ほど作成したDBに投入
pathはバージョンによって微妙に変わるので要確認

 zcat /usr/share/doc/zabbix-server-mysql-3.0.0/create.sql.gz | mysql -uroot zabbix

zabbix_serverの設定

/etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=password

zabbixWEBインターフェースのタイムゾーン指定
デフォルトでコメントアウトされているので修正

/etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Tokyo

各種サービス開始&自動起動設定

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

WEBインターフェースにアクセス

http://サーバーのアドレス/zabbix/
最初のアクセス時は、Zabbix初期設定ウィザードが表氏されるので、DBへのアクセス情報などを入力して画面の通り進める。

すべて完了するとログイン画面が表示されるので
ユーザー名:Admin
パスワード:zabbix
でログインし、ユーザーのパスワードの変更などを行う。

SELinuxの設定

SELinuxが作動しているとhttpdからzabbix-serverへのアクセスが拒否され動作しないはずです。
次のコマンドでアクセスを許可します。

setsebool -P httpd_can_connect_zabbix on
setsebool -P zabbix_can_network on

これで正常に動作するはずです。

誤字脱字、間違っている部分がありましたらご指摘ください。

1
1
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
1