LoginSignup
3
11

More than 5 years have passed since last update.

Zabbix 3.0 と SNMPTT をCentOS7.X にインストールする

Last updated at Posted at 2017-08-22

0. 事前準備

# getenforce
※SELinux は無効化か
※SELinux が起動している場合は以下


# setenforce 0
# vi /etc/selinux/config
/etc/selinux/config
SELINUX=enforcing
↓
SELINUX=disabled
# systemctl status firewalld
※firewalled は無効化されているか
※firewalled が起動している場合は以下

# systemctl stop firewalld
# systemctl disable firewalld

1. 事前パッケージインストール

# cd /tmp
# wget http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

# rpm -ivh zabbix-release-3.0-1.el7.noarch.rpm

2. Zabbix インストール

# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-web-japanese zabbix-agent zabbix-get mariadb-server net-snmp

3. MariaDB設定

■構成ファイルの編集

# cd /etc
# cp -p my.cnf my.cnf.org

# vi my.cnf
/etc/my.cnf
[mysqld]
↓↓追記
character-set-server=utf8
skip-character-set-client-handshake
innodb_buffer_pool_size = XXG
innodb_log_files_in_group = 2
innodb_log_file_size = 128M
max_allowed_packet=16M
innodb_file_per_table
log-error=/var/log/mariadb/mariadb.log

innodb_flush_log_at_trx_commit = 2
↑↑ここまで

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

↓↓以下追記
[mysqldump]
socket=/var/lib/mysql/mysql.sock
max_allowed_packet=16M

[client]
socket=/var/lib/mysql/mysql.sock
↑↑ここまで

■MariaDB起動 及び 自動起動設定

# systemctl start mariadb
# systemctl status mariadb
# systemctl enable mariadb
# systemctl is-enabled mariadb

■DBの作成

# mysqladmin -uroot create zabbix --default-character-set=utf8

■DBアカウント作成

# mysql -uroot
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbixpassword';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit

■Zabbixの初期データベースをインポート

# cd /usr/share/doc/`rpm -qa | grep zabbix-server-mysql|cut -d"-" -f1,2,3,4`
# gunzip create.sql.gz
# mysql -uroot zabbix < create.sql

4. httpd基本設定 apache起動

# cd /etc/httpd/conf
# cp -p httpd.conf httpd.conf.org
# vi httpd.conf
以下を追記
/etc/httpd/conf/httpd.conf
-----------
# 以下編集
ServerName <ホスト名FQDN>

# 以下追記
ServerTokens Prod
ServerSignature Off
TraceEnable off
-----------

5. snmptrapd設定

# cd /etc/snmp
# vi snmptrapd.conf
以下の様に追記

/etc/snmp/snmptrapd.conf
以下を追記
---------
authCommunity log,execute,net <CommunityName>
perl do "/usr/sbin/snmptthandler-embedded";
---------

■snmptrapd起動 及び 自動起動設定
# systemctl start snmptrapd
# systemctl status snmptrapd
# systemctl enable snmptrapd
# systemctl is-enabled snmptrapd

6. zabbix_server設定

# cd /etc/zabbix
# cp -p zabbix_server.conf zabbix_server.conf.org30
# vi zabbix_server.conf
------------
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbixpassword
DBSocket=/var/lib/mysql/mysql.sock
SNMPTrapperFile=/var/log/snmptt/snmptt.log
StartSNMPTrapper=1
ListenIP=0.0.0.0
ValueCacheSize=500M
Timeout=30
------------

■zabbix_server起動 及び 自動起動設定
# systemctl start zabbix-server
# systemctl status zabbix-server
# systemctl enable zabbix-server
# systemctl is-enabled zabbix-server

7. 管理画面の設定

■メインページの表示

# cd /etc/httpd/conf.d
# vi zabbix.conf
以下の様に編集
※php_value upload_max_filesize と php_value date.timezone を編集します

------------
#
# Zabbix monitoring system php web frontend
#

Alias /zabbix /usr/share/zabbix

<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 10M
        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
    </IfModule>
</Directory>

<Directory "/usr/share/zabbix/conf">
    Require all denied
</Directory>

<Directory "/usr/share/zabbix/app">
    Require all denied
</Directory>

<Directory "/usr/share/zabbix/include">
    Require all denied
</Directory>

<Directory "/usr/share/zabbix/local">
    Require all denied
</Directory>
-----------------

■index 画面変更

# cd /etc/zabbix/web
# vi zabbix.conf.php
---- 以下をべた貼り --------------------------------
<?php
// Zabbix GUI configuration file.
global $DB;

$DB['TYPE']     = 'MYSQL';
$DB['SERVER']   = 'localhost';
$DB['PORT']     = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER']     = 'zabbix';
$DB['PASSWORD'] = 'zabbixpassword';

// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';

$ZBX_SERVER      = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '';

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
?>
-------------

# chown apache:apache zabbix.conf.php
# systemctl restart httpd

■Zabbix GUI にアクセス

http://<ZabbixサーバIPアドレス>/zabbix/
ユーザー名:admin
パスワード:zabbix

8.snmptt インストール

# cd /tmp
# wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
# rpm -ivh epel-release-7-11.noarch.rpm
# yum -y install snmptt
# yum -y install net-snmp-perl perl-Digest-SHA1 perl-Sys-Syslog perl-List-MoreUtils perl-IO-stringy net-snmp-utils perl perl-Module-Build perl-Time-HiRes

# cd /usr/share/snmptt
# cp ./snmptthandler-embedded /usr/sbin/
# chmod 755 /usr/sbin/snmptthandler-embedded

. 関連ファイルの設定
# cd /etc/snmp/
# vi snmptt.ini

---- 以下の様に編集 --------------------------------
##mode = standalone 
mode = daemon

##net_snmp_perl_enable = 0
net_snmp_perl_enable = 1

##net_snmp_perl_best_guess = 0 
net_snmp_perl_best_guess = 2

#date_time_format = 
date_time_format = %Y/%m/%d %H:%M:%S

##sleep = 5
sleep = 1

##syslog_enable = 1
syslog_enable = 0
---------------------------------------------------

■プロセスを起動 
# systemctl start snmptt
# systemctl status snmptt
# systemctl enable snmptt
# systemctl is-enabled snmptt

■snmptrapdの設定を変更 
# cd /etc/sysconfig/
# vi snmptrapd

---- 以下の様に編集 ---------------------------------------------------- 
OPTIONS="-m +ALL -On"
------------------------------------------------------------------------ 

■プロセスを再起動 
# systemctl restart snmptrapd
# systemctl restart snmptt

■テスト 
# snmptrap -v2c -c <CommunityName> localhost '' .1.3.6.1.6.3.1.1.5.3 test i 0
# tail /var/log/snmptt/snmptt.log
※ 出力メッセージが書き足されていれば成功 

■読込ディレクトリ調整
# cd /etc/snmp
# mkdir snmptt_Confs
# mv snmptt.conf ./snmptt_Confs/

# vi snmptt.ini
------------
/etc/snmp/snmptt.conf
↓
/etc/snmp/snmptt_Confs/snmptt.conf
------------
# systemctl restart snmptt
3
11
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
3
11