(整理)Zabbix一键到位脚本

很久以前部署好的zabbix监控服务器,可是用的甚少,今天偶然帮助群里的小伙伴解决问题,于是又温习了一遍部署过程。细说起来,要注意的地方真挺多的。

在正式安装zabbbix之前,需要先装好依赖软件。

#---------------INSTALL NGINX 1.9.15-----------------------#
# install pcre
if [ $(rpm -qa|grep pcre.*.x86_64|wc -l) -lt 1 ]; then
yum -y install pcre*
fi
# install ssl support
if [ $(rpm -qa|grep openssl.*.x86_64|wc -l) -lt 1 ]; then
yum -y install openssl*
fi
# install nginx
cd ~
wget http://nginx.org/download/nginx-1.9.15.tar.gz
tar xf nginx-1.9.15.tar.gz
cd nginx-1.9.15
./configure --prefix=/usr/local/nginx-1.9.15 --with-http_ssl_module --with-http_stub_status_module --with-pcre
make && make install
#列出启动,重启命令
# start
#/usr/local/nginx-1.9.15/sbin/nginx
# stop
#/usr/local/nginx-1.9.15/sbin/nginx -s stop
# change config
#/usr/local/nginx-1.9.15/sbin/nginx -s reload
#-------------------------------------------------------#

PHP的安装需要开启的支持太多,基本上记不全。好记性不如烂笔头,后面的配置文件必须要修改,否则zabbix安装过程中检测不通过。我安装的版本有2项默认就是对应的值,所以无需更改。

#---------------INSTALL PHP 5.6.5-----------------------#
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2 libxml2-devel bzip2-devel libcurl-devel -y
cd ~
wget http://cn2.php.net/distributions/php-5.6.5.tar.gz
tar xf php-5.6.5.tar.gz
cd php-5.6.5
./configure --prefix=/usr/local/php-5.6.5 --with-config-file-path=/usr/local/php-5.6.5/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
make && make install
#edit configure file
cp php.ini-production /usr/local/php-5.6.5/etc/php.ini
cp /usr/local/php-5.6.5/etc/php-fpm.conf.default /usr/local/php-5.6.5/etc/php-fpm.conf
sed -i ‘s/max_execution_time = 30/max_execution_time = 300/‘ /usr/local/php-5.6.5/etc/php.ini
#sed -i ‘s/memory_limit = 128M/memory_limit = 128M/‘ /usr/local/php-5.6.5/etc/php.ini
#sed -i ‘s/upload_max_filesize = 2M/upload_max_filesize = 2M/‘ /usr/local/php-5.6.5/etc/php.ini
sed -i ‘s/post_max_size = 8M/post_max_size = 16M/‘ /usr/local/php-5.6.5/etc/php.ini
sed -i ‘s/max_input_time = 60/max_input_time = 300/‘ /usr/local/php-5.6.5/etc/php.ini
sed -i ‘s/;date.timezone =/date.timezone = PRC/‘ /usr/local/php-5.6.5/etc/php.ini
#start php-fpm
/usr/local/php-5.6.5/sbin/php-fpm
#-----------------------------------------------#

正式安装zabbix

#---------------INSTALL ZABBIX 2.2.2------------------#
cd ~
wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.2/zabbix-2.2.2.tar.gz
tar zabbix-2.2.2.tar.gz
cd zabbix-2.2.2
 ./configure --prefix=/usr/local/zabbix-2.2/ --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxl2
make && make install
#-----------------------------------------------#
#zabbix默认不会使用root用户运行
#create user zabbix
groupadd zabbix
useradd -g zabbix zabbix
#create default database zabbix
USER=root
PASSWORD=123456
mysql -u$USER -p$PASSWORD -e "create database zabbix default charset utf8;"
#if proxy, just schema.sql
mysql -u$USER -p$PASSWORD zabbix < database/mysql/schema.sql
mysql -u$USER -p$PASSWORD zabbix < database/mysql/images.sql
mysql -u$USER -p$PASSWORD zabbix < database/mysql/data.sql
#config zabbix && startup
cd /usr/bin/
ln -s /usr/local/zabbix-2.2/sbin/zabbix_server zabbix_server
cp /usr/local/zabbix-2.2/etc/zabbix_server.conf /etc/zabbix_server.conf
# change zabbix_server.conf about DB_config_informations
sed -i ‘s/# DBHost=localhost/DBHost=127.0.0.1/‘ /etc/zabbix_server.conf
sed -i ‘s/# DBPassword=/DBPassword=‘"$PASSWORD"‘/‘ /etc/zabbix_server.conf
#sed -i ‘s/# DBSocket=/tmp/mysql.sock/DBSocket=/tmp/mysql.sock/‘ /etc/zabbix_server.conf
#start
su zabbix
zabbix_server -c /etc/zabbix_server.conf
#stop
#zabbix_server -c /etc/zabbix_server.conf stop

