Instalador autônomo Zabbix 3.2.1 no CentOS 6

Publicado por fabio brigido (última atualização em 16/01/2017)

[ Hits: 5.629 ]

Download instalador_zabbix

Download 1480528417.instalador_zabbix (versão 2)




Esta é a minha primeira contribuição ao fórum, qualquer erro por favor me avisem. Este script surgiu da necessidade de auxiliar um colega  que está iniciando no mundo linux e precisava instalar o Zabbix em uma distro CentOS 6.

Está todo automatizado, inclusive as configurações da pagina web. Apenas por segurança altere as variáveis abaixo:

SENHA="123456";      # Essa é a senha que sera configurada no bando criado, nessa caso o zabbix
SENHAROOT="123456";  # Essa é a senha de root do mysql

  



Versões atualizadas deste script

Versão 2 - Enviado por fabio brigido em 30/11/2016

Changelog: Mudanças na estrutura do script sendo as principais:
- Mudança do banco mysql. Agora o script pede para inserir a senha na tela, não sendo mais necessária sua prévia inserção;
- Correção de bugs;

Download 1480528417.instalador_zabbix


Esconder código-fonte

#!/bin/bash

# SCRIPT DE PREPARAÇÃO E INSTALAÇÃO ZABBIX NO CENTOS 6
#
# VER. 1.0
# Copyright (c) 2016 Fabio Brigido
# Email: fbrigido14@gmail.com
#
#=====================================================================

echo '##############################################################################################################'
echo '##############################################################################################################'
echo '######################################## PREPARANDO SERVIDOR CENTOS #########################################'
echo '##############################################################################################################'
echo '##############################################################################################################'

# Variaveis de ambiente
PHPINI="/etc/php.ini"

SENHA="123456";
SENHAROOT="123456";
NOMEBANCO="zabbix";
USUARIODB="zabbix";

# Criando e acessando o diretorio temporario de instalacao
mkdir /home/instaladores
cd /home/instaladores

# Configurando o SELinux
sed -i "s/=enforcing/=disabled/g" /etc/selinux/config
# Desabilita o SELINUX neste boot
setenforce 0

#Desabilitando firewall
chkconfig iptables off
chkconfig ip6tables off
service iptables stop

# Habilitando DNS
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf

# Habilitando os repositórios
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm
rpm -Uvh http://repo.webtatic.com/yum/el6/latest.rpm

# Instalando biblioteca de gerenciamento
yum groupinstall 'Development Tools' -y
yum install vim wget -y

# Atualizando sistema operacional
yum update -y

# Instalando arquivos necessários
yum install wget vim net-snmp net-snmp-devel net-snmp-utils net-snmp-libs iksemel-devel zlib-devel libc-devel curl-devel automake libidn-devel openssl-devel rpm-devel OpenIPMI-devel libssh2-devel make fping -y
yum install httpd httpd-devel mod_ssl -y
yum install mysql mysql-server mysql-devel -y
yum install php56w php56w-opcache php56w-cli php56w-common php56w-devel php56w-gd php56w-imap php56w-mbstring php56w-mcrypt php56w-mysql php56w-phpdbg php56w-snmp php56w-bcmath php56w-xml php56w-ldap -y

# Iniciando os serviços
chkconfig mysqld on
chkconfig httpd on
service httpd start
service mysqld start

# Definindo a senha do root
/usr/bin/mysqladmin -u root password $SENHAROOT;

# Criando banco do zabbix
echo "create database $NOMEBANCO character set utf8;" | mysql -uroot -p$SENHAROOT
echo "GRANT ALL PRIVILEGES ON $NOMEBANCO.* TO $USUARIODB@localhost IDENTIFIED BY '$SENHA' WITH GRANT OPTION;" | mysql -uroot -p$SENHAROOT

# Configurando apache
echo "serverName localhost:80" >> /etc/httpd/conf/httpd.conf


# Configurando o php.ini
sed -i "s/date.timezone/;date.timezone/" $PHPINI;
sed -i "s/max_execution_time/;max_execution_time/" $PHPINI;
sed -i "s/max_input_time/;max_input_time/" $PHPINI;
sed -i "s/post_max_size/;post_max_size/" $PHPINI;

echo "date.timezone = Europe/Riga" >> $PHPINI;
echo "max_execution_time = 300" >> $PHPINI;
echo "max_input_time = 300" >> $PHPINI;
echo "post_max_size = 16M" >> $PHPINI;
echo "always_populate_raw_post_data=-1" >> $PHPINI

# Instalação zabbix

echo '############################################################################'
echo '############################################################################'
echo '###################### Instalando Zabbix 3.2 ###############################'
echo '############################################################################'
echo '############################################################################'

