我正在使用 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"
当我从 Icinga2 尝试 check_MySQL
时,出现以下错误:
Can't connect to MySQL server on 'remote-host' (111)
如何解决远程主机的 check_MySQL
问题。
谢谢。
最佳答案
很高兴在这里找到你。
我认为你的mysql服务器不允许远程访问。
在这种情况下:
打开命令提示符并运行以下命令以打开 SSH 隧道。
$ ssh user@example.com -L 3307:127.0.0.1:3306 -N 注意。将user@example.com
替换为您的 ssh 用户名和 ssh 主机名或 IP 地址。
-N:转发端口
-L :将本地端口绑定(bind)到远程主机端口 2. 尝试连接你的mysql-client
$ mysql --protocol TCP -h localhost -u YOUR_MYSQL_USER -P 3307 -p
上类了?所以,:)
- 只需替换 icinga 服务配置中的
vars.mysql_port=3307
即可。
太棒了!好东西!没有?
关于mysql - 使用远程主机检查 Mysql - Icinga2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55175214/