MHA配置测试ssh连接报错Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
在 manager 节点上测试 ssh 无密码认证出现报错
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[root@mysql2 . ssh ] # masterha_check_ssh -conf=/etc/masterha/app1.cnf Wed Sep 22 19:33:33 2021 - [warning] Global configuration file /etc/masterha_default .cnf not found. Skipping. Wed Sep 22 19:33:33 2021 - [info] Reading application default configuration from /etc/masterha/app1 .cnf.. Wed Sep 22 19:33:33 2021 - [info] Reading server configuration from /etc/masterha/app1 .cnf.. Wed Sep 22 19:33:33 2021 - [info] Starting SSH connection tests.. Wed Sep 22 19:33:34 2021 - [error][ /usr/local/share/perl5/MHA/SSHCheck .pm, ln63] Wed Sep 22 19:33:34 2021 - [debug] Connecting via SSH from root@192.168.229.80(192.168.229.80:22) to root@192.168.229.90(192.168.229.90:22).. Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). Wed Sep 22 19:33:34 2021 - [error][ /usr/local/share/perl5/MHA/SSHCheck .pm, ln111] SSH connection from root@192.168.229.80(192.168.229.80:22) to root@192.168.229.90(192.168.229.90:22) failed! Wed Sep 22 19:33:34 2021 - [debug] Wed Sep 22 19:33:33 2021 - [debug] Connecting via SSH from root@192.168.229.90(192.168.229.90:22) to root@192.168.229.80(192.168.229.80:22).. Wed Sep 22 19:33:34 2021 - [debug] ok. Wed Sep 22 19:33:34 2021 - [debug] Connecting via SSH from root@192.168.229.90(192.168.229.90:22) to root@192.168.229.70(192.168.229.70:22).. Wed Sep 22 19:33:34 2021 - [debug] ok. Wed Sep 22 19:33:36 2021 - [debug] Wed Sep 22 19:33:34 2021 - [debug] Connecting via SSH from root@192.168.229.70(192.168.229.70:22) to root@192.168.229.90(192.168.229.90:22).. Wed Sep 22 19:33:35 2021 - [debug] ok. Wed Sep 22 19:33:35 2021 - [debug] Connecting via SSH from root@192.168.229.70(192.168.229.70:22) to root@192.168.229.80(192.168.229.80:22).. Wed Sep 22 19:33:35 2021 - [debug] ok. Bizarre copy of ARRAY in scalar assignment at /usr/share/perl5/vendor_perl/Carp .pm line 182. |
查找问题并解决
查看配置文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
[root@mysql2 . ssh ] # vim /etc/masterha/app1.cnf [server default] manager_log= /var/log/masterha/app1/manager .log manager_workdir= /var/log/masterha/app1 master_binlog_dir= /usr/local/mysql/data master_ip_failover_script= /usr/local/bin/master_ip_failover master_ip_online_change_script= /usr/local/bin/master_ip_online_change password=manager ping_interval=1 remote_workdir= /tmp repl_password=12345 repl_user=myslave secondary_check_script= /usr/local/bin/masterha_secondary_check -s 192.168.229.80 -s 192.168.229.70 shutdown_script= "" ssh_user=root user=mha [server1] hostname =192.168.229.90 port=3306 [server2] candidate_master=1 check_repl_delay=0 hostname =192.168.229.80 port=3306 [server3] hostname =192.168.229.70 port=3306 |
配置文件应该没什么问题
再查找ssh连接的问题
1
2
|
[root@mysql2 . ssh ] # ls authorized_keys id_rsa id_rsa.pub known_hosts |
重新连接ssh,将./ssh目录下的文件全部删除,重新设置无密连接
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
[root@mysql1 ~] # cd ./.ssh/ [root@mysql1 . ssh ] # ls authorized_keys id_rsa id_rsa.pub known_hosts [root@mysql1 . ssh ] # rm -rf * [root@mysql1 . ssh ] # ls [root@mysql1 . ssh ] # ssh-keygen -t rsa Generating public /private rsa key pair. Enter file in which to save the key ( /root/ . ssh /id_rsa ): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/ . ssh /id_rsa . Your public key has been saved in /root/ . ssh /id_rsa .pub. The key fingerprint is: SHA256:YH0mtNnSodwDmK3IQIwuM8gBKaDd9fKC4RWezuREx3A root@mysql1 The key's randomart image is: +---[RSA 2048]----+ |==. =*E . | |=oo. +oXoO . | |* ooo.X.X B | |=o .o@.+ = . | |.o o = S | | . | | | | | | | +----[SHA256]-----+ [root@mysql1 . ssh ] # ssh-copy-id 192.168.229.80 /usr/bin/ssh-copy-id : INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host '192.168.229.80 (192.168.229.80)' can't be established. ECDSA key fingerprint is SHA256:kfiiDqRfaaR8s8E8VRXk+ZrgUEqUZaa1lW40fN0MgVw. ECDSA key fingerprint is MD5:87:6a:4a:bf:58:17:5b:f1:10:4f:a8:af:96:06:62:3b. Are you sure you want to continue connecting ( yes /no )? y Please type 'yes' or 'no' : yes /usr/bin/ssh-copy-id : INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id : INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@192.168.229.80's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh '192.168.229.80'" and check to make sure that only the key(s) you wanted were added. |
再次进行无密认证检测
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
[root@mysql2 . ssh ] # masterha_check_ssh -conf=/etc/masterha/app1.cnf Wed Sep 22 20:03:21 2021 - [warning] Global configuration file /etc/masterha_default .cnf not found. Skipping. Wed Sep 22 20:03:21 2021 - [info] Reading application default configuration from /etc/masterha/app1 .cnf.. Wed Sep 22 20:03:21 2021 - [info] Reading server configuration from /etc/masterha/app1 .cnf.. Wed Sep 22 20:03:21 2021 - [info] Starting SSH connection tests.. Wed Sep 22 20:03:22 2021 - [debug] Wed Sep 22 20:03:21 2021 - [debug] Connecting via SSH from root@192.168.229.90(192.168.229.90:22) to root@192.168.229.80(192.168.229.80:22).. Wed Sep 22 20:03:21 2021 - [debug] ok. Wed Sep 22 20:03:21 2021 - [debug] Connecting via SSH from root@192.168.229.90(192.168.229.90:22) to root@192.168.229.70(192.168.229.70:22).. Wed Sep 22 20:03:21 2021 - [debug] ok. Wed Sep 22 20:03:22 2021 - [debug] Wed Sep 22 20:03:21 2021 - [debug] Connecting via SSH from root@192.168.229.80(192.168.229.80:22) to root@192.168.229.90(192.168.229.90:22).. Warning: Permanently added '192.168.229.80' (ECDSA) to the list of known hosts. Wed Sep 22 20:03:21 2021 - [debug] ok. Wed Sep 22 20:03:21 2021 - [debug] Connecting via SSH from root@192.168.229.80(192.168.229.80:22) to root@192.168.229.70(192.168.229.70:22).. Wed Sep 22 20:03:22 2021 - [debug] ok. Wed Sep 22 20:03:23 2021 - [debug] Wed Sep 22 20:03:22 2021 - [debug] Connecting via SSH from root@192.168.229.70(192.168.229.70:22) to root@192.168.229.90(192.168.229.90:22).. Wed Sep 22 20:03:22 2021 - [debug] ok. Wed Sep 22 20:03:22 2021 - [debug] Connecting via SSH from root@192.168.229.70(192.168.229.70:22) to root@192.168.229.80(192.168.229.80:22).. Wed Sep 22 20:03:22 2021 - [debug] ok. Wed Sep 22 20:03:23 2021 - [info] All SSH connection tests passed successfully. |
检测成功,故障排除
分类:
数据库
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)