Projekt

Allgemein

Profil

Aktionen

Install Zabbix Server 2.2.x

preliminary note

this procedure was originally based on http://www.wikinixi.com/2011/12/install-zabbix-server-1-8-9-on-centos6/
you may also check https://www.zabbix.com/documentation/2.2/manual/installation/install_from_packages

Requirements

Server-Install

yum update
yum install httpd httpd-devel
yum install zabbix-server-mysql zabbix-agent zabbix-web-mysql
yum install mysql-server
chkconfig httpd on
chkconfig mysqld on
/etc/init.d/mysqld start
mysql_secure_installation
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 'password';
mysql> exit

cd /usr/share/doc/zabbix-server-mysql-2.2.1/create
mysql -u root -p zabbix < schema.sql
mysql -u root -p zabbix < images.sql
mysql -u root -p zabbix < data.sql
vim /etc/zabbix/zabbix_server.conf

# line 116: uncomment and add DB password for Zabbix
DBPassword=password

vim /etc/zabbix/zabbix_agentd.conf

# line 105: change to your hostname
Hostname=zabbix.server.com

vim /etc/php.ini

# line 440: change to Zabbix recommended
max_execution_time = 300

# line 449: change to Zabbix recommended
max_input_time = 300

# line 457: change to Zabbix recommended
memory_limit = 128M

# line 729: change to Zabbix recommended
post_max_size = 16M

# line 878: change to Zabbix recommended
upload_max_filesize = 2M

# line 946: uncomment and add your timezone
date.timezone = Europe/Vienna

/etc/init.d/zabbix-server start
/etc/init.d/zabbix-agent start
/etc/init.d/httpd restart
chkconfig zabbix-server on
chkconfig zabbix-agent on

Firewall

if you are going to monitor other systems than the localhost then you have to open ports 10050 and 10051

SELinux

as SELinux prevents the web-client to establish a connection to localhost:10050 you will get a wrong indication on Server-Status. Allow access to the server via

setsebool -P httpd_can_network_connect 1

Backup Zabbix config

is taken from http://zabbixzone.com/zabbix/backuping-only-the-zabbix-configuration/

see also https://github.com/xsbr/zabbixzone

This script is a simple way to backup all configuration tables (eg. templates, hostgroups, hosts, triggers…) without the history data.

As the result is very small (around 30 MB), is possible run this backup many times per day.

#!/bin/bash
#
# zabbix-mysql-backupconf.sh
# v0.2  - 20111105
# v0.21 - 20120912 modified to work with CentOS 6.x (JKE)
# v0.22 - 20130411 modified to work with Zabbix 2.0 (JKE)
#
# Configuration Backup for Zabbix 2.0 w/MySQL
#
# Author: Ricardo Santos (rsantos at gmail.com)
# http://zabbixzone.com
#
# Thanks for suggestions from:
# - Oleksiy Zagorskyi (zalex)
# - Petr Jendrejovsky
#
# mysql config
DBHOST="localhost" 
DBNAME="zabbix" 
DBUSER="zabbix" 
DBPASS="YOURMYSQLPASSWORDHERE" 
# some tools
MYSQLDUMP="/usr/bin/mysqldump" 
GZIP="/bin/gzip" 
DATEBIN="/bin/date" 
MKDIRBIN="/bin/mkdir" 
# target path
MAINDIR="/var/cache/myzabbixdump" 
DUMPDIR="${MAINDIR}/`${DATEBIN} +%Y%m%d%H%M`" 
${MKDIRBIN} -p ${DUMPDIR}
# configuration tables
CONFTABLES=( actions applications autoreg_host conditions config dchecks dhosts \
drules dservices escalations expressions functions globalmacro globalvars graph_discovery graph_theme \
graphs graphs_items groups help_items host_inventory hostmacro hosts hosts_groups \
hosts_templates housekeeper httpstep \
httpstepitem httptest httptestitem icon_map icon_mapping ids images interface item_discovery items items_applications \
maintenances maintenances_groups maintenances_hosts maintenances_windows \
mappings media media_type node_cksum nodes opcommand opcommand_grp opcommand_hst opconditions operations \
opgroup opmessage opmessage_grp opmessage_usr optemplate \
profiles proxy_autoreg_host proxy_dhistory proxy_history regexps \
rights screens screens_items scripts service_alarms services services_links \
services_times sessions slides slideshows sysmap_element_url sysmap_url sysmaps sysmaps_elements \
sysmaps_link_triggers sysmaps_links timeperiods trigger_depends trigger_discovery triggers \
user_history users users_groups usrgrp valuemaps )
# tables with large data
DATATABLES=( acknowledges alerts auditlog auditlog_details events \
history history_log history_str history_str_sync history_sync history_text \
history_uint history_uint_sync trends trends_uint )
# CONFTABLES
for table in ${CONFTABLES[*]}; do
        DUMPFILE="${DUMPDIR}/${table}.sql" 
        echo "Backuping table ${table}" 
        ${MYSQLDUMP} -R --opt --extended-insert=FALSE \
                -h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} --tables ${table} >${DUMPFILE}
        ${GZIP} -f ${DUMPFILE}
done
# DATATABLES
for table in ${DATATABLES[*]}; do
        DUMPFILE="${DUMPDIR}/${table}.sql" 
        echo "Backuping schema table ${table}" 
        ${MYSQLDUMP} -R --opt --no-data        \
                -h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} --tables ${table} >${DUMPFILE}
        ${GZIP} -f ${DUMPFILE}
done
echo
echo "Backup Completed - ${DUMPDIR}" 

Von Jeremias Keihsler vor etwa 7 Jahren aktualisiert · 2 Revisionen