AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / server / Perguntas / 1170131
Accepted
elplatt
elplatt
Asked: 2025-01-15 05:15:23 +0800 CST2025-01-15 05:15:23 +0800 CST 2025-01-15 05:15:23 +0800 CST

MySQL 5.7 Por que consigo conectar à origem, mas não replicar?

  • 772

Estou tentando configurar a replicação entre dois servidores mysql 5.7. Consigo conectar à fonte a partir da réplica, mas quando tento iniciar a replicação, a réplica falha ao conectar à fonte. O que pode causar isso

Isso abre com sucesso um cliente mysql conectado à fonte:

# On replica
$ mysql -u [my_user] -p -h [source_host] \
    --ssl-mode=REQUIRED \
    --ssl-ca=/etc/[source_host].cabundle

Status da fonte:

mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.002513 | 45687316 |              |                  |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

Na réplica:

mysql> CHANGE MASTER TO
    -> MASTER_HOST='[source_host]',
    -> MASTER_USER='[my_user]',
    -> MASTER_PASSWORD='[my_password]',
    -> MASTER_LOG_FILE='mysql-bin.002495',
    -> MASTER_LOG_POS=154,
    -> MASTER_SSL=1,
    -> MASTER_SSL_VERIFY_SERVER_CERT=0,
    -> MASTER_SSL_CA='/etc/ssl/[source_host].cabundle'
    -> ;
Query OK, 0 rows affected, 2 warnings (0.03 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

Status da réplica:

mysql> show slave stauts \G
*************************** 1. row ***************************
               Slave_IO_State: Connecting to master
                  Master_Host: [source_host]
                  Master_User: [my_user]
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.002495
          Read_Master_Log_Pos: 154
               Relay_Log_File: [hostname]-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.002495
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
              Relay_Log_Space: 154
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: Yes
           Master_SSL_CA_File: /etc/ssl/[source_host].cabundle
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 2026
                Last_IO_Error: error connecting to master '[my_user]@[source_host]:3306' - retry-time: 60  retries: 
4
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 0
                  Master_UUID: 
             Master_Info_File: [mysql_dir]/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 250115 03:03:38
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version:

mysql error.log na réplica:

[Note] 'CHANGE MASTER TO FOR CHANNEL '' executed'. Previous state master_host='[source_host]', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='[source_host]', master_port= 3306, master_log_file='mysql-bin.002495', master_log_pos= 154, master_bind=''.
[Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[Warning] Slave SQL for channel '': If a crash happens this configuration does not guarantee that the relay log info will be consistent, Error_code: 0
[Note] Slave SQL thread for channel '' initialized, starting replication in log 'mysql-bin.002495' at position 154, relay log './analysis-relay-bin.000001' position: 4
[ERROR] Slave I/O for channel '': error connecting to master '[my_user]@[source_host]:3306' - retry-time: 60  retries: 1, Error_code: 2026

mysql error.log na fonte:

[Note] Bad handshake
mysql
  • 2 2 respostas
  • 64 Views

2 respostas

  • Voted
  1. symcbean
    2025-01-15T08:44:04+08:002025-01-15T08:44:04+08:00
    1. O que você nos mostrou aqui não se parece com a saída de show slave status( show slave status \Gé mais fácil de ler).

    2. Ao se conectar na linha de comando, você informa explicitamente ao cliente onde encontrar o certificado CA. Você NÃO fez isso ao criar o canal de replicação (MASTER_SSL_CAPATH=...).

    3. O erro 2026 é um erro na negociação da conexão TLS

    Tente definir o caminho da CA no comando start slave.

    • 1
  2. Best Answer
    elplatt
    2025-01-17T02:25:23+08:002025-01-17T02:25:23+08:00

    Achei a resposta. Havia duas coisas acontecendo:

    1. Mesmo que eu tenha especificado MASTER_SSL_VERIFY_SERVER_CERT=0, a replicação estava tentando usar VERIFY_CAo modo. Não sei por quê. Mas o erro foi o mesmo quando alterei o cliente de linha de comando para usar VERIFY_CAem vez de REQUIRED.

    2. Estou usando certificados Let's Encrypt. Em junho de 2024, a Let's Encrypt parou de incluir o certificado ISRG Root X1 em sua cadeia CA. Sem isso, o openssl não conseguia verificar o certificado do servidor (Ubuntu 20.04, Mysql 5.7). Isso é corrigido baixando o certificado ISRG Root X1 da Let's Encrypt e anexando-o manualmente ao arquivo da cadeia CA. Descobri isso olhando um comentário em uma postagem de blog que me levou a alguma documentação da Let's Encrypt:

      • https://krisrice.io/2022-01-28-mysql-lets-encrypt/
      • https://letsencrypt.org/2023/07/10/cross-sign-expiration/
      • https://community.letsencrypt.org/t/letsencrypt-ssl-for-mysql-on-ubuntu-20-04/172346/37
    • 0

relate perguntas

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Você pode passar usuário/passar para autenticação básica HTTP em parâmetros de URL?

    • 5 respostas
  • Marko Smith

    Ping uma porta específica

    • 18 respostas
  • Marko Smith

    Verifique se a porta está aberta ou fechada em um servidor Linux?

    • 7 respostas
  • Marko Smith

    Como automatizar o login SSH com senha?

    • 10 respostas
  • Marko Smith

    Como posso dizer ao Git para Windows onde encontrar minha chave RSA privada?

    • 30 respostas
  • Marko Smith

    Qual é o nome de usuário/senha de superusuário padrão para postgres após uma nova instalação?

    • 5 respostas
  • Marko Smith

    Qual porta o SFTP usa?

    • 6 respostas
  • Marko Smith

    Linha de comando para listar usuários em um grupo do Windows Active Directory?

    • 9 respostas
  • Marko Smith

    O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL?

    • 3 respostas
  • Marko Smith

    Como determinar se uma variável bash está vazia?

    • 15 respostas
  • Martin Hope
    Davie Ping uma porta específica 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    kernel O scp pode copiar diretórios recursivamente? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh retorna "Proprietário incorreto ou permissões em ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil Como automatizar o login SSH com senha? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin Como lidar com um servidor comprometido? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner Como posso classificar a saída du -h por tamanho 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent Como determinar se uma variável bash está vazia? 2009-05-13 09:54:48 +0800 CST

Hot tag

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve