1、监控存在的原因
站点出了问题,没有人知道,等用户发现了,才提醒供应商;对公司影响很大
2、常见开源监控软件
cacti、nagios、zabbix、smokeping、open-falcon等等,其中nagios、zabbix流行度非常高;
cacti、smokeping偏向于基础监控,成图非常漂亮,适合监控网络设备 cacti监控网络的设备;
cacti、nagios、zabbix服务端监控中心,需要php环境支持(用Apache的php,用nginx的php都可以),其中zabbix和cacti都需要mysql作为数据存储,nagios不用存储历史数据,注重服务或者监控项的状态,zabbix会获取服务或者监控项目的数据,会把数据记录到数据库里,从而可以成图
3、目前业界都流行用zabbix。
zabbix配置简单,优势明显,早起使用nagios的企业,慢慢的转向使用zabbix;
nagios,需要更改配置文件,并不支持web界面一键执行,nagios和zabbix相比,nagios 更注重的是某一个监控的状态,不关注历史;
zabbix,则是把每一次监控的数值反馈出来,数值存到数据库里面,方便后期数据图去分析监控整个状态;
nagios不需要mysql的支持,不能成图,若需要画图,得安装插件以后才支持web界面;
ccti 也需要mysql的支持,也可以成图,可以记录历史数据
zabbix 在web界面下管理得非常彻底,可以增加监控节点,报警预知等等。
open-falcon为小米公司开发,开源后受到诸多大公司和运维工程师的追捧,适合大企业,滴滴、360、新浪微博、京东等大公司在使用这款监控软件,值得研究
open-falcon软件适合大企业使用,小企业可以去研究它的思想。
监控软件比较新的: prometheus grafana
4、zabbix简介
C/S架构,有一个服务端,去客户端抓数据。在客户端必须要有一个服务启动运行才可以抓取数据;数据可以主动的上报服务端,也可以让服务端去连接客户端获取(通过抓取数据方式,数据获取分两个模式,一个主动模式,一个被动模式),
zabbix软件基于C++开发,监控中心需要一个PHP的web环境,因为要开启一个web界面配置和管理 单台server节点(即一台server),理论上 可以支持上万台客户端
5、zabbix瓶颈:
在于采集数据的量,虽然支持上万台,但监控的项目过多,还是会导致zabbix效率降低;所以,当服务器大到一定规模的时候,就需要对zabbix进行优化;
解决方法:可以增加一些代理点,这些代理点充当server,替代server去采集数据,最终得到分析结果再汇报给主服务端server;
6、zabbix架构里,包括了5个组件:
zabbix-server 监控中心,接收客户端上报信息,负责配置、统计、操作数据
数据存储 存放数据,比如mysql
web界面 也叫web UI,在web界面下操作配置是zabbix简单易用的主要原因(如果没有web界面,就无法在浏览器上配置它)
zabbix-proxy 可选组件,它可以代替zabbix-server的功能,减轻server的压力(当机器量很多的时候,可以使用zabbix-proxy)
有时候,服务器分布在多个机房里,每个机房的服务器之间都是一个单独的内网,这时候就可以在某一个局域网里搭建一个 zabbix-proxy ,用这台 proxy 去监控局域网里的机器
zabbix-agent 客户端软件(每一台客户端都需要安装agent),负责采集各个监控服务或项目的数据,并上报。
zabbix官网:www.zabbix.com
[root@linux-001 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
获取https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.z8bUCY: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:zabbix-release-4.2-1.el7 ################################# [100%]
[root@linux-001 ~]# yum install -y zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql zabbix-agent
安装省略
[root@linux-001 ~]# mysql -uroot -plinux002
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.43-log MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zabbix;
Query OK, 1 row affected (0.01 sec)
mysql> grant all on zabbix.* to zabbix@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges ;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
zabbix的原始数据库是create.sql.gz,可以使用gzip -d 解压此文件,在导入数据库,也可以使用zcat命令。
[root@linux-001 ~]# cd /usr/share/doc/zabbix-server-mysql-4.2.3/
[root@linux-001 zabbix-server-mysql-4.2.3]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@linux-001 zabbix-server-mysql-4.2.3]# zcat create.sql.gz | mysql -uroot -plinux002 zabbix
Warning: Using a password on the command line interface can be insecure.
[root@linux-001 zabbix-server-mysql-4.2.3]#
修改zabbix_server.conf 文件中数据库相关的行。
[root@linux-001 ~]# vim /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBSocket=/tmp/mysql.sock
修改和server端通信的ip地址
[root@linux-001 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1
ServerActive=127.0.0.1
[root@linux-001 ~]# vim /etc/php.ini
date.timezone = Asia/Shanghai
启动 zabbix-server zabbix-agent httpd 服务
[root@linux-001 ~]# systemctl start zabbix-server
[root@linux-001 ~]# systemctl start zabbix-agent
[root@linux-001 ~]# systemctl start httpd.service
[root@linux-001 ~]#
如果遇到如上图的问题,请删除zabbix-server-pgsql,如下图
解决办法:修改 zabbix_server.conf 中的 DBSocket=/tmp/mysql.sock
[root@linux-02 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
获取https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.Y9bgOq: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:zabbix-release-4.2-1.el7 ################################# [100%]
[root@linux-02 ~]# yum install -y zabbix-agent
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.cn99.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
zabbix | 2.9 kB 00:00:00
zabbix-non-supported | 951 B 00:00:00
(1/3): extras/7/x86_64/primary_db | 200 kB 00:00:02
(2/3): zabbix/x86_64/primary_db | 39 kB 00:00:06
(3/3): updates/7/x86_64/primary_db | 5.0 MB 00:00:06
zabbix-non-supported/x86_64/primary | 1.6 kB 00:00:02
zabbix-non-supported 4/4
正在解决依赖关系
--> 正在检查事务
---> 软件包 zabbix-agent.x86_64.0.4.2.3-2.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================================================================================
Package 架构 版本 源 大小
==================================================================================================================================================
正在安装:
zabbix-agent x86_64 4.2.3-2.el7 zabbix 400 k
事务概要
==================================================================================================================================================
安装 1 软件包
总下载量:400 k
安装大小:1.6 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/zabbix/packages/zabbix-agent-4.2.3-2.el7.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY00:00:00 ETA
zabbix-agent-4.2.3-2.el7.x86_64.rpm 的公钥尚未安装
zabbix-agent-4.2.3-2.el7.x86_64.rpm | 400 kB 00:01:15
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 检索密钥
导入 GPG key 0xA14FE591:
用户ID : "Zabbix LLC "
指纹 : a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591
软件包 : zabbix-release-4.2-1.el7.noarch (installed)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在安装 : zabbix-agent-4.2.3-2.el7.x86_64 1/1
验证中 : zabbix-agent-4.2.3-2.el7.x86_64 1/1
已安装:
zabbix-agent.x86_64 0:4.2.3-2.el7
完毕!
[root@linux-02 ~]#
[root@linux-001 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.141.128
ServerActive=192.168.141.128
[root@linux-02 ~]# systemctl start zabbix-agent.service
zabbix-agent 端的10050端口与 zabbix-server 端的10051端口通信。如果防火墙处于开启状态,需要把10050端口通信放行。
iptables -I -INPUT -s 192.168.141.128 -j ACCEPT
需要把之前在linux-002服务器上安装的agent添加到server端控制台,操作步骤:配置----主机----创建主机
也可复制已有的模板,然后吧不需要的监控项目删除。我们拿Template OS Linux模板举例。
取消aaa模板中不需要的连接模板。
因为触发器是根据监控项来设置的, 所以在删除不需要的监控项目之前需要把不用的触发器删除。
模板中不需要的监控项可以删除,越多的监控项会很耗费系统的io。
首先进入zabbix的根目录 /usr/share/zabbix/include , 打开文件defines.inc.php ,文件中有定义字体的位置,如下图。
然后进入 /usr/share/zabbix/assets/fonts/ 目录下,可以把windows中的字体传入此文件夹,windows的字体的文件位置(C:\Windows\Fonts),随便找一个字体传入此文件夹,我们在刷新网页,可以查看到图形界面的地方,字体不是乱码咯。
由于网页端输入的字符串存储是存储在mysql数据库中,若数据库中字符串所在位置存储格式不是utf8,会导致存储报错,那我们需要如何设置呢,先把数据库备份下,使用vim打开sql文件,修改文件中 latin1 为utf8。
[root@linux-001 ~]# mysql -uroot -plinux002 zabbix
Warning: Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 792
Server version: 5.6.43-log MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use zabbix
Database changed
mysql> show create table triggers\G;
*************************** 1. row ***************************
Table: triggers
Create Table: CREATE TABLE `triggers` (
`triggerid` bigint(20) unsigned NOT NULL,
`expression` varchar(2048) NOT NULL DEFAULT '',
`description` varchar(255) NOT NULL DEFAULT '',
`url` varchar(255) NOT NULL DEFAULT '',
`status` int(11) NOT NULL DEFAULT '0',
`value` int(11) NOT NULL DEFAULT '0',
`priority` int(11) NOT NULL DEFAULT '0',
`lastchange` int(11) NOT NULL DEFAULT '0',
`comments` text NOT NULL,
`error` varchar(2048) NOT NULL DEFAULT '',
`templateid` bigint(20) unsigned DEFAULT NULL,
`type` int(11) NOT NULL DEFAULT '0',
`state` int(11) NOT NULL DEFAULT '0',
`flags` int(11) NOT NULL DEFAULT '0',
`recovery_mode` int(11) NOT NULL DEFAULT '0',
`recovery_expression` varchar(2048) NOT NULL DEFAULT '',
`correlation_mode` int(11) NOT NULL DEFAULT '0',
`correlation_tag` varchar(255) NOT NULL DEFAULT '',
`manual_close` int(11) NOT NULL DEFAULT '0',
`details` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`triggerid`),
KEY `triggers_1` (`status`),
KEY `triggers_2` (`value`,`lastchange`),
KEY `triggers_3` (`templateid`),
CONSTRAINT `c_triggers_1` FOREIGN KEY (`templateid`) REFERENCES `triggers` (`triggerid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> show variaables like 'character%' ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'variaables like 'character%'' at line 1
mysql> show variables like 'character%';
+--------------------------+----------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.00 sec)
mysql> exit
Bye
[root@linux-001 ~]# mysqldump -uroot -plinux002 --default-character-set=utf8 zabbix > zabbix.sql
Warning: Using a password on the command line interface can be insecure.
[root@linux-001 ~]#
[root@linux-001 ~]# vim zabbix.sql
一般命令模式输入 :1,$s/latin1/utf8/g 可查看以上图片
[root@linux-001 ~]# mysql -uroot -plinux002 --default-character-set=utf8 zabbix < zabbix.sql
Warning: Using a password on the command line interface can be insecure.
[root@linux-001 ~]# mysql -uroot -plinux002
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 902
Server version: 5.6.43-log MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show variables like 'character%';
+--------------------------+----------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.00 sec)
mysql> show create table interface\G;
*************************** 1. row ***************************
Table: interface
Create Table: CREATE TABLE `interface` (
`interfaceid` bigint(20) unsigned NOT NULL,
`hostid` bigint(20) unsigned NOT NULL,
`main` int(11) NOT NULL DEFAULT '0',
`type` int(11) NOT NULL DEFAULT '0',
`useip` int(11) NOT NULL DEFAULT '1',
`ip` varchar(64) NOT NULL DEFAULT '127.0.0.1',
`dns` varchar(255) NOT NULL DEFAULT '',
`port` varchar(64) NOT NULL DEFAULT '10050',
`bulk` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`interfaceid`),
KEY `interface_1` (`hostid`,`type`),
KEY `interface_2` (`ip`,`dns`),
CONSTRAINT `c_interface_1` FOREIGN KEY (`hostid`) REFERENCES `hosts` (`hostid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> exit
Bye
未开通邮件推送服务,可以按照步骤开通邮件推送服务,设置一个自己的域名,把发信域名的配置信息添加到域名解析里面。
[root@linux-001 ~]# vim mail.py
#!/usr/bin/python
#coding:utf-8
import smtplib
from email.mime.text import MIMEText
import sys
mail_host = 'smtpdm.aliyun.com'
mail_user = '[email protected]'
mail_pass = '5cn3yYVzim'
mail_postfix = 'aliyun.com'
def send_mail(to_list,subject,content):
me = "zabbix 监控告警平台"+"<"+mail_user+"@"+mail_postfix+">"
msg = MIMEText(content, 'plain', 'utf-8')
msg['Subject'] = subject
msg['From'] = me
msg['to'] = to_list
try:
s = smtplib.SMTP()
s.connect(mail_host)
s.login(mail_user,mail_pass)
s.sendmail(me,to_list,msg.as_string())
s.close()
return True
except Exception,e:
print str(e)
return False
if __name__ == "__main__":
send_mail(sys.argv[1], sys.argv[2], sys.argv[3])
[root@linux-001 ~]# chmod 755 mail.py
我们可以在 zabbix_server.conf 配置文件中找到定义发送邮件脚本的发送位置,如下图
[root@linux-001 ~]# mv mail.py /usr/lib/zabbix/alertscripts
[root@linux-001 alertscripts]# ls
mail.py
[root@linux-001 alertscripts]# ./mail.py [email protected] 'ceshi' '`echo $HOSTNAME`'
//脚本参数如下:
{ALERT.SENDTO} 收件人邮箱
{ALERT.SUBJECT} 邮件标题
{ALERT.MESSAGE} 邮件正文
由于在编译安装nginx的时候没有添加选项,需要重新编译下nginx,如果不编译nginx,添加ngxin状态模块会提示报错。
[root@linux-02 ~]# cd /usr/local/src/nginx-1.16.0
[root@linux-02 nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
省略
[root@linux-02 nginx-1.16.0]# make && make install
省略
[root@linux-02 nginx-1.16.0]# cd /usr/local/nginx/conf/vhost
[root@linux-02 vhost]# vim test.com.conf
## 在行末添加以下内容 ##
location /nginx_status
{
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
[root@linux-02 vhost]# ./../../sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@linux-02 vhost]# /etc/init.d/nginx start
Starting nginx (via systemctl): [ 确定 ]
[root@linux-02 vhost]# ps aux | grep nginx
root 12851 0.0 0.0 20680 736 ? Ss 08:50 0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 12852 0.0 0.4 23168 3572 ? S 08:50 0:00 nginx: worker process
nobody 12853 0.0 0.3 23168 3316 ? S 08:50 0:00 nginx: worker process
root 12855 0.0 0.1 112724 988 pts/0 R+ 08:50 0:00 grep --color=auto nginx
[root@linux-02 vhost]# curl 127.0.0.1/nginx_status
Active connections: 1
server accepts handled requests
1 1 1
Reading: 0 Writing: 1 Waiting: 0
[root@linux-02 vhost]# curl 127.0.0.1/nginx_status
Active connections: 1
server accepts handled requests
2 2 2
Reading: 0 Writing: 1 Waiting: 0
[root@linux-02 vhost]# curl 127.0.0.1/nginx_status
Active connections: 1
server accepts handled requests
3 3 3
Reading: 0 Writing: 1 Waiting: 0
上面nginx状态的解释
字段 | 含义 |
---|---|
Active Connections | 当前活动连接数,其中也包括了等待状态的连接 |
accepts | 接收到的连接数 |
handled | 已经处理完的连接数,该数字一般和accepts一致,如果不一致那么说明Nginx出错了 |
requests | 总共处理的请求数,一个连接可以有多个请求,所以该值比accpets要大 |
Reading | 正在读取请求头信息的连接数 |
Writing | 正在发送响应报文的连接数 |
Waiting | 处于闲置状态,等待客户端发送请求的连接数 |
[root@linux-02 ~]# vim /usr/local/sbin/ngx_status.sh
#!/bin/bash
url="http://127.0.0.1/nginx_status"
curl=/usr/bin/curl
# 检测nginx进程是否存在
function ping {
/sbin/pidof nginx | wc -l
}
# 检测nginx性能
function active {
$curl $url 2>/dev/null| grep 'Active' | awk '{print $NF}'
}
function reading {
$curl $url 2>/dev/null| grep 'Reading' | awk '{print $2}'
}
function writing {
$curl $url 2>/dev/null| grep 'Writing' | awk '{print $4}'
}
function waiting {
$curl $url 2>/dev/null| grep 'Waiting' | awk '{print $6}'
}
function accepts {
$curl $url 2>/dev/null| awk NR==3 | awk '{print $1}'
}
function handled {
$curl $url 2>/dev/null| awk NR==3 | awk '{print $2}'
}
function requests {
$curl $url 2>/dev/null| awk NR==3 | awk '{print $3}'
}
$1
[root@linux-02 ~]# chmod 755 /usr/local/sbin/ngx_status.sh
[root@linux-02 ~]# vim /etc/zabbix/zabbix_agentd.conf
UserParameter=nginx.status[*],/usr/local/sbin/ngx_status.sh $1
[root@linux-02 ~]# yum install -y zabbix_java_gateway
安装省略
[root@linux-02 ~]# vim /etc/zabbix/zabbix_java_gateway.conf
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
START_POLLERS=5
[root@linux-02 ~]# systemctl start zabbix-java-gateway
[root@linux-02 ~]# ps aux | grep zabbix-java
zabbix 7685 10.8 4.3 2226548 36104 ? Sl 20:31 0:01 java -server -Dlogback.configurationFile=/etc/zabbix/zabbix_java_gateway_logback.xml -classpath lib:lib/android-json-4.3_r3.1.jar:lib/logback-classic-0.9.27.jar:lib/logback-core-0.9.27.jar:lib/slf4j-api-1.6.1.jar:bin/zabbix-java-gateway-4.2.3.jar -Dzabbix.pidFile=/var/run/zabbix/zabbix_java.pid -Dzabbix.listenIP=192.168.141.129 -Dzabbix.listenPort=10052 -Dzabbix.startPollers=5 -Dsun.rmi.transport.tcp.responseTimeout=3000 com.zabbix.gateway.JavaGateway
root 7698 0.0 0.1 112724 988 pts/0 R+ 20:31 0:00 grep --color=auto zabbix-java
[root@linux-02 ~]# netstat -lntp | grep 10052
tcp6 0 0 192.168.141.129:10052 :::* LISTEN 7685/java
[root@linux-02 ~]# vim /usr/local/tomcat/bin/catalina.sh
#在#!/bin/sh下增加
export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote
-Djava.rmi.server.hostname=192.168.141.129
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false"
[root@linux-02 ~]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk1.8/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@linux-001 ~]# vim /etc/zabbix/zabbix_server.conf
JavaGateway=192.168.141.129
JavaGatewayPort=10052
StartJavaPollers=5
[root@linux-001 ~]# systemctl restart zabbix-server
[root@linux-02 ~]# mysql -uroot -plinux002
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.43 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> grant usage, process, replication client on *.* to 'mmm'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.02 sec)
mysql>
mysql> quit
Bye
/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf 配置文件中定义的zabbix使用mysql用户存放的位置包含文件名称。
[root@linux-02 ~]# mkdir /var/lib/zabbix
[root@linux-02 ~]# vi /var/lib/zabbix/.my.cnf
[mysql]
host=localhost
user=mmm
password='123456'
socket=/tmp/mysql.sock
[mysqladmin]
host=localhost
user=mmm
password='123456'
socket=/tmp/mysql.sock
上面server端测试提示mysqladmin未找到命令,解决办法
在server段重新测试提示已经ok。