执行ambari-server start时候出错
Exception in thread "main" com.google.inject.CreationException: Guice creation errors:
23 1) Error injecting constructor, java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
4
5 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
6 at org.apache.ambari.server.orm.DBAccessorImpl.<init>(DBAccessorImpl.java:80)
7 while locating org.apache.ambari.server.orm.DBAccessorImpl
8 while locating org.apache.ambari.server.orm.DBAccessor
9 for field at org.apache.ambari.server.orm.dao.DaoUtils.dbAccessor(DaoUtils.java:36)
10 at org.apache.ambari.server.orm.dao.DaoUtils.class(DaoUtils.java:36)
11 while locating org.apache.ambari.server.orm.dao.DaoUtils
12 for field at org.apache.ambari.server.orm.dao.HostComponentStateDAO.daoUtils(HostComponentStateDAO.java:39)
13 at org.apache.ambari.server.orm.dao.HostComponentStateDAO.class(HostComponentStateDAO.java:39)
14 while locating org.apache.ambari.server.orm.dao.HostComponentStateDAO
15 for field at org.apache.ambari.server.orm.models.HostComponentSummary.hostComponentStateDao(HostComponentSummary.java:53)
16 Caused by: java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
17
18 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
19 at org.apache.ambari.server.orm.DBAccessorImpl.<init>(DBAccessorImpl.java:107)
20 at org.apache.ambari.server.orm.DBAccessorImpl$$FastClassByGuice$$86dbc63e.newInstance(<generated>)
21 at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
22 at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
23 at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
24 at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
25 at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54)
26 at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
27 at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
28 at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:94)
29 at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
30 at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
31 at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
32 at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
33 at com.google.inject.Scopes$1$1.get(Scopes.java:65)
34 at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
35 at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
36 at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
37 at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:94)
38 at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
39 at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
40 at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
41 at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
42 at com.google.inject.Scopes$1$1.get(Scopes.java:65)
43 at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
44 at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
45 at com.google.inject.internal.InjectionRequestProcessor$StaticInjection$1.call(InjectionRequestProcessor.java:116)
46 at com.google.inject.internal.InjectionRequestProcessor$StaticInjection$1.call(InjectionRequestProcessor.java:110)
47 at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
48 at com.google.inject.internal.InjectionRequestProcessor$StaticInjection.injectMembers(InjectionRequestProcessor.java:110)
49 at com.google.inject.internal.InjectionRequestProcessor.injectMembers(InjectionRequestProcessor.java:78)
50 at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:170)
51 at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109)
52 at com.google.inject.Guice.createInjector(Guice.java:95)
53 at com.google.inject.Guice.createInjector(Guice.java:72)
54 at com.google.inject.Guice.createInjector(Guice.java:62)
55 at org.apache.ambari.server.controller.AmbariServer.main(AmbariServer.java:826)
56 Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
57
58 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
59 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
60 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
61 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
62 at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
63 at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
64 at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1129)
65 at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:358)
66 at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2489)
以上出错是因为用指定的配置登陆mysql时不能正常登陆
结果办法:
1、查看/etc/ambari-server/conf/ambari.properties 中所有mysql相关url配置,看配置的是什么名称。例如我配置的是localhost
2、linux中命令:$ mysql -h localhost -u ambari -p 登陆,看是否能够成功,如果成功说明配置没有问题,如果不能登陆,则查看mysq中user表中 用户'ambari‘配置是否正确。
总结:大多数情况是用户登陆信息不正确。
另附1、用户操作:
查询用户:SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
创建用户: CREATE USER 'username'@'host' IDENTIFIED BY 'password';
用户授权:GRANT privileges ON databasename.tablename TO 'username'@'host'
GRANT ALL ON *.* TO 'user'@'host';
2、mysql 安装删除操作
//fedora
jdbc 驱动安装:mysql-connector-java
mysql 安装 :yum install mysql-community-server
mysql启动 :systemctl enable mysqld.service
//ubuntu
1. apt-get install mysql-server
2. apt-get install mysql-client
3. apt-get install libmysql-java
//卸载
sudo apt-get autoremove --purge mysql-server-5.0
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common //这个很重要