8) Error injecting constructor, java.lang.RuntimeException: java.sql.SQLException: null, message from server: "Host 'ambari0.cloud' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"
at org.apache.ambari.server.orm.DBAccessorImpl.(DBAccessorImpl.java:74)
while locating org.apache.ambari.server.orm.DBAccessorImpl
while locating org.apache.ambari.server.orm.DBAccessor
for field at org.apache.ambari.server.orm.dao.DaoUtils.dbAccessor(DaoUtils.java:36)
at org.apache.ambari.server.orm.dao.DaoUtils.class(DaoUtils.java:36)
while locating org.apache.ambari.server.orm.dao.DaoUtils
for field at org.apache.ambari.server.orm.dao.ResourceTypeDAO.daoUtils(ResourceTypeDAO.java:36)
at org.apache.ambari.server.orm.dao.ResourceTypeDAO.class(ResourceTypeDAO.java:36)
while locating org.apache.ambari.server.orm.dao.ResourceTypeDAO
for field at org.apache.ambari.server.view.ViewRegistry.resourceTypeDAO(ViewRegistry.java:97)
at org.apache.ambari.server.view.ViewRegistry.class(ViewRegistry.java:97)
while locating org.apache.ambari.server.view.ViewRegistry
for field at org.apache.ambari.server.controller.AmbariServer.viewRegistry(AmbariServer.java:126)
at org.apache.ambari.server.controller.AmbariServer.class(AmbariServer.java:126)
while locating org.apache.ambari.server.controller.AmbariServer
Caused by: java.lang.RuntimeException: java.sql.SQLException: null, message from server: "Host 'ambari0.cloud' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"
at org.apache.ambari.server.orm.DBAccessorImpl.(DBAccessorImpl.java:100)
at org.apache.ambari.server.orm.DBAccessorImpl$$FastClassByGuice$$86dbc63e.newInstance()
at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54)
at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:94)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
解决办法:
#mysqladmin flush-hosts
或者
mysql -uroot-p
flush hosts
原因:
mysql中默认的max_connect_errors是10,因为连接失误,造成这个数值高于10,当在接受连接的时侯就被锁住了, 并阻止主机的进一步连接请求。
可以将这个值改的稍微高一些。
Mysql数据库查看max_connection_errors: show variables like '%max_connection_errors%';
或者show variables like '%connect%';
shell> mysqld_safe --max_connect_errors=1000
或者
set global max_connect_errors=1000;
注意,对给定的主机,如果得到这条错误消息,你应该首先检查该主机的TCP/IP连接有没有问题。如果你的TCP/IP连接不在运行,增加max_connect_errors变量的值对你也不会有帮助!