# Criando usuário e grupo
groupadd zabbix
useradd -g zabbix zabbix

cd /home/instaladores
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.2.1/zabbix-3.2.1.tar.gz
tar xvf zabbix-3.2.1.tar.gz

cd /home/instaladores/zabbix-3.2.1
cat database/mysql/schema.sql | mysql -u $USUARIODB -p$SENHA $NOMEBANCO && cat database/mysql/images.sql | mysql -u $USUARIODB -p$SENHA $NOMEBANCO && cat database/mysql/data.sql | mysql -u $USUARIODB -p$SENHA $NOMEBANCO;

cd /home/instaladores/zabbix-3.2.1
./configure --enable-server --enable-agent --with-mysql --with-openssl

make install

# Instalando frontend

echo '############################################################################'
echo '############################################################################'
echo '######################## Instalação Zabbix 3.2.1 ###########################'
echo '######################## INSTALAÇÃO DO FRONTEND ############################'
echo '############################################################################'
echo '############################################################################'

mkdir /var/www/html/zabbix
cd /home/instaladores/zabbix-3.2.1/frontends/php/
cp -a . /var/www/html/zabbix/
chown apache:apache -R /var/www/html/zabbix
chcon -Rv --type=httpd_sys_content_t /var/www/html
setsebool -P httpd_can_network_connect=1
setsebool -P zabbix_can_network=1
chmod +x /var/www/html/zabbix/conf/

# Criando o arquivo de configuracao do frontend
echo -e "<?php
// COnfigurador Zabbix GUI. - Criado por Fabio Brigido
global \$DB;

\$DB['TYPE']            = 'MYSQL';
\$DB['SERVER']         = 'localhost';
\$DB['PORT']            = '0';
\$DB['DATABASE']         = '$NOMEBANCO';
\$DB['USER']            = '$USUARIODB';
\$DB['PASSWORD']         = '$SENHA';
// Schema name. Used for IBM DB2 and PostgreSQL.
\$DB['SCHEMA']         = '';

\$ZBX_SERVER            = 'localhost';
\$ZBX_SERVER_PORT      = '10051';
\$ZBX_SERVER_NAME      = 'Zabbix';

\$IMAGE_FORMAT_DEFAULT   = IMAGE_FORMAT_PNG;
?>
" > /var/www/html/zabbix/conf/zabbix.conf.php

echo '############################################################################'
echo '############################################################################'
echo '##################### Instalação Zabbix 3.2.1 ##############################'
echo '################# Instalação serviços agent & server #######################'
echo '############################################################################'
echo '############################################################################'

cp /home/instaladores/zabbix-3.2.1/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
cp /home/instaladores/zabbix-3.2.1/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_agentd

chkconfig --add /etc/init.d/zabbix_server
chkconfig --add /etc/init.d/zabbix_agentd
chkconfig zabbix_server on
chkconfig zabbix_agentd on
service zabbix_server start
service zabbix_agentd start
 
service httpd restart

rm -rf /home/instaladores

echo '############################################################################'
echo '############################################################################'
echo '################# Instalação Zabbix 3.2.1 concluida ########################'
echo '################ Acesse http://ip_do_servidor/zabbix #######################'
echo '################## Usuário: Admin / senha: zabbix ##########################'
echo '############################################################################'
echo '############################################################################'

Scripts recomendados

Script de backup interativo

xmms+bitchx

Criação de Usuarios , Grupo e instalação do servidor de arquivos samba

Compara igualdade entre arquivos

Cálculo de raiz quadrada


  

Comentários
[1] Comentário enviado por janduy em 26/09/2017 - 15:08h

Opa Fabio, boa tarde. Tudo bem?
Parabéns pelo script, no meu linux deu um erro ao final da instalação, segue abaixo o erro.

ERRO:
cp: cannot stat `/home/instaladores/zabbix-3.2.1/misc/init.d/fedora/core/zabbix_server': No such file or directory
cp: cannot stat `/home/instaladores/zabbix-3.2.1/misc/init.d/fedora/core/zabbix_server': No such file or directory
error reading information on service zabbix_agentd: No such file or directory
error reading information on service zabbix_agentd: No such file or directory
Starting zabbix_server: Usage: /usr/local/sbin/zabbix_server {start|stop|status|restart|help}

start - start zabbix_server
stop - stop zabbix_server
status - show current status of zabbix_server
restart - restart zabbix_server if running by sending a SIGHUP or start if not running
help - this screen

[FAILED]

Consegue me dar um help?

Obrigado.


Atenciosamente,
Janduy Euclides

[2] Comentário enviado por fabiobrigido em 11/10/2017 - 10:02h

A versão 2 já corrige esse problema amigo, tente baixar a segunda versão que vai dar certo!


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts