zabbix安装与使用

1. 关闭系统selinux

[root@linux01 ~]#vi /etc/selinux/config  

#This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing - SELinux security policy is enforced.

#     permissive - SELinux prints warnings instead of enforcing.

#     disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of these two values:

#     targeted - Targeted processes are protected,

#     mls - Multi Level Security protection.

设置完需重启虚拟机

2.设置此参数,因zabbix连接不上数据库

#  setenforce 0

3.查看zabbix安装文档

https://www.zabbix.com/documentation/4.0/manual/installation/install_from_packages/rhel_centos       ##zabbix  安装文档

4.安装rpm

rpm -ivh https://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm

5.下载安装文档

wget https://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm

6.安装serveragent

yum install mysql-server httpd php

yum install zabbix-server-mysql zabbix-web-mysql

 yum install zabbix-agent

7. 创建zabbix数据库

> create database zabbix;                                              #8.zabbix数据库中创建需要的表

    # cd /usr/share/doc/zabbix-server-mysql-4.0.0/

# zcat create.sql.gz | mysql -uroot -pzabbix -S /home/mysql/mysqldb/db_master/mysql.sock zabbix

8. 数据库创建用户并授权

> create user zabbix@'10.0.0.69';

> grant all privileges on *.* to zabbix@'10.0.0.69' identified by 'oracle';

> flush privileges;

> grant all privileges on *.* to zabbix@'localhost' identified by 'oracle';

9. 编辑文件zabbix_server.conf加入server端信息

加入信息:

SocketDir=/var/run/zabbix

DBHost=10.0.0.53

DBName=zabbix

DBUser=zabbix

DBPasswd=oracle

DBSocket=/home/mysql/mysqldb/db_slave/mysql.sock zabbix

DBPort=33333

10. 查看/etc/zabbix/zabbix_server.conf

[root@localhost ~]# grep -v '^#' /etc/zabbix/zabbix_server.conf |grep -v '^$'

LogFile=/var/log/zabbix/zabbix_server.log

LogFileSize=0

PidFile=/var/run/zabbix/zabbix_server.pid

SocketDir=/var/run/zabbix

DBHost=10.0.0.53

DBName=zabbix

DBUser=zabbix

DBPasswd=oracle

DBSocket=/home/mysql/mysqldb/db_slave/mysql.sock zabbix

DBPort=33333

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

Timeout=4

AlertScriptsPath=/usr/lib/zabbix/alertscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

LogSlowQueries=3000

11. 测试以上信息正确性

# mysql -uzabbix -poracle -S /home/mysql/mysqldb/db_master/mysql.sock -P 55555 ;

12. zabbix启动、关闭重启

# systemctl restart zabbix-server

# systemctl start zabbix-server

# systemctl stop zabbix-server

# systemctl status zabbix-server

# systemctl start zabbix-agent

# systemctl stop zabbix-agent

 

13. 查看zabbix日志

[root@localhost ~]# tail -f /var/log/zabbix/zabbix_server.log

[root@localhost ~]# tail -f /var/log/zabbix/zabbix_agent.log

14. 修改时区:

vi  /etc/httpd/conf.d/zabbix.conf

依据所在时区,你可以取消date.timezone” 设置的注释,并正确配置它。在配置文件更改后,需要重启Apache Web服务器。

在此行下面添加

date.timezone = Asia/Shanghai

15. 创建mysql连接目录

agent端数据库连接与密码

[root@localhost zabbix]# mkdir -p /var/lib/zabbix

#  vi /var/lib/zabbix/.my.cnf

[client]

password=

user=root

socket=/home/mysql/mysqldb/db_master/mysql.sock

16. 编辑/etc/zabbix/zabbix_agentd.d加入agent端信息

# cd /etc/zabbix/zabbix_agentd.d

# vi userparameter_mysql.conf

UserParameter=mysql.status[*],echo "show global status where Variable_name='Binlog_cache_use';" | HOME=/var/lib/zabbix mysql -N | awk '{print $0}'

找出HOME=/var/lib/zabbix mysql 测试

[root@localhost zabbix_agentd.d]# HOME=/var/lib/zabbix mysql       agent端数据库连接与密码同一路径

 

可以连接到数据库

[root@localhost zabbix_agentd.d]# env|grep HOME

HOME=/root

17.查看 /etc/zabbix/zabbix_agentd.conf 

[root@localhost ~]# grep -v '^#' /etc/zabbix/zabbix_agentd.conf |grep -v '^$'

PidFile=/var/run/zabbix/zabbix_agentd.pid

LogFile=/var/log/zabbix/zabbix_agentd.log

LogFileSize=0

Server=10.0.0.69

ServerActive=10.0.0.69

Hostname=localhost

Include=/etc/zabbix/zabbix_agentd.d/*.conf

 

18.web网页连接

# systemctl start httpd

# http://10.0.0.69/zabbix/setup.php

原文地址:https://www.cnblogs.com/lswei/p/9546297.html