Projekt

Allgemein

Profil

Setup zabbix-server22 » Historie » Version 1

Jeremias Keihsler, 13.01.2017 12:33

1 1 Jeremias Keihsler
h1. Install Zabbix Server 2.2.x
2
3
h2. preliminary note
4
5
this procedure was originally based on http://www.wikinixi.com/2011/12/install-zabbix-server-1-8-9-on-centos6/
6
you may also check https://www.zabbix.com/documentation/2.2/manual/installation/install_from_packages
7
8
h2. Requirements
9
10
* [[repo_epel|EPEL]]
11
12
h2. Server-Install
13
14
<pre><code class="bash">
15
yum update
16
yum install httpd httpd-devel
17
yum install zabbix-server-mysql zabbix-agent zabbix-web-mysql
18
yum install mysql-server
19
chkconfig httpd on
20
chkconfig mysqld on
21
/etc/init.d/mysqld start
22
mysql_secure_installation
23
mysql -u root -p
24
</code></pre>
25
<pre><code class="bash">
26
mysql> create database zabbix character set utf8 collate utf8_bin;
27
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
28
mysql> exit
29
</code></pre>
30
<pre><code class="bash">
31
cd /usr/share/doc/zabbix-server-mysql-2.2.1/create
32
mysql -u root -p zabbix < schema.sql
33
mysql -u root -p zabbix < images.sql
34
mysql -u root -p zabbix < data.sql
35
vim /etc/zabbix/zabbix_server.conf
36
</code></pre>
37
<pre>
38
# line 116: uncomment and add DB password for Zabbix
39
DBPassword=password
40
</pre>
41
<pre><code class="bash">
42
vim /etc/zabbix/zabbix_agentd.conf
43
</code></pre>
44
<pre>
45
# line 105: change to your hostname
46
Hostname=zabbix.server.com
47
</pre>
48
<pre><code class="bash">
49
vim /etc/php.ini
50
</code></pre>
51
<pre>
52
# line 440: change to Zabbix recommended
53
max_execution_time = 300
54
 
55
# line 449: change to Zabbix recommended
56
max_input_time = 300
57
 
58
# line 457: change to Zabbix recommended
59
memory_limit = 128M
60
 
61
# line 729: change to Zabbix recommended
62
post_max_size = 16M
63
 
64
# line 878: change to Zabbix recommended
65
upload_max_filesize = 2M
66
 
67
# line 946: uncomment and add your timezone
68
date.timezone = Europe/Vienna
69
</pre>
70
<pre><code class="bash">
71
/etc/init.d/zabbix-server start
72
/etc/init.d/zabbix-agent start
73
/etc/init.d/httpd restart
74
chkconfig zabbix-server on
75
chkconfig zabbix-agent on
76
</code></pre>
77
78
h3. Firewall
79
80
if you are going to monitor other systems than the @localhost@ then you have to open ports @10050@ and @10051@
81
h3. SELinux
82
83
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
84
<pre><code class="bash">
85
setsebool -P httpd_can_network_connect 1
86
</code></pre>
87
88
h2. Backup Zabbix config
89
90
is taken from http://zabbixzone.com/zabbix/backuping-only-the-zabbix-configuration/
91
92
see also https://github.com/xsbr/zabbixzone
93
94
This script is a simple way to backup all configuration tables (eg. templates, hostgroups, hosts, triggers…) without the history data.
95
96
As the result is very small (around 30 MB), is possible run this backup many times per day.
97
98
<pre bash zabbix-mysql-backupconf.sh>
99
#!/bin/bash
100
#
101
# zabbix-mysql-backupconf.sh
102
# v0.2  - 20111105
103
# v0.21 - 20120912 modified to work with CentOS 6.x (JKE)
104
# v0.22 - 20130411 modified to work with Zabbix 2.0 (JKE)
105
#
106
# Configuration Backup for Zabbix 2.0 w/MySQL
107
#
108
# Author: Ricardo Santos (rsantos at gmail.com)
109
# http://zabbixzone.com
110
#
111
# Thanks for suggestions from:
112
# - Oleksiy Zagorskyi (zalex)
113
# - Petr Jendrejovsky
114
#
115
# mysql config
116
DBHOST="localhost"
117
DBNAME="zabbix"
118
DBUSER="zabbix"
119
DBPASS="YOURMYSQLPASSWORDHERE"
120
# some tools
121
MYSQLDUMP="/usr/bin/mysqldump"
122
GZIP="/bin/gzip"
123
DATEBIN="/bin/date"
124
MKDIRBIN="/bin/mkdir"
125
# target path
126
MAINDIR="/var/cache/myzabbixdump"
127
DUMPDIR="${MAINDIR}/`${DATEBIN} +%Y%m%d%H%M`"
128
${MKDIRBIN} -p ${DUMPDIR}
129
# configuration tables
130
CONFTABLES=( actions applications autoreg_host conditions config dchecks dhosts \
131
drules dservices escalations expressions functions globalmacro globalvars graph_discovery graph_theme \
132
graphs graphs_items groups help_items host_inventory hostmacro hosts hosts_groups \
133
hosts_templates housekeeper httpstep \
134
httpstepitem httptest httptestitem icon_map icon_mapping ids images interface item_discovery items items_applications \
135
maintenances maintenances_groups maintenances_hosts maintenances_windows \
136
mappings media media_type node_cksum nodes opcommand opcommand_grp opcommand_hst opconditions operations \
137
opgroup opmessage opmessage_grp opmessage_usr optemplate \
138
profiles proxy_autoreg_host proxy_dhistory proxy_history regexps \
139
rights screens screens_items scripts service_alarms services services_links \
140
services_times sessions slides slideshows sysmap_element_url sysmap_url sysmaps sysmaps_elements \
141
sysmaps_link_triggers sysmaps_links timeperiods trigger_depends trigger_discovery triggers \
142
user_history users users_groups usrgrp valuemaps )
143
# tables with large data
144
DATATABLES=( acknowledges alerts auditlog auditlog_details events \
145
history history_log history_str history_str_sync history_sync history_text \
146
history_uint history_uint_sync trends trends_uint )
147
# CONFTABLES
148
for table in ${CONFTABLES[*]}; do
149
        DUMPFILE="${DUMPDIR}/${table}.sql"
150
        echo "Backuping table ${table}"
151
        ${MYSQLDUMP} -R --opt --extended-insert=FALSE \
152
                -h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} --tables ${table} >${DUMPFILE}
153
        ${GZIP} -f ${DUMPFILE}
154
done
155
# DATATABLES
156
for table in ${DATATABLES[*]}; do
157
        DUMPFILE="${DUMPDIR}/${table}.sql"
158
        echo "Backuping schema table ${table}"
159
        ${MYSQLDUMP} -R --opt --no-data        \
160
                -h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} --tables ${table} >${DUMPFILE}
161
        ${GZIP} -f ${DUMPFILE}
162
done
163
echo
164
echo "Backup Completed - ${DUMPDIR}"
165
</pre>