用远程主机检查Mysql - Icinga2

问题描述 投票:0回答:1

我正在使用Icinga2监视远程主机上的Mysql服务器。现在,我正在尝试配置mysql_check

这是文件service.conf

apply Service "mysql8" {  
  import "generic-service"
 check_command = "mysql"

 vars.mysql_mode = "uptime"
 vars.mysql_hostname = "remote-host"
 vars.mysql_port = "3306"
 vars.mysql_username = "username"
 vars.myql_password = "password"
 command_endpoint = host.vars.client_endpoint
 assign where host.vars.mysql == true && host.vars.client_endpoint
}

这是文件host.conf

object Host "remote-host" {
import "generic-host"
address = "xxx.xxx.xx.xxx"
vars.os = "linux"
vars.mysql = true
host.vars.client_endpoint="remote-host"

当我尝试使用check_MySQLfrom Icinga2时,我收到以下错误:

无法连接到'remote-host'上的MySQL服务器(111)

我该怎么做才能用远程主机解析check_MySQL

谢谢。

mysql remote-access remote-server icinga2
1个回答
0
投票

很高兴在这里找到你。

我认为你的mysql服务器不允许远程访问。

在这种情况下 :

  1. 打开命令提示符并运行以下命令以打开SSH隧道。 $ ssh [email protected] -L 3307:127.0.0.1:3306 -N NB。将[email protected]替换为您的ssh用户名和ssh主机名或IP地址。

-N:转发端口

-L:将本地端口绑定到远程主机端口2.尝试连接mysql-client

$ mysql --protocol TCP -h localhost -u YOUR_MYSQL_USER -P 3307 -p

这是工作?所以,:)

  1. 只需在icinga服务配置中替换vars.mysql_port=3307即可。

大!好东西!不?

© www.soinside.com 2019 - 2024. All rights reserved.