quarta-feira, 22 de outubro de 2014

Install Zabbix on Centos-6.4

1. Introduction


This post shows how to install zabbix into CentOs 6.4

2. Step by Step


Step #1 - Update SO packages


# mkdir /tmp/install
# cd /tmp/install/
# wget http://epel.gtdinternet.com/6/i386/epel-release-6-7.noarch.rpm
# rpm -ivh epel-release-6-7.noarch.rpm
# yum -y update

Step #2 - Install Packages dependencies


# yum -y install httpd php php-common php-mysql php-gd php-bcmath php-mbstring php-xml mysql mysql-server mysql-devel net-snmp net-snmp-devel net-snmp-utils net-snmp-libs gcc gcc-devel gcc-devel curl curl-devel

Step #3 - Download Zabbix binnaries


# mkdir /tmp/install
# cd /tmp/install/
# wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.4.1/zabbix-2.4.1.tar.gz

Step #4 - Create Zabbix User


# adduser zabbix -s /bin/false

Step #5 - Extract Zabbix source


# tar xzvf zabbix-*.tar.gz
# cd zabbix-*

Step #6 - Start MySQL and create Zabbix database


# service mysqld start
# chkconfig mysqld on
# mysql -u root
mysql> create database zabbix character set utf8;
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
mysql> exit

# mysql -u root zabbix < database/mysql/schema.sql

# mysql -u root zabbix < database/mysql/images.sql
# mysql -u root zabbix < database/mysql/data.sql

Step #7 - Configure,  Compile and Make


# ./configure --enable-server --with-mysql --with-net-snmp --with-libcurl --enable-agent 

# make install


Step #8 - Configure Zabbix Server - /etc/zabbix


vi /usr/local/etc/zabbix_server.conf 
  :
DBHost=localhost
DBName=zabbix
DBUser=zabbix
  :
LogFileSize=10
  :

Step #9 - Configure Zabbix Agent - /usr/local/etc/zabbix_agentd.conf


vi /usr/local/etc/zabbix_agentd.conf
  :
Server=127.0.0.1
  :

Step #10 - Disable SELinux configuration


vim /etc/selinux/config
  :
SELINUX=disabled
  :



Step #11 - Disable IPTables or Configure IPTables for zabbix


iptables -nvL --line-numbers
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1      588 39946 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
2        0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0
3       56  3922 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0
4        0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
5      355 51380 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT 462 packets, 92468 bytes)
num   pkts bytes target     prot opt in     out     source               destination
[root@oracle-linux64 ~]#

As we can see, there is a INPUT rule #1 that accept all sources/destination but only in some states. And ther is a INPUT rule #5 that reject everything. So, we have to disable firewall or add iptable rule to accept Oracle port 1521.

  • Option #1: To disable Iptable do this:
service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
chkconfig iptables off

  • Option #2: To keep Iptables running and add a new rule to accept Zabbix and HTTP ports ( 80, 10050, 10051) do this:
iptables -I INPUT 1 -p tcp --dport 80    -j ACCEPT
iptables -I INPUT 2 -p tcp --dport 10050 -j ACCEPT
iptables -I INPUT 3 -p tcp --dport 10051 -j ACCEPT
# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
service iptables restart

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Unloading modules:                               [  OK  ]

iptables: Applying firewall rules:                         [  OK  ]


Step #12 - Start Zabbix Service, check process 

# echo
# echo 'Starting Zabbix (server and agent) ...'
# echo
# zabbix_server
# zabbix_agentd
# ps aux | grep zabbix
  :
zabbix   26603  0.0  0.2 131636  2484 ?        S    11:08   0:00 zabbix_server
zabbix   26607  0.0  0.1 131636  1960 ?        S    11:08   0:00 zabbix_server: configuration syncer [synced configuration in 0.008139 sec, idle 60 sec]
zabbix   26608  0.0  0.1 131636  1556 ?        S    11:08   0:00 zabbix_server: db watchdog [synced alerts config in 0.001322 sec, idle 60 sec]
zabbix   26609  0.0  0.3 229520  3208 ?        S    11:08   0:00 zabbix_server: poller #1 [got 0 values in 0.000006 sec, idle 5 sec]
  :
#

echo
echo 'Adding Zabbix (server and agent) start running during boot ...'
echo
# vi /etc/rc.d/rc.local
  :
/usr/local/sbin/zabbix_server
/usr/local/sbin/zabbix_agentd

Step #13 - Install and configure Zabbix Web Interface (php)

# cp -r frontends/php/* /var/www/html/zabbix/
chown -R apache:apache /var/www/html/zabbix/
# vi /etc/php.ini
  :
max_execution_time = 300
max_input_time = 300
date.timezone = "America/Sao_Paulo"
post_max_size = 16M
  :
# echo
# echo 'Restarting HTTP Server ...'
#

# service httpd restart


Step #14 - Complete Web Installation in your browser

  • http://<zabbix-server-ip-address>/zabbix
  • Press "next" to see "2. Check of pre-requisites"
  • Press "next" to see "3. Configure DB Connection"
  • Configure Database Name "zabbix", User "zabbix" and Password "zabbix"
  • Press "Test" to Test connection and wait for message "Ok"
  • Press "Next" to "4. Zabbix server details"
  • Configure Name "Zabbix Server" 
  • Press "Next" to "5. Pre-Installation summary"
  • Press "Next" to "6. Install". If you get an error message like "Configuration file "/var/www/html/zabbix/conf/zabbix.conf.php" create fail. Check permission and ownership on path "/var/www/html/zabbix/". Change ownership to "apache" and change permission to read, write and execute
  • Press "Finish" to complete installation
  • Sign in using username "admin" and password "zabbix"

Step #15 - Enabling Zabbix Server self monitoring


  • On Zabbix Menu :: "Configuration >> Host": click on hiperlink "not monitored" to change monitoring status. Confirm enable operation


3. References




Nenhum comentário:

Postar um comentário