0

CentOS 6.6 + MySQL MHA(0.56)\

ssh-keygen -t rsa
ssh-copy-id -i /root/.ssh/id_rsa.pub root@slave2

and my SSH check is ok

[root@master ~]# ssh -v root@slave2
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to slave2 [192.168.233.133] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/identity-cert type -1
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'slave2' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = zh_CN.UTF-8
Last login: Wed Jun  1 06:56:32 2016 from master

and test ssh connection through command line,correct

[root@master ~]# ssh root@slave2
Last login: Wed Jun  1 22:55:06 2016 from 192.168.233.1
[root@slave2 ~]# 

when I use mha ssh check(masterha_check_ssh script),an error occurs "Permission denied (publickey,password)."

    [root@monitor ~]# masterha_check_ssh --conf=/etc/app1.cnf
    Thu Jun  2 04:25:52 2016 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
    Thu Jun  2 04:25:52 2016 - [info] Reading application default configuration from /etc/app1.cnf..
    Thu Jun  2 04:25:52 2016 - [info] Reading server configuration from /etc/app1.cnf..
    Thu Jun  2 04:25:52 2016 - [info] Starting SSH connection tests..
    Thu Jun  2 04:25:53 2016 - [error][/usr/local/share/perl5/MHA/SSHCheck.pm, ln63] 
    Thu Jun  2 04:25:52 2016 - [debug]  Connecting via SSH from root@master(192.168.233.135:22) to root@slave2(192.168.233.133:22)..
    Permission denied (publickey,password).
    Thu Jun  2 04:25:52 2016 - [error][/usr/local/share/perl5/MHA/SSHCheck.pm, ln111] SSH connection from root@master(192.168.233.135:22) to root@slave2(192.168.233.133:22) failed!
    Thu Jun  2 04:25:53 2016 - [error][/usr/local/share/perl5/MHA/SSHCheck.pm, ln63] 
    Thu Jun  2 04:25:52 2016 - [debug]  Connecting via SSH from root@slave2(192.168.233.133:22) to root@master(192.168.233.135:22)..
    Permission denied (publickey).
    Thu Jun  2 04:25:53 2016 - [error][/usr/local/share/perl5/MHA/SSHCheck.pm, ln111] SSH connection from root@slave2(192.168.233.133:22) to root@master(192.168.233.135:22) failed!
    SSH Configuration Check Failed!
     at /usr/local/bin/masterha_check_ssh line 44
    You have new mail in /var/spool/mail/root

and this is my mha configuration, ssh_user is root ~ I have 5 servers —— master,slave1,slave2,slave3,monitor

[root@monitor bin]# cat /etc/app1.cnf
  [server default]
  user=root
  password=123456

  ssh_user=root

  master_binlog_dir= /data/mysql3306/logs/
  remote_workdir=/data/mysql3306/logs/mha_save_binlog
  secondary_check_script= /usr/bin/masterha_secondary_check -s slave3 -s slave2
  ping_interval=3
  #master_ip_failover_script=/script/masterha/master_ip_failover
  #shutdown_script= /script/masterha/power_manager
  #report_script= /script/masterha/send_master_failover_mail
  manager_workdir=/var/log/masterha/app1
  manager_log=/var/log/masterha/app1/app1.log

  [server1]
  hostname=master

  [server2]
  hostname=slave1

  [server3]
  hostname=slave2

  [server4]
  hostname=slave3

This is has been making me crazy for 24 hours, can anybody help me?

2
  • You probably need to tell the masterha to use your private key (/root/.ssh/id_rsa).
    – Jakuje
    Jun 10, 2016 at 9:00
  • @Jakuje how to do that ? add entry to /etc/app1.cnf ?
    – LawrenceLi
    Jun 11, 2016 at 0:55

1 Answer 1

0

A workaround would be to use preshared keys ( between all cluster ) and use the masterha_check_ssh with public key authentication.

3
  • preshared keys is publickey right ? I have already done ssh no password
    – LawrenceLi
    Jun 10, 2016 at 0:34
  • Does your /etc/app1.cnf have the user,password,repl_user and repl_password defined ?
    – ivspenna
    Jun 10, 2016 at 14:46
  • yes,they are correct
    – LawrenceLi
    Jun 11, 2016 at 0:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .