系统版本
centos7.2
下载软件源配置yum
rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
预先准备LANMP环境
1.yum
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
2.mysql建库并授权
create database zabbix character set utf8 cllate utf8_bin;
grant all privileges on . to zabbix@‘localhost’ identified by “zabbix”;
flush privileges;
3.导入数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
4.修改hosts配置文件
主监听ip 主机名(zabbix识别)
修改zabbix-server配置文件
DBpassword
DBuser
DBhost
修改zabbix-agent配置文件
Server=127.0.0.1 (主监听ip)
ListenPort=10050 (主监听端口)
ListenIP=0.0.0.0 (被监听ip)
ServerActive=127.0.0.1 (主监听ip)
Hostname=adminserver (监听识别主机名)
修改zabbix语言字体
/usr/share/zabbix/include/defines.inc.php中define(‘ZBX_GRAPH_FONT_NAME’,对应的字体
(字体可以从windows中上传到/usr/share/zabbix/assets/fonts下)
5.解决swap交换分区的问题
/etc/sysctl.conf
vm.swappiness = 10
mkdir /swap && cd /swap
dd if=/dev/zero of=swapfile bs=1M count=4k
mkswap swapfile
swapon swapfile
6.配置邮件报警类型(阿里云服务器25不通)
1)创建存放证书的目录
mkdir -p /root/.certs
2)向163请求证书
echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p’ > ~/.certs/163.crt ####向163请求证书
3)添加一个SSL证书到证书数据库中
certutil -A -n “GeoTrust SSL CA” -t “C,” -d ~/.certs -i ~/.certs/163.crt
4)添加一个Global 证书到证书数据库中
certutil -A -n “GeoTrust Global CA” -t “C,” -d ~/.certs -i ~/.certs/163.crt
5)创建报警脚本
#!/bin/bash
messages=echo $3 | tr '\r\n' '\n'
subject=echo $2 | tr '\r\n' '\n'
echo “
m
e
s
s
a
g
e
s
"
∣
m
a
i
l
−
s
"
{messages}" | mail -s "
messages"∣mail−s"{subject}” $1 >>/tmp/sendmail.log 2>&1