Last active
May 4, 2017 13:52
-
-
Save olmosleo/926ce575ab66637f330a312b297c5073 to your computer and use it in GitHub Desktop.
Zabbix Server Deploy Script for CentOS 6 and 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Zabbix Deploy on CentOS. | |
sudo yum update -y | |
# package essential tools for sysadmin | |
sudo yum install -y vim nano telnet screen nmap openssh-clients wget rsync git net-tools unzip traceroute | |
# Install EPEL Repositorio | |
sudo yum install epel-release | |
# Configure the ZabbixZone package repository and GPG key using command: | |
sudo rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX | |
#sudo rpm -Uv http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm | |
# CentOS 7.X | |
sudo rpm -Uv http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm | |
# CentOS 6.X | |
sudo rpm -Uv http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm | |
# (version con problemas) sudo rpm -Uv http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm | |
# ahora instalamos el servicio de zabbix a través de los repositorios cargados | |
sudo yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway | |
# cambiar la zona horaria en el archivo de configuracion | |
# vim /etc/httpd/conf.d/zabbix.conf | |
ZABBIX_CONF = "/etc/httpd/conf.d/zabbix.conf", | |
# | |
# Zabbix monitoring system php web frontend | |
# | |
echo "Alias /zabbix /usr/share/zabbix" > $ZABBIX_CONF; | |
echo "<Directory '/usr/share/zabbix'>" >> $ZABBIX_CONF; | |
echo " Options FollowSymLinks " >> $ZABBIX_CONF; | |
echo " AllowOverride None" >> $ZABBIX_CONF; | |
echo " Require all granted " >> $ZABBIX_CONF; | |
echo " <IfModule mod_php5.c> " >> $ZABBIX_CONF; | |
echo " php_value max_execution_time 300 " >> $ZABBIX_CONF; | |
echo " php_value memory_limit 128M " >> $ZABBIX_CONF; | |
echo " php_value post_max_size 16M " >> $ZABBIX_CONF; | |
echo " php_value upload_max_filesize 2M " >> $ZABBIX_CONF; | |
echo " php_value max_input_time 300 " >> $ZABBIX_CONF; | |
echo " php_value date.timezone America/Santiago " >> $ZABBIX_CONF; | |
echo " </IfModule> " >> $ZABBIX_CONF; | |
echo " </Directory> " >> $ZABBIX_CONF; | |
echo " <Directory '/usr/share/zabbix/conf'> " >> $ZABBIX_CONF; | |
echo " Require all denied " >> $ZABBIX_CONF; | |
echo " </Directory> " >> $ZABBIX_CONF; | |
echo " <Directory '/usr/share/zabbix/include'> " >> $ZABBIX_CONF; | |
echo " Require all denied " >> $ZABBIX_CONF; | |
echo " </Directory> " >> $ZABBIX_CONF; | |
# restart the server | |
sudo systemctl start httpd | |
sudo systemctl enable httpd | |
# Se incorporan las politicas de seguridad para aceptar petificiones al servicio HTTP | |
sudo firewall-cmd --permanent --add-service=http | |
sudo systemctl restart firewalld | |
# Install MariaDB | |
sudo yum install mariadb-server mariadb -y | |
# Start the services MARIADB | |
sudo systemctl start mariadb | |
sudo systemctl enable mariadb | |
# Script to setting root account and another stuff of security. | |
sudo mysql_secure_installation | |
# Creamos la base de datos "zabbixdb" and the user "zabbixuser". | |
mysql -u root -p | |
# create database zabbixdb character set utf8; | |
# grant all privileges on zabbixdb.* to 'zabbixuser'@'localhost' identified by 'abcd.1234'; | |
# flush privileges; | |
# exit | |
# Cargamos los squemas de las tablas de datos para MYSQL | |
mysql -u zabbixuser -p zabbixdb < /usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql | |
mysql -u zabbixuser -p zabbixdb < /usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql | |
mysql -u zabbixuser -p zabbixdb < /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql | |
# vi /etc/zabbix/zabbix_server.conf | |
#[...] Especificar el nombre de la base de datos | |
#DBName=zabbixdb | |
#[...] Especificar el nombre de usuario con privilegios en la base de datos | |
#DBUser=zabbixuser | |
#[...] Pass del user. | |
#DBPassword=password | |
#[...] | |
# Install PHP | |
yum install php php-mysql php-gd php-pear -y | |
sudo systemctl restart httpd | |
# Ajustar las politicas se seguridad para aceptar el tráfico a Zabbix Server | |
firewall-cmd --permanent --add-port=10050/tcp | |
firewall-cmd --permanent --add-port=10051/tcp | |
sudo systemctl restart firewalld | |
# Editar el archivo de configuracion del Zabbix Agent para que permita monitorear el servidor mismo. | |
# vi /etc/zabbix/zabbix_agentd.conf | |
#[...] | |
## Line 85 - Specify Zabbix server ## | |
#Server=127.0.0.1 | |
#[...] | |
## Line 126 - Specify Zabbix server ## | |
#ServerActive=127.0.0.1 | |
#[...] | |
## Line 137 - Specify Zabbix server Hostname or IP address ## | |
#Hostname=server1.unixmen.local | |
#[...] | |
# Editar el PHP.INI y realizar los ajustes pertinentes | |
#vi /etc/php.ini | |
#max_execution_time = 600 | |
#max_input_time = 600 | |
#memory_limit = 256M | |
#post_max_size = 32M | |
#upload_max_filesize = 16M | |
#date.timezone = America/Santiago | |
sudo systemctl start zabbix-server | |
sudo systemctl start zabbix-agent | |
sudo systemctl restart httpd | |
sudo systemctl restart mariadb | |
sudo systemctl enable zabbix-server | |
sudo systemctl enable zabbix-agent | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script let you install zabbix on CentOS 7.