一、Zabbix介绍
Zabbix 是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。zabbix 能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
Zabbix官网
二、架构规划
1、主机清单
角色 |
主机IP |
用途 |
组件 |
服务端/zabbix-server |
192.168.91.17 |
部署Zabbix服务端 |
Nginx/Mysql/PHP/zabbix-server |
客户端/zabbix-agent |
192.168.91.15 |
部署Zabbix客户端 |
zabbix-agent |
2、组件清单
三、LNMP环境搭建
1、L(Linux)
1、关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
2、关闭selinux
setenforce 0
sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
3、初始化
mkdir -p /data/{
software,logs,temp}
chmod 777 /data/logs
2、N(Nginx)
1、生成安装脚本
cat > install_nginx.sh << EOF
#!/bin/bash
###By Luis
yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl
yum -y install openssl-devel
ng_tgz=`find / -name "nginx-1.18.0.tar.gz"`
install_dir=`basename ${
ng_tgz} .tar.gz`
if [ ! -d /data/software ];then
mkdir -p /data/software
fi
if [ ! -d /data/temp ];then
mkdir -p /data/temp
fi
tar -xf ${ng_tgz} -C /data/temp/
cd /data/temp/${install_dir}
./configure --prefix=/data/software/nginx --with-http_stub_status_module
make && make install
ln -sv /data/software/nginx/sbin/nginx /usr/bin/nginx
EOF
2、执行安装
sh install_nginx.sh
3、使用systemd管理服务
cat > /lib/systemd/system/nginx.service << EOF
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/data/software/nginx/sbin/nginx
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
4、启停方式
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
3、M(Mysql)
1、安装脚本
#!/bin/bash
yum -y install libaio
cd /data/software/
tar xvf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
cd /usr/local
ln -s mysql-5.7.30-linux-glibc2.12-x86_64 mysql
DB_BASE_DIR='/data/software/mysql_3306'
DB_LOG_DIR='/data/logs/mysql_3306'
mkdir -p ${DB_BASE_DIR}/{
data,etc,tmp}
mkdir -pv ${DB_LOG_DIR}/{
innodb_logs,bin,relaylog,undo}
useradd mysql
chown -R mysql.mysql ${DB_BASE_DIR}
chown -R mysql.mysql ${DB_LOG_DIR}
cd /usr/local/mysql
cat > /etc/my.cnf <<EOF
[client]
port=3306
default-character-set=utf8
socket=/data/software/mysql_3306/tmp/mysql.sock
[mysql]
port=3306
prompt=\\u@\\d \\r:\\m:\\s>
default-character-set=utf8
no-auto-rehash
socket=/data/software/mysql_3306/tmp/mysql.sock
[mysqld]
port=3306
sql_mode='NO_ENGINE_SUBSTITUTION'
character-set-server=utf8mb4
default-storage-engine=INNODB
default-time-zone="+08:00"
log_timestamps=SYSTEM
explicit_defaults_for_timestamp=1
transaction-isolation = READ-COMMITTED
# directionary
innodb_log_group_home_dir=/data/logs/mysql_3306/innodb_logs/
innodb_data_home_dir=