cdh oozie 无法启动问题Could not load service classes, Cannot create PoolableConnectionFactory

问题描述:在安装cdh元数据myslq高可用时,使用的是myslq主主复制+keepalived实现。期间发现切换时,出现如下异常信息!

花了很长时间寻找问题的原因。因为切换的时候,使用本机命令行是可以连接的,但是夸服务器就无法连接,没有去这方面的尝试,后来使用navicate无法连接后,就推测是mysql高可用切换的问题导致的。

问题分析:如果不重启keepalived,是无法实现切换和连接的。以下问题就是由于这个原因导致的,本质是无法连接mysql,不是jar包的问题。网上很多人的异常是因为mysql驱动问题,错误不太一样 。

解决方案

             1)尝试手工重启services  keepalived restart   ,后问题解决

             2)当mysql切换的时候,自动重启另外一台服务器的keepalived。通过配置脚本的方式来解决。本质原因还是在重启的时候不能执行:

/opt/model/keepalived-2.0.0/shell/sqlCdh2.sh

#!/bin/bash

service keepalived restart

cat /opt/model/keepalived-2.0.0/shell/restartCdh2Keepalived.sh

ssh root@172.17.10.153 nohup /opt/model/keepalived-2.0.0/shell/sqlCdh2.sh >/opt/model/keepalived-2.0.0/shell/result.txt 2>&1 &

调用重启

cat /root/shutdown

/opt/model/keepalived-2.0.0/shell/restartCdh2Keepalived.sh

sleep 10#这句话必须要加上,否则不能重启另外一台服务的keepalived

killall keepalived

 cat /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {

   router_id mysql-ha

}

vrrp_instance VI_1 {

    state BACKUP

    interface ens32

    virtual_router_id 201

    #优先级,高优先级竞选为master

    priority 100

    advert_int 1

    #设置为不抢占 注:这个配置只能设置在backup主机上,而且这个主机优先级要比另外一台高,另一台不要设置这个选项 

    nopreempt

    authentication {

        auth_type PASS

        auth_pass 123456

    }

    virtual_ipaddress {

        172.17.10.155

    }

}

virtual_server 172.17.10.155 3306 {

    delay_loop 2

    lb_algo rr

    lb_kind DR

    persistence_timeout 60

    protocol TCP

    real_server 172.17.10.152 3306 {

        weight 1

        notify_down /root/shutdown.sh

        TCP_CHECK {

            connect_port 3306

            connect_timeout 3

            nb_get_retry 2

            delay_before_retry 1

        }

    }

}

异常信息:

2018-12-18 17:45:21,820 FATAL org.apache.oozie.service.Services: SERVER[cdh3] Runtime Exception during Services Load. Check your list of ‘oozie.services’ or ‘oozie.services.ext’

2018-12-18 17:45:21,825 FATAL org.apache.oozie.service.Services: SERVER[cdh3] E0103: Could not load service classes, Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)

org.apache.oozie.service.ServiceException: E0103: Could not load service classes, Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)

    at org.apache.oozie.service.Services.loadServices(Services.java:309)

    at org.apache.oozie.service.Services.init(Services.java:213)

    at org.apache.oozie.servlet.ServicesLoader.contextInitialized(ServicesLoader.java:46)

    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)

    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)

    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:802)

    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)

    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)

    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:944)

    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:779)

    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:505)

    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)

    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:325)

    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)

    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1068)

    at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)

    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)

    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)

    at org.apache.catalina.core.StandardService.start(StandardService.java:525)

    at org.apache.catalina.core.StandardServer.start(StandardServer.java:759)

    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:498)

    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)

    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Caused by: <openjpa-2.2.2-r422266:1468616 fatal general error> org.apache.openjpa.persistence.PersistenceException: Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)

    at org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(DBDictionaryFactory.java:102)

    at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:603)

    at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1518)

    at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:531)

    at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:456)

    at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:120)

    at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68)

    at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)

    at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:967)

    at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:958)

    at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:644)

    at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:203)

    at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)

    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)

    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)

    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)

    at org.apache.oozie.service.JPAService.getEntityManager(JPAService.java:500)

    at org.apache.oozie.service.JPAService.init(JPAService.java:201)

    at org.apache.oozie.service.Services.setServiceInternal(Services.java:386)

    at org.apache.oozie.service.Services.setService(Services.java:372)

    at org.apache.oozie.service.Services.loadServices(Services.java:305)

    … 26 more

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)

    at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)

    at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)

    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)

    at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(DelegatingDataSource.java:110)

    at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(DecoratingDataSource.java:87)

    at org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(DBDictionaryFactory.java:91)

    … 46 more

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1121)

    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:357)

    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2482)

    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2519)

    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2304)

    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)

    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

    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:346)

    at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)

    at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)

    at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)

    at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)

    … 51 more

Caused by: java.net.ConnectException: Connection refused

    at java.net.PlainSocketImpl.socketConnect(Native Method)

    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)

    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

    at java.net.Socket.connect(Socket.java:589)

    at java.net.Socket.connect(Socket.java:538)

    at java.net.Socket.<init>(Socket.java:434)

    at java.net.Socket.<init>(Socket.java:244)

    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:259)

    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:307)

    … 67 more

———————

作者:liygcoding

来源:本人博客地址

原文:https://blog.csdn.net/wumiqing1/article/details/85088373 

    原文作者:suolemen
    原文地址: https://www.jianshu.com/p/e17ad26ed6ca
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