通过ssh隧道的mariadb复制

我正在尝试通过ssh隧道进行mariadb复制。 这是我的configuration。 首先,我创build了一个从我的复制服务器(R1)到我的主服务器(M1)的ssh隧道。

ssh -L 13306:localhost:3306 -p 22111 admin@M1 -f -N 

两个mariadb实例已经在两台服务器上运行。 而且我已经在M1 mariadb实例上创build了一个复制用户。

 CREATE USER 'replication'@'127.0.0.1' identified by 'xxxx'; GRANT REPLICATION SLAVE on *.* to 'replication'@'127.0.0.1' REQUIRE SSL; 

从R1我检查我是否可以连接到M1 mariadb实例。

 mysql -u replication -pxxxx -h 127.0.0.1 --protocol=TCP -P 13306 

以上操作成功。 但是现在,当我指示复制实例R1 更改主机启动从机时 ,它将失败。

 CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='replication', MASTER_PASSWORD='xxxx', MASTER_PORT=13306, MASTER_LOG_FILE='mysql-bin.000022', MASTER_LOG_POS=9164599, MASTER_SSL=1, MASTER_SSL_CA='/etc/tls/ca-cert.pem', MASTER_SSL_CERT='/etc/tls/client-cert.pem', MASTER_SSL_KEY='/etc/tls/client-key.pem', MASTER_CONNECT_RETRY=10; START SLAVE; SHOW SLAVE STATUS \G *************************** 1. row *************************** Slave_IO_State: Connecting to master Master_Host: 127.0.0.1 Master_User: replication Master_Port: 13306 Connect_Retry: 10 Master_Log_File: mysql-bin.000022 Read_Master_Log_Pos: 9164599 Relay_Log_File: mysqld-relay-bin.000002 Relay_Log_Pos: 4 Relay_Master_Log_File: mysql-bin.000022 Slave_IO_Running: Connecting Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 9164599 Relay_Log_Space: 249 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: Yes Master_SSL_CA_File: /etc/tls/ca-cert.pem Master_SSL_CA_Path: Master_SSL_Cert: /etc/tls/client-cert.pem Master_SSL_Cipher: Master_SSL_Key: /etc/tls/client-key.pem Seconds_Behind_Master: NULL Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 2003 Last_IO_Error: error connecting to master '[email protected]:13306' - retry-time: 10 retries: 86400 message: Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused") Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 0 Master_SSL_Crl: /etc/tls/ca-cert.pem Master_SSL_Crlpath: Using_Gtid: No Gtid_IO_Pos: Replicate_Do_Domain_Ids: Replicate_Ignore_Domain_Ids: Parallel_Mode: conservative 1 row in set (0.00 sec) 

指向错误configuration的任何帮助是非常受欢迎的。

问候,

Ashutosh辛格