Setup zabbix-server22 » Historie » Version 2
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 | 2 | Jeremias Keihsler | |
| 82 | 1 | Jeremias Keihsler | h3. SELinux |
| 83 | |||
| 84 | 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 |
||
| 85 | <pre><code class="bash"> |
||
| 86 | setsebool -P httpd_can_network_connect 1 |
||
| 87 | </code></pre> |
||
| 88 | |||
| 89 | h2. Backup Zabbix config |
||
| 90 | |||
| 91 | is taken from http://zabbixzone.com/zabbix/backuping-only-the-zabbix-configuration/ |
||
| 92 | |||
| 93 | see also https://github.com/xsbr/zabbixzone |
||
| 94 | |||
| 95 | This script is a simple way to backup all configuration tables (eg. templates, hostgroups, hosts, triggers…) without the history data. |
||
| 96 | |||
| 97 | As the result is very small (around 30 MB), is possible run this backup many times per day. |
||
| 98 | |||
| 99 | 2 | Jeremias Keihsler | <pre> |
| 100 | 1 | Jeremias Keihsler | #!/bin/bash |
| 101 | # |
||
| 102 | # zabbix-mysql-backupconf.sh |
||
| 103 | # v0.2 - 20111105 |
||
| 104 | # v0.21 - 20120912 modified to work with CentOS 6.x (JKE) |
||
| 105 | # v0.22 - 20130411 modified to work with Zabbix 2.0 (JKE) |
||
| 106 | # |
||
| 107 | # Configuration Backup for Zabbix 2.0 w/MySQL |
||
| 108 | # |
||
| 109 | # Author: Ricardo Santos (rsantos at gmail.com) |
||
| 110 | # http://zabbixzone.com |
||
| 111 | # |
||
| 112 | # Thanks for suggestions from: |
||
| 113 | # - Oleksiy Zagorskyi (zalex) |
||
| 114 | # - Petr Jendrejovsky |
||
| 115 | # |
||
| 116 | # mysql config |
||
| 117 | DBHOST="localhost" |
||
| 118 | DBNAME="zabbix" |
||
| 119 | DBUSER="zabbix" |
||
| 120 | DBPASS="YOURMYSQLPASSWORDHERE" |
||
| 121 | # some tools |
||
| 122 | MYSQLDUMP="/usr/bin/mysqldump" |
||
| 123 | GZIP="/bin/gzip" |
||
| 124 | DATEBIN="/bin/date" |
||
| 125 | MKDIRBIN="/bin/mkdir" |
||
| 126 | # target path |
||
| 127 | MAINDIR="/var/cache/myzabbixdump" |
||
| 128 | DUMPDIR="${MAINDIR}/`${DATEBIN} +%Y%m%d%H%M`" |
||
| 129 | ${MKDIRBIN} -p ${DUMPDIR} |
||
| 130 | # configuration tables |
||
| 131 | CONFTABLES=( actions applications autoreg_host conditions config dchecks dhosts \ |
||
| 132 | drules dservices escalations expressions functions globalmacro globalvars graph_discovery graph_theme \ |
||
| 133 | graphs graphs_items groups help_items host_inventory hostmacro hosts hosts_groups \ |
||
| 134 | hosts_templates housekeeper httpstep \ |
||
| 135 | httpstepitem httptest httptestitem icon_map icon_mapping ids images interface item_discovery items items_applications \ |
||
| 136 | maintenances maintenances_groups maintenances_hosts maintenances_windows \ |
||
| 137 | mappings media media_type node_cksum nodes opcommand opcommand_grp opcommand_hst opconditions operations \ |
||
| 138 | opgroup opmessage opmessage_grp opmessage_usr optemplate \ |
||
| 139 | profiles proxy_autoreg_host proxy_dhistory proxy_history regexps \ |
||
| 140 | rights screens screens_items scripts service_alarms services services_links \ |
||
| 141 | services_times sessions slides slideshows sysmap_element_url sysmap_url sysmaps sysmaps_elements \ |
||
| 142 | sysmaps_link_triggers sysmaps_links timeperiods trigger_depends trigger_discovery triggers \ |
||
| 143 | user_history users users_groups usrgrp valuemaps ) |
||
| 144 | # tables with large data |
||
| 145 | DATATABLES=( acknowledges alerts auditlog auditlog_details events \ |
||
| 146 | history history_log history_str history_str_sync history_sync history_text \ |
||
| 147 | history_uint history_uint_sync trends trends_uint ) |
||
| 148 | # CONFTABLES |
||
| 149 | for table in ${CONFTABLES[*]}; do |
||
| 150 | DUMPFILE="${DUMPDIR}/${table}.sql" |
||
| 151 | echo "Backuping table ${table}" |
||
| 152 | ${MYSQLDUMP} -R --opt --extended-insert=FALSE \ |
||
| 153 | -h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} --tables ${table} >${DUMPFILE} |
||
| 154 | ${GZIP} -f ${DUMPFILE} |
||
| 155 | done |
||
| 156 | # DATATABLES |
||
| 157 | for table in ${DATATABLES[*]}; do |
||
| 158 | DUMPFILE="${DUMPDIR}/${table}.sql" |
||
| 159 | echo "Backuping schema table ${table}" |
||
| 160 | ${MYSQLDUMP} -R --opt --no-data \ |
||
| 161 | -h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} --tables ${table} >${DUMPFILE} |
||
| 162 | ${GZIP} -f ${DUMPFILE} |
||
| 163 | done |
||
| 164 | echo |
||
| 165 | echo "Backup Completed - ${DUMPDIR}" |
||
| 166 | </pre> |