LoginSignup
1
1

More than 5 years have passed since last update.

Zabbix 4.2インストール、Docker Image作成する

Posted at

概要

Docker CentOS(Official Image)をベースにして、Zabbix 4.2をインストール。
Docker Imageを作成。

環境

  • Windows 10 Pro
  • Windows PowerShell
  • Docker Desktop Community Version 2.0.0.3

手順

Docker CentOS(Official Image)準備

PowerShell上
1.

docker pull centos

コンテナ実行・コンテナに入る

PowerShell上
1.

docker run --privileged -it -d --name centos7 centos /sbin/init

2.

docker exec -it centos7 /bin/bash

CentOSコンテナ初期処理

コンテナ上
1.
/etc/yum.confの「tsflags=nodocs」コメントアウト
2.

localedef -f UTF-8 -i ja_JP ja_JP 

MySQLインストール・起動

コンテナ上
1.

yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

2.

yum -y install mysql-community-server

3.

systemctl enable mysqld.service

4.

systemctl start mysqld.service

MySQL初期パスワード確認

コンテナ上
1.

grep password /var/log/mysqld.log


[shell]2019-04-03T01:41:01.445286Z 1 [Note] A temporary password is generated for root@localhost: DQB>3&GcAhF1[/shell]
「root@localhost: 」の後ろがパスワード
控えておく

MySQLパスワード変更

コンテナ上
1.

mysql -uroot -p

パスワードを聞かれるので前作業で控えたパスワード入力
2.
mysql上

set password for root@localhost=password('Zabbix-db-9876');
quit[/shell]

Zabbixインストール

コンテナ上
1.

rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm

2.

yum clean all

3.

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

Zabbix DB初期設定

コンテナ上
1.

mysql -uroot -p

パスワードを聞かれるので「Zabbix-db-9876」入力
2.
mysql上
shell
create database zabbix character set utf8 collate utf8_bin;

grant all privileges on zabbix.* to zabbix@localhost identified by 'Zabbix-db-9876';

3.

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

Zabbix初期設定・起動

コンテナ上
1.
/etc/zabbix/zabbix_server.confに「DBPassword=Zabbix-db-9876」追加
「DBPassword」で検索すると適切な挿入位置は分かる
2.
/etc/httpd/conf.d/zabbix.confの「# php_value date.timezone Europe/Riga」を検索。
コメントを外す
「Europe/Riga」を「Japan」に変更
3.

systemctl restart zabbix-server zabbix-agent httpd

4.

systemctl enable zabbix-server zabbix-agent httpd

5.
コンテナ抜ける

exit

Docker Image作成

PowerShell上
1.
コンテナ停止

docker stop centos7

2.
Docker Image作成

docker commit centos7 zabbix4_2-centos7

作成したImageでコンテナ起動

PowerShell上

docker run --privileged -it -d -p 7777:80 --rm --name zabbix zabbix4_2-centos7

Zabbixアクセス先
http://localhost:7777/zabbix/
となります。

あとは

Data Volume等でMySQLを永続化すれば。

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