ambari-server start 出错

当执行`ambari-server start`时遇到错误,主要是由于MySQL登录配置不正确导致。解决方案包括检查`ambari.properties`中的MySQL配置,验证用户'ambari'在MySQL中的设置是否正确。如果登录失败,可能需要创建或更新用户权限。此外,提供了在Fedora和Ubuntu上的MySQL安装、启动和卸载步骤。
摘要由CSDN通过智能技术生成

执行ambari-server start时候出错


Exception in thread "main" com.google.inject.CreationException: Guice creation errors:

   2
   3 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 //这个很重要

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值