2017-09-05 6 views
2

wir haben derzeit ein großes Problem auf unserem Produktionsserver. Wir haben eine MySQL DB auf einem Server (Ubuntu 14.04 und MySQL Version 5.5.57).MySQL Host ist wegen vieler Verbindungsfehler blockiert

Wir haben einen anderen Server mit allen Anwendungen, die mit der Datenbank auf Server eins sprechen. 5 Tage jetzt halten wir diesen Fehler auf dem zweiten Server bekommen:

05-09-2017 00:00:01 WARN com[email protected]623841b8 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: 
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. 
    at sun.reflect.GeneratedConstructorAccessor32.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408) 
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) 
    at com.mysql.jdbc.Util.getInstance(Util.java:386) 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015) 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989) 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975) 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920) 
    at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2395) 
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2316) 
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834) 
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) 
    at sun.reflect.GeneratedConstructorAccessor19.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408) 
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) 
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416) 
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347) 
    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146) 
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195) 
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184) 
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200) 
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086) 
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073) 
    at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44) 
    at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810) 
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648) 
    Caused by: java.sql.SQLException: null, message from server: "Host 'IP_ADDRESS' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'" 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078) 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989) 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975) 
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1114) 
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2493) 
    at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2334) 

Wir versuchen, für 5 Tage wurde dieses Problem zu beheben, aber jedes Mal, wenn wir seine neu starten mysql ein paar Stunden beginnt dann der Fehler erneut. Ich habe die max_connect_errors von 10 auf 50 erhöht, aber das verlängerte den Fehler nur.

Dann haben wir auch den Log-Level auf 2 angepasst, aber das einzige, was wir jemals im Fehlerprotokoll sehen, ist abgebrochene Verbindungen, keine "verweigerten" Verbindungen.

Gibt es eine Möglichkeit, die tatsächlichen Verbindungsfehler zu sehen? Bitte helfen Sie, dies zu lösen, ich weiß nicht, wie ich es lösen soll. Wir haben auch keinen DBA, also ist es nur ein Entwicklerteam, das keine Datenbankexperten ist.

EDIT: Die Anwendung ist eine Java Maven-Anwendung, die Hibernate verwendet, um eine Verbindung zur Datenbank herzustellen. Hier ist die Hibernate-Konfigurationsdatei:

<hibernate-configuration> 
<session-factory> 
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="hibernate.connection.username">USERNAME_HERE</property> 
    <property name="hibernate.connection.password">PASSWORD_HERE</property> 
    <property name="hibernate.connection.url">jdbc:mysql://SERVER_HERE:3306/voda_soccer?zeroDateTimeBehavior=convertToNull</property> 
    <property name="hibernate.connection.autoReconnect">true</property> 
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> 
    <property name="hibernate.temp.use_jdbc_metadata_defaults">false</property> 
    <property name="show_sql">false</property> 

    <property name="hibernate.c3p0.min_size">5</property> 
    <property name="hibernate.c3p0.max_size">20</property> 
    <property name="hibernate.c3p0.timeout">300</property> 
    <property name="hibernate.c3p0.max_statements">50</property> 
    <property name="hibernate.c3p0.idle_test_period">3000</property> 

    <mapping class="com.myapp.sms.producer.entity.Customer"></mapping> 
    <mapping class="com.myapp.sms.producer.entity.Gifting"></mapping> 
    <mapping class="com.myapp.sms.producer.entity.BulkCampaign"></mapping> 
</session-factory> 

Wir sind immer enge Verbindungen in einem finally-Block:

} finally { 
     if (session != null) { 
      try { 
       session.close(); 
      } catch (Exception e) {} 
     } 
     session = null; 
    } 

Ich weiß, dass wir die Gastgeber spülen oder neu starten, MySQL, aber ich kann das nicht tun die ganze Zeit im Produktionsserver. Ich möchte herausfinden, WARUM wir die Verbindungsfehler bekommen und wo sie zu sehen sind?

+0

Schließen Sie Ihre Verbindungen? –

+0

Teilen Sie Ihr Verbindungsobjekt zwischen mehreren Threads, diese Objekte sind nicht Thread-sicher – Ferrybig

+0

siehe auch https://StackOverflow.com/Questions/222285318/How-to-Unblock-with-mysqladmin-flush-hosts –

Antwort

0

Es scheint, dass ein Verbindungsleck vorliegt oder Sie lange Abfragen ausführen, die verhindern, dass andere Codesegmente eine Verbindung erhalten.

Je nach dem von Ihnen verwendeten Datenquellen-Tool (c3p0, hikari usw.) können Sie Ihren Pool über jmx (jsconsole, visual vm) überwachen.

Sie können auch Flexy Pool verwenden, um einige Überwachung zu tun.

Mysql Workbench bietet auch einige nützliche Tools, um mehr Informationen über die Aktion zu erhalten, die verantwortlich ist.

Verwandte Themen