Zabbix自动安装篇
shell脚本自动安装,方便大家快速上手zabbix。
autoinstall_Zabbix.sh
#!/bin/sh
#############################defined variable#############################
package_path=`pwd`
wait_second=10
mysql_pwd="root"
nginx_conf="nginx.conf" #nginxy主配置文件
nginx_zabbix_conf="zabbix.conf" #zabbix的vhost配置文件
install_report="${package_path}/install_report.log"
###################install nginx php zabbix Package by yum######################
function yum_install_zabbix()
{
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 2>>${install_report}
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 2>>${install_report}
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm 2>>${install_report}
yum clean all 2>>${install_report}
yum makecache 2>>${install_report}
yum -y install wget gzip nginx php php-fpm php-cli php-common php-gd php-mbstring php-mcrypt php-mysql
php-pdo php-devel php-xmlrpc php-xml php-bcmath php-dba php-enchant mariadb-server zabbix-server
zabbix-get zabbix-agent zabbix-server-mysql zabbix-web-mysql 2>>${install_report}
}
###############check files exists########################################
function check_files(){
if [ -e ${install_report} ]
then
rm -fr ${install_report}
fi
}
##############config nginx#########################
function config_nginx(){
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
cp ${nginx_conf} /etc/nginx/nginx.conf
cp ${nginx_zabbix_conf} /etc/nginx/conf.d/zabbix.conf
}
################config mysql################################
function config_mysql(){
gzip -d /usr/share/doc/zabbix-server-mysql-3.4.8/create.sql.gz
systemctl start mariadb
mysqladmin -uroot password ${mysql_pwd}
mysql -uroot -p${mysql_pwd}<<EOF
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";
flush privileges;
EOF
mysql -uroot -p${mysql_pwd} zabbix</usr/share/doc/zabbix-server-mysql-3.4.8/create.sql
}
######################config php#################################
function config_php(){
sed -i 's/post_max_size = 8M/post_max_size = 16M/g' /etc/php.ini
sed -i 's/;default_charset = "UTF-8"/default_charset = "UTF-8"/g' /etc/php.ini
sed -i 's/expose_php = On/expose_php = off/g' /etc/php.ini
sed -i 's/max_execution_time = 30$/max_execution_time = 300/g' /etc/php.ini
sed -i 's/max_input_time = 60/max_input_time = 300/g' /etc/php.ini
sed -i 's/memory_limit = 128M/memory_limit = 256M/g' /etc/php.ini
sed -i 's/^;date.timezone =/date.timezone = Asia\/Shanghai/g' /etc/php.ini
}
######################config zabbix############################
function config_zabbix(){
sed -i 's/# DBPassword=/DBPassword=zabbix/g' /etc/zabbix/zabbix_server.conf
sed -i 's/# DBSocket=\/tmp\/mysql.sock/DBSocket=\/var\/lib\/mysql\/mysql.sock/g' /etc/zabbix/zabbix_server.conf
}
######################start service####################################
function start_service(){
systemctl start nginx.service
systemctl start php-fpm
systemctl start zabbix-server
systemctl start zabbix-agent
systemctl stop firewalld
}
#########################config service##################################
function config_service(){
config_nginx
config_mysql
config_php
config_zabbix
}
#########################Health Check##################################
check_health(){
success_info=$1
error_num=`egrep '(error|Failed)' ${install_report} |wc -l`
if [ $error_num == "0" ]
then
tput bold
echo "----------------------------------------------------------------------------------------"
echo ${success_info}
echo "----------------------------------------------------------------------------------------"
tput sgr0
else
tput bold
echo "----------------------------------------------------------------------------------------"
echo "Notice:Abnormal exit,Please Check ${install_report}!"
echo "----------------------------------------------------------------------------------------"
tput sgr0
sleep ${wait_second}
exit 2
fi
}
##########################main######################################
check_files
yum_install_zabbix
check_health "Zabbix Install Success"
config_service
start_service
check_health "Service start Success!"
nginx.conf配置文件
user zabbix;
worker_processes 8;
pid /var/run/nginx.pid;
worker_rlimit_nofile 65535;
events {
worker_connections 65535;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
open_file_cache max=65535 inactive=60s;
open_file_cache_valid 80s;
open_file_cache_min_uses 1;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
proxy_buffer_size 128k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 128k;
server_tokens off;
client_header_buffer_size 4k;
server_names_hash_bucket_size 64;
server_name_in_redirect off;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
log_format main '$server_name $remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" ' '$ssl_protocol $ssl_cipher $upstream_addr $request_time $upstream_response_time';
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml text/javascript;
include /etc/nginx/conf.d/*.conf;
}
zabbix.conf nginx虚拟主机配置
server{
listen 80;
server_name _;
index index.php;
root /usr/share/zabbix/;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 30d;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
include fastcgi_params;
}
}
相关文章
- Zerotier在群晖DMS6的安装
- Linux 最小化安装时,是没有 tab 命令补全的,需要自己手动安装。
- madvrhdrmeasure 设置_ime3d安装教程
- Dreamweaver 2018软件下载和安装教程
- 介绍下 npm 模块安装机制,为什么输入 npm install 就可以自动安装对应的模块?
- Mac OS X中MacPorts安装和使用
- 【图文安装教程】Docker安装ES的拼音分词器-搜索时候自动补全必备
- 把 Django 网站做成能用 pip 安装的软件包
- 计量经济学软件EViews最新中文版,EViews软件2023安装教程下载 EViews下载
- centos 6.5下安装oracle 11gR2与Oracle自动启动的配置
- 使用PXE自动安装CentOS7.6的教程详解
- Linux离线安装:无网卡也可以运行(linux无网卡)
- 安装Linux虚拟机优盘快速安装指南(linux虚拟机优盘)
- 标题:轻松实现Oracle自动安装(自动安装oracle)
- 微软必应推出官方版的壁纸更换程序 安装后可每天自动更换必应美图
- Debian及衍生版自动安装系统更新
- Mac安装MySQL小贴士(mac如何安装mysql)
- Linux自动部署软件:一键安装就能搞定!(linux自动安装软件)
- Linux安装Lzma简易指南(linux安装lzma)
- 安装Linux系统时使用LZMA压缩(linux安装lzma)
- Linux自动安装之路:光盘实现自动部署(linux自动安装光盘)
- 在 Ubuntu 18.04 LTS 上安装 Microsoft Windows 字体
- 自动安装的应答文件
- 解决CH340驱动Linux安装问题,让您的设备连接更省心(ch340驱动linux)
- Linux下GDB的安装部署(linuxgdb安装)
- 搭建Linux服务器,安装JDK环境(linux服务器jdk)
- 如何在Linux上安装GTK?25步教你快速安装GTK!(linux安装gtk)
- WxDfast (wxDownload Fast)是一个图形化的下载工具,支持多线程、断点续传等功能,最大特点是下载速度快。然后使用如下命令进行安装: #tar jxvf wxdfast-0.2.1d.tar.bz2 #cd wxdfast-0.2.1-src #make install 在终端下运行“./wxdfast”命令便可运行程序。
- Opera的一直努力成为第一位的浏览器,虽然在添加/删除软件工具中找不到,但是其下载页面可以自动监测到你正在使用的Linux版本从而提供合适的程序。打开时,管理器会自动打开并询问是否安装该软件包。
- 搭建基于 Ubuntu Server 的 PXE 自动安装环境的实用指南