至此,安装启动完成,在浏览器打开http://localhost/zabbix即可进行配置,根据提示配置完成后就成功了。

系统环境:CentOS 6.7 (final)

基本上这个脚本,直接拷贝过去,修改数据库密码和(启用|去掉)几个注释部分就可以使用了。脚本已上传至下载中心,欢迎下载。有错误的地方还望不吝指正!

时间: 2024-08-03 02:13:54

(整理)Zabbix一键到位脚本的相关文章

lnmp+zabbix一键部署脚本

一.基础环境准备脚本比较执行过程中比较依赖yum,所以前提保证服务器yum环境正常,否则一些依赖包将不能正常安装,导致后续编译失败等问题,该脚本经过个人轮番测试基本上可以一键搞定zabbix的部署工作,目前只是整个Server端的脚本,后续将编写Agent端自动推送的脚本二.脚本用法介绍 脚本使用-h参数可以看到该脚本支持传递以下3个参数,该参数都不是必须参数,如果不传递将采用脚本默认参数进行安装 直接执行脚本将进入人工确认模式进行安装(静默模式需要加"-s"参数),显示如下: 人工模

zabbix一键安装脚本

脚本作者:火星小刘 web:www.huoxingxiaoliu.com email:[email protected] 要求纯净centos6/7系统 关闭防火墙 关闭selinux php>=5.6 运行"server-install.sh"安装zabbix服务器端 由于zabbix3需要php5.6以上,因此脚本会删除原有php环境从新安装 mysql默认root密码123321zabbix数据库名称zabbixzabbix数据库用户名zabbixzabbix数据库密码za

LNMP+Zabbix一键安装脚本

环境:CentOS 6.5(最小化安装) 执行截图: #!/bin/bash #date:2015-6-14 #author:yfshare #mail:[email protected] echo '' echo -e "\t###########################################################" echo -e "\t###\t\t\t\t\t\t\t###" echo -e "\t###\twelcom

LNMP+zabbix一键安装部署

安装脚本 说明:此脚本只适用与RHEL6.x系列:Nginx版本为1.6最新稳定版:PHP为5.4最新版:Mysql为5.5最新稳定版:Zabbix暂时为2.4最新版. #!/bin/bash # install Nginx 1.6.2 + mysql5.5.x + PHP-FPM 5.4.x + Zabbix 2.4.4 automatically. # Tested on CentOS 6.5 ############################################## # 

linux服务器一键优化脚本

服务器一键优化脚本,高亮显示 内容:关闭selinux.时间同步设置.zabbix-agent安装.句柄数调优.常用软件安装.永久静态路由添加 #/bin/bash echo "####start shutdown selinux########" sed -i 's/SELINK=enforcing/SELINK=disabled/' /etc/selinux/config setenforce 0 value_selinux=`getenforce` if [ value_seli

Lnmp一键部署脚本(包含模块安装,php7,openresty+缓存等)

Lnmp一键部署脚本 个人gitpage:https://owelinux.github.io/ #!/bin/bash ##DATE:2016-7-25 ##USER:owelinux ###install wallet #######install mysql################################################## yum -y install cmake ncurses-devel bison libaio make gcc gcc-c++ mk

linux tomcat一键维护脚本(值得收藏)

<span style="font-family: Arial, Helvetica, sans-serif;">#! /bin/sh</span> a="/usr/share/tomcat7/webapps/ROOT" b="/usr/share/tomcat7/webapps/ROOT.war" c="ROOT.war" tomcat_stop="/usr/share/tomcat7/bi

Ubuntu Or Debian L2TP VPN 一键安装脚本

#!/bin/bash if [ $(id -u) != "0" ]; then printf "Error: You must be root to run this tool!\n" exit 1 fi clear printf " #################################################### # # # This is a Shell-Based tool of l2tp installation # #

Centos7搭建pptp VPN一键安装脚本

Centos7搭建pptp一键安装脚本 废话不多说,先上脚本地址:Centos7一键pptp 使用: wget https://raw.githubusercontent.com/DanylZhang/VPS/master/CentOS7-pptp-host1plus.sh chmod +x ./CentOS7-pptp-host1plus.sh ./CentOS7-pptp-host1plus.sh -u your_username -p your_password 1 2 3 可在-u.-p