Raspberry Pi3の温湿度監視をZabbixに取り込みグラフ化トリガによるアクションを実現する。
CentOS
CentOSは最小インストールを仮想ホストに行ってある Hyper-V OracleVMとも同様設定
公式のマニュアルがわかりやすい 🙂
https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages
1 2 |
# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) |
Firewalldの停止と無効化(正規運用時は有効化設定する)
1 2 3 4 |
# systemctl stop firewalld # systemctl disable firewalld Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. |
SElinux
1 2 |
# vi /etc/selinux/config SELINUX=disabled |
もしくは
1 2 3 |
# getsebool -a | grep zabbix httpd_can_connect_zabbix --> off zabbix_can_network --> off |
1 2 3 4 5 |
# setsebool -P httpd_can_connect_zabbix on # setsebool -P zabbix_can_network on # getsebool -a | grep zabbix httpd_can_connect_zabbix --> on zabbix_can_network --> on |
ホストの再起動をここで行っておく。忘れているとWebでzabbix-serverとの接続ができずにはまった。常識の範疇だと思うが、、、 😥
MySQL関連
Yumリポジトリのダウンロード
http://dev.mysql.com/downloads/repo/yum/
wgetでもOK
1 2 |
# yum install wget # wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm |
リポジトリの追加インストール
1 2 3 4 5 |
# rpm -ivh mysql57-community-release-el7-8.noarch.rpm 警告: mysql57-community-release-el7-8.noarch.rpm: ヘッダー V3 DSA/SHA1 Signature、鍵 ID 5072e1f5: NOKEY 準備しています... ################################# [100%] 更新中 / インストール中... 1:mysql57-community-release-el7-8 ################################# [100%] |
mysql関連インストールとインストール確認(更新5.7.14になる)
1 2 3 4 5 6 7 8 |
# yum install mysql-community-server # rpm -qa | grep mysql mysql57-community-release-el7-8.noarch mysql-community-common-5.7.14-1.el7.x86_64 mysql-community-client-5.7.14-1.el7.x86_64 mysql-community-libs-compat-5.7.14-1.el7.x86_64 mysql-community-libs-5.7.14-1.el7.x86_64 mysql-community-server-5.7.14-1.el7.x86_64 |
mysqlデーモン起動
1 |
# systemctl start mysqld |
mysql起動
1 2 |
# mysql -u root -p ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) |
ぉぉノー!!いつから仕様変わったの??? 😥
参考にさせていただきました。
http://weblabo.oscasierra.net/mysql-57-init-setup/
ログファイルに初期パスワードの記載がある
1 2 |
# vi /var/log/mysqld.log 2016-08-05T23:08:52.632727Z 1 [Note] A temporary password is generated for root@localhost: qPTOIukVx9;v |
パスワードの有効期間を無制限化(非推奨)
後述 mysql> uninstall plugin validate_password;でこの設定は消去されるので設定必要なし
1 2 3 4 |
#vi /etc/my.cnf [mysqld] character-set-server = utf8 default_password_lifetime = 0 |
パスワードポリシーを低くする(非推奨)
1 2 3 4 5 6 7 8 9 10 11 12 |
mysql> SET GLOBAL validate_password_policy=LOW; Query OK, 0 rows affected (0.00 sec) ALTER USER 'root'@'localhost' IDENTIFIED BY 'PASSWORD'; Query OK, 0 rows affected (0.00 sec) mysql> select @@validate_password_policy; +----------------------------+ | @@validate_password_policy | +----------------------------+ | LOW | +----------------------------+ |
結局のところ乱暴かも知れないがこのパスワード縛りを削除してしまう
1 2 |
mysql> uninstall plugin validate_password; Query OK, 0 rows affected (0.00 sec) |
ログイン 入れるかな
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.7.13 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> |
ZABBIX
ZABBIXリポジトリをインストール
http://www.zabbix.com/download.php
wgetだと
1 |
# wget http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm |
1 2 |
# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm # yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-web-japanese zabbix-get zabbix-agent zabbix-web-japanese zabbix-get |
ZABBIX_MySQLデータベース関連設定
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# mysql -u root -p mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; ###mysql> SET PASSWORD FOR 'zabbix'@'localhost' = PASSWORD('zabbix'); mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | zabbix | +--------------------+ 5 rows in set (0.00 sec) |
ZABBIX用初期DB作成 DB名を指定しないではまる 💡 -pのあとのzabbix
1 2 3 |
# cd /usr/share/doc/zabbix-server-mysql-3.0.3/ # zcat create.sql.gz | mysql -u zabbix -p zabbix Enter password: |
Edit database configuration in zabbix_server.conf
zabbix_server.confの編集
1 2 3 4 5 |
# vi /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix |
中身は?? テーブルができていることを確認しておく
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# mysql -u zabbix -p mysql> use zabbix mysql> show tables; +----------------------------+ | Tables_in_zabbix | +----------------------------+ | acknowledges | | actions | | alerts | | application_discovery | | application_prototype | | application_template | | applications | | auditlog | | auditlog_details | | autoreg_host | | conditions | | config | | dbversion | | dchecks | | dhosts | | drules | | dservices | | escalations | | events | | expressions | | functions | | globalmacro | | globalvars | | graph_discovery | | graph_theme | | graphs | | graphs_items | | group_discovery | | group_prototype | | groups | | history | | history_log | | history_str | | history_text | | history_uint | | host_discovery | | host_inventory | | hostmacro | | hosts | | hosts_groups | | hosts_templates | | housekeeper | | httpstep | | httpstepitem | | httptest | | httptestitem | | icon_map | | icon_mapping | | ids | | images | | interface | | interface_discovery | | item_application_prototype | | item_condition | | item_discovery | | items | | items_applications | | maintenances | | maintenances_groups | | maintenances_hosts | | maintenances_windows | | mappings | | media | | media_type | | opcommand | | opcommand_grp | | opcommand_hst | | opconditions | | operations | | opgroup | | opinventory | | opmessage | | opmessage_grp | | opmessage_usr | | optemplate | | profiles | | proxy_autoreg_host | | proxy_dhistory | | proxy_history | | regexps | | rights | | screen_user | | screen_usrgrp | | screens | | screens_items | | scripts | | service_alarms | | services | | services_links | | services_times | | sessions | | slides | | slideshow_user | | slideshow_usrgrp | | slideshows | | sysmap_element_url | | sysmap_url | | sysmap_user | | sysmap_usrgrp | | sysmaps | | sysmaps_elements | | sysmaps_link_triggers | | sysmaps_links | | timeperiods | | trends | | trends_uint | | trigger_depends | | trigger_discovery | | triggers | | users | | users_groups | | usrgrp | | valuemaps | +----------------------------+ 113 rows in set (0.00 sec) |
Apache
1 2 3 4 |
# vi /etc/httpd/conf.d/zabbix.conf # php_value date.timezone Europe/Riga ↓ php_value date.timezone Asia/Tokyo |
Zabbixサーバの起動と自動起動設定
1 2 |
# systemctl start zabbix-server # systemctl enable zabbix-server |
Apache再起動
1 |
# systemctl restart httpd |
動作確認用にAgentを起動しておく
1 2 |
# systemctl start zabbix-agent # systemctl enable zabbix-agent |
起動しているかチェック 稼働Versionの表示があれば成功
1 2 |
# zabbix_get -s 127.0.0.1 -k agent.version 3.0.4 |
各daemonの起動設定と再起動(念のため)
1 2 3 4 5 6 7 8 |
# systemctl enable mysqld # systemctl enable httpd # systemctl enable zabbix-server # systemctl enable zabbix-agent # systemctl restart mysqld # systemctl restart httpd # systemctl restart zabbix-server # systemctl restart zabbix-agent |
Webからのセットアップ
要件が整っているか→All OK!!
データベース設定 Postgres Oracle DB2なども大丈夫
ホスト Port設定 Nameは空白
セットアップのSummary
セットアップ完了
ログイン
Username:Admin
Password:zabbix
初期は英文 設定は別に記す予定
コメント