One-click installation of zabbix, provided that mysql has been installed with a password, has been tested on centos 6.5, zabbixcentos

Source: Internet
Author: User

One-click installation of zabbix, provided that mysql has been installed with a password, has been tested on centos 6.5, zabbixcentos

#!/bin/bash
 
# Zabbix one-click installation # Database User Name DBUSER = 'root' # Database User Password DBPASS = 'root' # local address DBHOST = 'localhost' # zabbix downloaded version ZBX_VER = '2. 4.3 '### check the returned value function checkReturn {if [$1-ne 0]; then echo "fail: $2" echo "$3" exit else echo "pass: $2 "fi sleep 3 }### prerequisites ### only versions can be installed on centos or redhat 6.0 ### install mysql cat first <"eof" = run at your own risk = do not run on existing installations, YOU * WILL * LOSE DATAThis script: * installza Bbix 2.2.x on CentOS/Red Hat 6 * Drops an existing database * Does not install MySQL; to install type "yum install mysql-server" * Assums a vanilla OS install, though it tries to work around it * Does not install zabbix packages, it uses source from zabbix.com * Disables firewall * Disables SELinuxeof #### read-p 'Type "go" to continue: 'respif ["$ RESP "! = "Go"]; then echo "Sorry to hear it" exitelse echo "Lets do this... "fi # check selinux ### check whether the firewall is disabled if [" 'sestatus | grep status | awk' {print $3} ''" = "enabled"]; then # checkReturn 1 "Disable SELinux and then retry" setenforce 0 sed "s/SELINUX = enforcing/SELINUX = disabled/g"/etc/selinux/config>/tmp/mytmp093; mv/tmp/mytmp093/etc/selinux/configfi # disable firewall chkconfig iptables off/etc /Init. d/iptables stop ### check whether mysql is disabled if ["'rpm-qa | grep mysql-Server'"]; then chkconfig mysqld on service mysqld restartfi # check mysqlmysql-h $ {DBHOST}-u $ {DBUSER} -- password =$ {DBPASS}>/dev/null <eofstatuseofRETVAL =$? CheckReturn $ RETVAL "basic mysql access" "Install mysql server packages or fix mysql permissions" if [! "'Rpm-qa | grep fping'"]; then if ["'uname-m'" = "x86_64"]; then rpm-Uhv http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm elif ["'uname-m'" = "i686"]; then rpm-Uhv http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm unzip iyum-y install gcc mysql-devel curl-devel httpd php-mysql php-bcmath php-gd php-xml php-mbstring Net-snmp-devel fping e2fsprogs-devel zlib-devel libgssapi-devel krb5-devel openssl-devel wget libssh2-devel openldap-devel libxml2-devel make patchRETVAL =$? CheckReturn $ RETVAL "Package install" chmod 4755/usr/sbin/fpingcd/tmprm-rf/etc/zabbixrm-rf zabbix-$ ZBX_VERrm zabbix-w.zbx_ver.tar.gz wget variable? CheckReturn $ RETVAL "downloading source" "check ZBX_VER variable or mirror might be down" tar xzf zabbix-w.zbx_ver.tar.gz cd zabbix-$ ZBX_VER. /configure -- enable-agent -- enable-ipv6 -- enable-proxy -- enable-server -- with-mysql -- with-libcurl -- with-net-snmp -- with-ssh2 -- with-ldap -- with-libxml2 -- sysconfdir =/etc/zabbixRETVAL =$? CheckReturn $ RETVAL "Configure" makeRETVAL = $? CheckReturn $ RETVAL "Compile" make installRETVAL =$? CheckReturn $ RETVAL "make install" echo "drop database if exists zabbix; "| mysql-h $ {DBHOST}-u $ {DBUSER} -- password =$ {DBPASS} (echo" create database zabbix; "echo" USE zabbix; "cat/tmp/zabbix-$ ZBX_VER/database/mysql/schema. sqlcat/tmp/zabbix-$ ZBX_VER/database/mysql/images. sqlcat/tmp/zabbix-$ ZBX_VER/database/mysql/data. SQL) | mysql-h $ {DBHOST}-u $ {DBUSER} -- password =$ {DBPASS} adduser-r-d/var/run/za Bbix-server-s/sbin/nologin zabbixmkdir-p/var/log/zabbix-servermkdir-p/var/log/zabbix-agentmkdir-p/var/run/zabbix-servermkdir -p/var/run/zabbix-agentchown zabbix. zabbix/var/run/zabbix * chown zabbix. zabbix/var/log/zabbix * cp/tmp/zabbix-$ ZBX_VER/misc/init. d/fedora/core5/zabbix_server/etc/init. dcp/tmp/zabbix-$ ZBX_VER/misc/init. d/fedora/core5/zabbix_agentd/etc/init. dcd/etc/zabbixpatch-p0 -L <"eof" --- orig/zabbix_server.conf 2012-07-01 18:30:00. 585612301-0700 ++ zabbix_server.conf 18:58:15. 181605999-0700-36,7 + 36,7 # Default: # LogFile =-LogFile =/tmp/zabbix_server.log + LogFile =/var/log/zabbix-server/zabbix_server.log ### Option: LogFileSize # Maximum size of log file in MB. @-65,7 + 65,7 ## Mandatory: no # Default:-# PidFile =/tmp/zabbix_server.pid + PidFile =/v Ar/run/zabbix-server/zabbix_server.pid ### Option: DBHost # Database host name. @-100,7 + 100,7 # Default: # DBUser =-DBUser = root + DBUser = _ dbuser _ ### Option: DBPassword # Database password. ignored for SQLite. @-example, 6 + example, 7 # Mandatory: no # Default: # DBPassword = + DBPassword = _ dbpass _ ### Option: DBSocket # Path to MySQL socket. eofsed "s/_ dbuser _/$ {DBUSER}/g"/etc/zabbix/zabbix_server.conf> /Tmp/mytmp393; mv/tmp/mytmp393/etc/zabbix/zabbix_server.confsed "s/_ dbpass _/$ {DBPASS}/g"/etc/zabbix/zabbix_server.conf>/tmp/mytmp393; mv/tmp/mytmp393/etc/zabbix/zabbix_server.confpatch-p0-l <"eof" --- orig/zabbix_agentd.conf 18:30:00. 585612301-0700 ++ zabbix_agentd.conf 18:55:40. 566660188-0700-9,6 + 9,7 # Mandatory: no # Default: # PidFile =/tmp/zabbix_agentd. Pid + PidFile =/var/run/zabbix-agent/zabbix_agentd.pid ### Option: LogFile # Name of log file. @-18,7 + 19,7 # Default: # LogFile =-LogFile =/tmp/zabbix_agentd.log + LogFile =/var/log/zabbix-agent/zabbix_agentd.log ### Option: logFileSize # Maximum size of log file in MB. @-57,6 + 58,7 # Mandatory: no # Default: # EnableRemoteCommands = 0 + EnableRemoteCommands = 1 ### Option: LogRemoteCommands # Enable Logging of executed shell commands as warnings. eofchkconfig zabbix_server onchkconfig zabbix_agentd onchmod + x/etc/init. d/zabbix_serverchmod + x/etc/init. d/mongozabbix_server restartservice zabbix_agentd restart #### end zabbix server & agent process install & START #### BEGIN WEBrm-rf/usr/local/share/zabbixmkdir-p/usr /local/share/zabbixcp-r/tmp/zabbix-$ ZBX_VER/frontends/php /* /Usr/local/share/zabbixecho "Alias/zabbix/usr/local/share/zabbix">/etc/httpd/conf. d/zabbix. confecho "post_max_size = 16 M">/etc/php. d/local_zabbix.iniecho "max_execution_time = 300">/etc/php. d/local_zabbix.iniecho "max_input_time = 300">/etc/php. d/local_zabbix.ini. /etc/sysconfig/clockecho "date. timezone = $ ZONE ">/etc/php. d/local_zabbix.inichkconfig httpd onservice httpd restart # sed "S/max_execution_time = 30/max_execution_time = 300/g"/etc/php. ini>/tmp/mytmp393; mv/tmp/mytmp393/etc/php. ini # touch/usr/local/share/zabbix/conf/zabbix. conf. php # chmod 666/usr/local/share/zabbix/conf/zabbix. conf. phpcat>/usr/local/share/zabbix/conf/zabbix. conf. php <"eof" <? Php // Zabbix GUI configuration fileglobal $ DB; $ DB ['type'] = "MYSQL"; $ DB ['server'] = "_ dbhost _"; $ DB ['Port'] = "0"; $ DB ['database'] = "zabbix"; $ DB ['user'] = "_ dbuser _"; $ DB ['Password'] = "_ dbpass _"; // SCHEMA is relevant only for IBM_DB2 database $ DB ['scheme'] = ''; $ ZBX_SERVER = "127.0.0.1"; $ ZBX_SERVER_PORT = "10051"; $ ZBX_SERVER_NAME = ''; $ IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;?> Eofsed "s/_ dbhost _/$ {DBHOST}/g"/usr/local/share/zabbix/conf/zabbix. conf. php>/tmp/mytmp393; mv/tmp/mytmp393/usr/local/share/zabbix/conf/zabbix. conf. phpsed "s/_ dbuser _/$ {DBUSER}/g"/usr/local/share/zabbix/conf/zabbix. conf. php>/tmp/mytmp393; mv/tmp/mytmp393/usr/local/share/zabbix/conf/zabbix. conf. phpsed "s/_ dbpass _/$ {DBPASS}/g"/usr/local/share/zabbix/conf/zabbix. conf. php>/tmp/mytmp393; mv/tmp/mytmp393/usr/local/share/zabbix/conf/zabbix. conf. phpcd echo "Load http: // localhost/zabbix/" echo "username: admin" echo "password: zabbix"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.