Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

One-click automatic installation of zabbix services

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Purpose

Install the zabbix service automatically with one click.

Environment

OS:CentOS 6.2

Zabbix version: 2.2.4

Configuration

#! / bin/bash# script name: one-click automatic installation of zabbix service # Note: # 1. This script is only successfully tested in the CentOS minimized installation environment and is not necessarily applicable to other environments. # 2. To change the passwords of root and zabbix users in the mysql database, please pay attention to the following two variables! Mysql_user_root_password= "redhat" mysql_user_zabbix_password= "zabbix" echo-n "is shutting down SELinux..." Setenforce 0 > / dev/null 2 > & 1sed-I'/ ^ SELINUX=/s/=.*/=disabled/' / etc/selinux/config & & echo "OK" echo-n "is configuring iptables firewall …" Iptables-Fiptables-Xiptables-An INPUT-m state-state RELATED,ESTABLISHED-j ACCEPTiptables-An INPUT-m state-state NEW-m tcp-p tcp-dport 22-j ACCEPTiptables-An INPUT-m state-state NEW-m tcp-p tcp-dport 80-j ACCEPTiptables-An INPUT-p icmp-j ACCEPTiptables-An INPUT-I lo-j ACCEPTiptables-P INPUT DROPiptables-P FORWARD DROPservice iptables save > / dev/null 2 > & 1 & echo "OK" echo-n is installing zabbix related software. " Yum-y install make gcc httpd mysql-server mysql-devel net-snmp-devel libcurl-devel php php-mysql php-bcmath php-mbstring php-gd php-xml wget > / dev/null 2 > & 1 & & echo "OK" echo-n "is adding zabbix users..." Useradd-M-s / sbin/nologin zabbix & & echo "OK" echo-n "is starting the mysqld service." Service mysqld start > / dev/null 2 > & 1 & & echo "OK" echo-n "is setting a password for root users of mysql." Mysqladmin-uroot password $mysql_user_root_password & & echo "OK" echo is executing the mysql statement. " Mysql-uroot-p$mysql_user_root_password-e "create database zabbix character set utf8" & & echo "has executed 1 mysql-uroot-p$mysql_user_root_password-e" grant all privileges on zabbix.* to zabbix@localhost identified by'$mysql_user_zabbix_password' "& & echo" has executed 2 "echo-n" downloading the zabbix source package. Wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.4/zabbix-2.2.4.tar.gz > / dev/null 2 > & 1 & & echo "OK" echo-n "is decompressing." Tar zxf zabbix-2.2.4.tar.gz > / dev/null 2 > & 1 & & echo "OK" echo-n "is being installed." Cd zabbix-2.2.4 & &. / configure-- prefix=/usr/local/zabbix-- enable-server-- enable-agent-- with-mysql-- with-net-snmp-- with-libcurl > / dev/null 2 > & 1 & & make install > / dev/null 2 > & 1 & & echo "OK" echo "is importing the database." Mysql-uzabbix-p$mysql_user_zabbix_password zabbix

< $PWD/database/mysql/schema.sql && echo "已完成1/3"mysql -uzabbix -p$mysql_user_zabbix_password zabbix < $PWD/database/mysql/images.sql && echo "已完成2/3"mysql -uzabbix -p$mysql_user_zabbix_password zabbix < $PWD/database/mysql/data.sql && echo "已完成3/3" echo -n "正在复制zabbix_server和zabbix_agentd服务到/etc/init.d/目录……"cp $PWD/misc/init.d/fedora/core/zabbix_* /etc/init.d/ && echo "OK" echo -n "正在复制php网页数据到/var/www/html/zabbix目录……"cp -R $PWD/frontends/php/ /var/www/html/zabbix && echo "OK" echo -n "正在修改/usr/local/zabbix/etc/zabbix_server.conf文件……"sed -i '/^DBUser=/s/=.*/=zabbix/;/DBPassword=/s/$/\n\nDBPassword=zabbix/' /usr/local/zabbix/etc/zabbix_server.conf && echo "OK" echo -n "正在修改/etc/init.d/zabbix_server和/etc/init.d/zabbix_agentd文件……"sed -i '/BASEDIR=/s/$/\/zabbix/' /etc/init.d/zabbix_* && echo "OK" echo -n "正在修改/etc/httpd/conf/httpd.conf文件……"sed -i '/^DirectoryIndex/s/$/ index.php/' /etc/httpd/conf/httpd.conf && echo "OK" echo -n "正在修改/etc/php.ini文件……"sed -i '/^post_max_size/s/= .*/= 16M/;/^max_execution_time/s/= .*/= 300/;/^max_input_time/s/= .*/= 300/;/^;date.timezone/{s/;//;s/$/ Asia\/Shanghai/}' /etc/php.ini && echo "OK" echo -n "正在修改/var/www/html/zabbix/conf/zabbix.conf.php文件……"cp /var/www/html/zabbix/conf/zabbix.conf.php.example /var/www/html/zabbix/conf/zabbix.conf.phpsed -i 's/zabbix_password/'$mysql_user_zabbix_password'/' /var/www/html/zabbix/conf/zabbix.conf.phpecho "OK" echo "正在添加服务到自动启动……"chkconfig --add mysqld && chkconfig mysqld on && echo "mysqld服务已添加到自动启动"chkconfig httpd on && echo "httpd服务已添加到自动启动"chkconfig --add zabbix_server && chkconfig zabbix_server on && echo "zabbix_server服务已添加到自动启动"chkconfig --add zabbix_agentd && chkconfig zabbix_agentd on && echo "zabbix_agentd服务已添加到自动启动" echo "正在启动服务……"service httpd start >

/ dev/null 2 > & 1 & & echo "httpd service started" service zabbix_server start > / dev/null 2 > & 1 & & echo "zabbix_server service started" service zabbix_agentd start > / dev/null 2 > & 1 & & echo "zabbix_agentd service started"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report