Troubleshooting record: Docker MySQL cannot be connected due to server IPv4 forwarding disabled

  Problem: Unable to log in to the system after restarting the server

1. Vue Axios login reports time out

  • Troubleshooting process
    • Open the backend log, check the log of the request process, and find that there is no error in the log, and the parameters of the request are output normally
    • Modify the log level to Debug, view more detailed log process, and find that there is no SQL query of MyBatis
    • After waiting for a while, the problem of MySQL connection failure was thrown (maybe it was thrown after the connection to MySQL timed out, and there was not enough time before), and the following error occurred

insert image description here

二、Druid 报 create connection SQLException

  • specific error

    • create connection SQLException, url: jdbc:mysql://hybrid03:3306/car_analyse?characterEncoding=utf-8&useSSL=false, errorCode 0, state 08S01
    • com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
  • The first reaction is that the number of MySQL connections exceeds

    • Enter the database and use the show full processlist to check, and found that only 21 connections are used, and only Hive is maintaining the connection, which is not exceeded at all (MySQL default max_connections is 151)
  • The second is to start searching for how others deal with Druid and report create connection SQLException state 08S01

    • I found that many people wrote about the problem of the database connection address url, just add useSSL=false, and then I saw that I have all the parameters, but there are still problems, so I gave up the search

3. Check MySQL

  • Use DBeaver locally to connect to the remote database, and find that the connection timed out, check whether the remote connection is enabled, check if it is enabled
  • Restarting MySQL and restarting Docker did not solve the problem. After discussing with the customer, delete the MySQL container and run it again (the data in the Docker MySQL container is mounted to the host, and the data will not be lost)
  • When reloading the Docker MySQL container, the following warning was reported

insert image description here

4. Server IPv4 forwarding is disabled

  • specific warning
    • WARNING:IPv4 forwarding is disabled. Networking will not work.
  • Try to modify this problem with the mentality of giving it a try
    • Add the configuration of net.ipv4.ip_forward=1 in /usr/lib/sysctl.d/00-system.conf of the host
    • Restart Networ and Docker
      • systemctl restart network
      • systemctl restart docker
  • problem solved, finished

Guess you like

Origin blog.csdn.net/baidu_40468340/article/details/128902414