标签:rap apache centos 测试 nlog pack httpd files get
mysql安装zabbix4.0
一 准备环境
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.设置此参数,不立即重启主机时
# setenforce 0
3.zabbix安装参考文档
https://www.zabbix.com/documentation/4.0/manual/installation/install_from_packages/rhel_centos ##zabbix 安装文档
二 安装
4.安装rpm
5.下载安装文档
wget https://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
6.安装server、agent端
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
9.数据库创建用户并授权
> create user zabbix@‘10.0.0.69‘;
> grant all privileges on *.* to zabbix@‘10.0.0.69‘ identified by ‘oraclep‘;
> flush privileges;
> grant all privileges on *.* to zabbix@‘localhost‘ identified by ‘oraclep‘;
10.编辑文件zabbix_server.conf加入server端信息
加入信息:
SocketDir=/var/run/zabbix
DBHost=10.0.0.53
DBName=zabbix
DBUser=zabbix
DBPasswd=oraclep
DBSocket=/home/mysql/mysqldb/db_slave/mysql.sock zabbix
DBPort=33333
11.查看/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=oraclep
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
12. 测试以上信息正确性
# mysql -uzabbix -poraclep -S /home/mysql/mysqldb/db_master/mysql.sock -P 55555 ;
13. 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
14. 查看zabbix日志
[root@localhost ~]# tail -f /var/log/zabbix/zabbix_server.log
[root@localhost ~]# tail -f /var/log/zabbix/zabbix_agent.log
15. 修改时区:
vi /etc/httpd/conf.d/zabbix.conf
依据所在时区,你可以取消 “date.timezone” 设置的注释,并正确配置它。在配置文件更改后,需要重启Apache Web服务器。
在此行下面添加
date.timezone = Asia/Shanghai
16. 创建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
17. 编辑/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
18.查看 /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
19.web网页连接
# systemctl start httpd
mysql 数据库搭建Zabbix 监控
标签:rap apache centos 测试 nlog pack httpd files get
原文地址:https://www.cnblogs.com/Chaos-oaa/p/9538219.html