CentOS7部署zabbix

zabbix4.0部署

 

一、客户端:

 

1、单机配置LAMP环境(安装好LANP)

Mysql需要准备的:

#建zabbix库
create database zabbix character set utf8 collate utf8_bin;
#授权
grant all on zabbix.* to 'zabbix'@'%'  identified by \"123456\";
#刷新授权
flush privileges;

2、阿里源远程安装远程安装

rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm

3、安装zabbix相关服务

yum install zabbix-server-mysql zabbix-web-mysql -y
yum -y install zabbix-get zabbix-agent
yum install -y php-fpm 

4、初始化zabbix

  (1)在mysql中生成相关文件:

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uroot -p123456 zabbix

5、修改配置文件

  (1)设置时区为亚洲上海,/etc/php.ini

echo 'date.timezone = Asia/Shanghai' >> /etc/php.ini

  (2)设置时区为亚洲上海,/etc/httpd/conf.d/zabbix.comf

php_value date.timezone Asia/Shanghai #第20行

  (3)zibbix_server基本配置文件

# cat /etc/zabbix/zabbix_server.conf | grep -Ev "^#|^$"        

ListenPort=10051
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=192.168.254.41
DBName=zabbix
DBUser=zabbix
DBPassword=123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

  6、访问192.168.254.41/zabbix (服务端IP)

  (1)关闭防火墙

#清空防火墙规则
iptables -F
#临时关闭防火墙
setenforce 0

  启动apache: systemctl start httpd

  登录账号Admin  密码 zabbix

二、客户端(被监控的)

  1、阿里源远程安装

rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm

  2、安装zabbix代理

yum install -y zabbix-get zabbix-agent

  3、客户端基本配置文件

# cat /etc/zabbix/zabbix_agentd.conf | grep -Ev "^#|^$"
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.254.41
ListenPort=10050
ListenIP=0.0.0.0
ServerActive=192.168.254.41
Hostname=MQ-32
Include=/etc/zabbix/zabbix_agentd.d/*.conf

#下面是我新加的监控项login.nuptime和User.mam
#在线用户
UserParameter=login.num,uptime | awk '{print$4}'
#内存大概使用率
UserParameter=User.mam,free -m | sed -n '2p' | awk '{print  ""$3/$2*100""}'|awk -F '.' '{print""$1"%"}'

 

posted on 2021-10-25 20:04  华华中  阅读(99)  评论(0编辑  收藏  举报

导航