一:安装分为两部分
1、zabbix3.0安装
2、邮件报警安装
二:zabbix3.0安装部署
关闭防火墙:
systemctl stop firewalld.service
systemctl disable firewalld.service
关闭selinux:
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
配置yun源
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
安装服务器端包
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server zabbix-get
启动mariadb
systemctl start mariadb
systemctl enable mariadb
创建zabbix数据库
mysqladmin -uroot password zabbitx
mysql -uroot -pzabbix
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
flush privileges;
exit;
导入数据和表结构
/usr/share/doc/zabbix-server-mysql-3.0.13
zcat create.sql.gz |mysql -uroot -pzabbix zabbix
默认账号密码是
Admin
zabbix
修改zabbix_server.conf
vim /etc/zabbix/zabbix_server.conf
91:DBName=zabbix
107:DBUser=zabbix
115:DBPassword=zabbix
启动zabbix-server
systemctl start zabbix-server
systemctl enable zabbix-server
添加时区信息
vim /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
#php_value date.timezone Europe/Riga
php_value date.timezone Asia/Shanghai (为追加项 把时区改为Asia/Shanghai)
启动httpd服务
systemctl start httpd.service
systemctl enable httpd.service
浏览器输入你的zabbixip地址 进行安装
http://zabbix_IP地址/zabbix/setup.php
登录账号密码是
Admin
zabbix
二:zabbix邮件报警
1.安装邮件发送工具mailx
systemctl stop sendmail
systemctl stop postfix
systemctl disable sendmail
systemctl disable postfix
yum -y install mailx
因为新的云主机不支持25端口因此采用465加密方式发送信息
需要配置smtps方式
mkdir -p /root/.certs/
echo -n | openssl s_client -connect smtp.exmail.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/tencent.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/tencent.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/tencent.crt
certutil -L -d /root/.certs
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i tencent.crt
vim /etc/mail.rc
set from=server@100.com
set smtp=smtps://smtp.exmail.qq.com:465
set smtp-auth-user=server@100.com
set smtp-auth-password=123456
set smtp-auth=login
set smtp-use=starttls
set ssl-verify=ignore
set nss-config-dir=/root/.certs
进入证书目录授权不然会报错 因为zabbix没有权限调用这个证书
添加zabbix sudoers权限(这个折腾了我好几天MMP)
Error initializing NSS: Unknown error -8015.
. . . message not sent.
cd /root/.certs
ls
chmod 755 ./*
手动测试邮件是否正常
echo ”zabbix test” | mail -s "zabbix" server@100.com
可以收到邮件
通过脚本来实现收发邮件
查看zabbix /etc/zabbix/zabbix_server.conf
看看脚本路径在哪
#!/bin/bash
messages=echo $3 | tr '\r\n' '\n'
subject=echo $2 | tr '\r\n' '\n'
echo "${messages}" | sudo mail -s "${subject}" $1 >>/tmp/mailx.log 2>&1
注意配置脚本参数和权限
登录zabbix web页面配置
用户配置添加自己的邮件地址
点击动作 创建一个ping 的动作
报警收件人添加进去直发送到scripts这个
在客户端安装agent
客户端是centos7.0:
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
yum -y install zabbix-agent
vim /etc/zabbix/zabbix_agentd.conf
Server=zabbix服务器IP
ServerActive=zabbix服务器IP
systemctl start zabbix-agent
systemctl enable zabbix-agent
在服务器iptables上面禁止ping
已经收到告警邮件
到此安装zabbix和邮件报警已经安装完了
如有问题可留言