1
2

More than 3 years have passed since last update.

ansible: zabbix4.0インストール(CentOS7 or 8用)

Last updated at Posted at 2020-05-09

つくったもの

Ansible-playbook(https://github.com/mishikawan/zabbix40-ansible.git )です。
CentOS7又はCentos8環境に、Zabbix4.0(ZabbixRepo使用)をインストールする。

Playbookの内容

rolesとして3つに分割
- common: OSの初期設定用
- server: zabbix-server設定用
- agent: zabbix-agent設定用

commonの処理内容

  1. selinux無効化
  2. hostname設定
  3. timezoneの設定(zone情報指定可能)
  4. zabbix-repoの登録

serverの処理内容

  1. Firewalldの穴開け(http,snmptrap,zabbix(10051))
  2. zabbix-server関連のyum install
  3. mysqlの設定ファイル修正(innodb_file_per_table対応)
  4. mysql開始
  5. mysql設定( DB名"zabbix"のユーザ"zabbix"のパスワード設定)
  6. zabbix用初期データ(create.sql.gz)を導入
  7. httpd(phpのtimezone)設定
  8. httpd開始
  9. zabbixの設定ファイル更新+新規作成
  10. zabbix-serverの開始

zabbix-agentの処理内容

  1. Firewalldの穴開け(zabbix(10050))
  2. zabbix-agentのyum install
  3. zabbix-agent設定(HostnameItem,Server,ServerActive)
  4. zabbix-agentの開始

設定情報のカスタマイズ

設定情報は、inventory/inventory.ini に格納されているので自分用に修正
以下、clone直後の状態。

初期設定情報
Zabbixサーバ機のホスト名は testsv01 ,IP 192.168.11.1
Zabbixエージェント機のホスト名は testcl01 ,IP 192.168.11.2
タイムゾーンは、 Asia/Tokyo
DB(zabbix)のパスワードは password (ただし、ユーザ名は"zabbix"固定)
inventory/inventory.ini
[servers]
testsv01 ansible_ssh_host=192.168.11.1 ansible_ssh_user=root
[agents]
testcl01 ansible_ssh_host=192.168.11.2 ansible_ssh_user=root
[all:vars]
timezone="Asia/Tokyo"
zabbix_server_ip="192.168.11.1"
[servers:vars]
zabbix_mysql_password="password"

必要に応じて変更してください。

playbook実行方法

  1. inventory.iniの修正
  2. ansibleサーバで以下を実行
実行コマンド
git clone https://github.com/mishikawan/zabbix40-ansible.git
cd zabbix40-ansible/
ansible-playbook -i inventory/inventory.ini site.yml

3.稼働確認。zabbix-serverはURLでアクセス可能。

URL情報
http://{zabbix-server-ip}/zabbix
  ID = Admin
  PASS = zabbix

(参考)作業の振り返り

CentOS8用を作ってみて

CentOS8 + (標準Repo)Mariadb 10.3.17 + zabbix4.0 ではエラーが出る
  • Zabbix初期データ(create.sql.gz)をMariadbに食わせると "ERROR 1118 (42000) at line 1278: Row size too large (> 8126)." ってエラーが出る。

参考: https://qiita.com/hatappi/items/132f56c00e428beef777
参考: https://support.zabbix.com/browse/ZBX-16465

上記URLにも書いているけど、テーブルhost_inventoryの定義が大きすぎてエラーになる。
CentOS7の標準Mariadb5.5ではエラーでないのになんでと思ったら、エラーがでないだけで実際に大きなデータ掘り込んだらエラー出た。初めて知った。最悪やん。
ま普通の利用やったら越えそうにないから、CentOS7はとりあえず標準mariadbのままで(w)

  • CentOS8 の場合、(標準)Mysql8.0だとinnodb_default_row_formatがdynamicなのでこっちを利用しました。
innodb_default_row_format
# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.17 Source distribution
....
mysql> show global variables like '%row_format%';
+---------------------------+---------+
| Variable_name             | Value   |
+---------------------------+---------+
| innodb_default_row_format | dynamic |
+---------------------------+---------+
1 row in set (0.01 sec)
mysql> 
yumからdnfに変更
  • 基本的なRPM操作はCentOS8でもyumが同じように使える。当分はdnf覚えないぞっと
yumはdnfのリンクやったわ
     # ls -l /usr/bin/yum 
     lrwxrwxrwx. 1 root root 5 12月 20 00:43 /usr/bin/yum -> dnf-3
rpmでの提供ミドルウエアが新しい
  • いろいろ新しい
  • 特にPHPが7.2で、大好きなDokuwikiが、標準リポジトリで構築できる!
phpがmoduleからphp-fpmに変更
  • zabbixの導入/運用するだけだったら意識しなくて良い。
1
2
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
2