异常描述
在CDP7.1.1的安装过程中,添加SMM组件后,配置完数据库信息,启动服务过程中,提示启动Streams Messaging Manager Rest Admin Server角色失败。如下图:
报错信息为:
代码语言:javascript复制Exception in thread "main" org.flywaydb.core.api.FlywayException: Unable to instantiate JDBC driver: com.mysql.cj.jdbc.Driver => Check whether the jar file is present
at org.flywaydb.core.internal.util.jdbc.DriverDataSource.<init>(DriverDataSource.java:142)
at org.flywaydb.core.api.configuration.ClassicConfiguration.setDataSource(ClassicConfiguration.java:1147)
at org.flywaydb.core.Flyway.setDataSource(Flyway.java:712)
at com.hortonworks.registries.storage.tool.sql.SchemaFlywayFactory.mysqlFlyway(SchemaFlywayFactory.java:58)
at com.hortonworks.registries.storage.tool.sql.SchemaFlywayFactory.get(SchemaFlywayFactory.java:44)
at com.hortonworks.registries.storage.tool.sql.TablesInitializer.main(TablesInitializer.java:176)
Caused by: org.flywaydb.core.api.FlywayException: Unable to instantiate class com.mysql.cj.jdbc.Driver : com.mysql.cj.jdbc.Driver
at org.flywaydb.core.internal.util.ClassUtils.instantiate(ClassUtils.java:61)
at org.flywaydb.core.internal.util.jdbc.DriverDataSource.<init>(DriverDataSource.java:132)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
异常分析
根据报错分析是找不到JDBC驱动。在CDP7.1中SMM和SchemaRegistry必须将mysql-connector-java.jar放在自己的库目录中,而我们默认是放在/usr/share/java中的。所以这里我们需要把JDBC驱动放置到需要的库中。
解决办法
1.把JDBC驱动分别软链到SMM和SchemaRegistry的库目录中
代码语言:javascript复制[root@cdh03 java]# cd /opt/cloudera/parcels/CDH/lib/schemaregistry/bootstrap/lib
[root@cdh03 lib]# ln -s /usr/share/java/mysql-connector-java.jar
代码语言:javascript复制[root@cdh03 lib]# cd /opt/cloudera/parcels/CDH/lib/schemaregistry/libs
[root@cdh03 libs]# ln -s /usr/share/java/mysql-connector-java.jar
代码语言:javascript复制[root@cdh03 libs]# cd /opt/cloudera/parcels/CDH/lib/streams_messaging_manager/bootstrap/lib
[root@cdh03 lib]# ln -s /usr/share/java/mysql-connector-java.jar
代码语言:javascript复制[root@cdh03 lib]# cd /opt/cloudera/parcels/CDH/lib/streams_messaging_manager/libs
[root@cdh03 libs]# ln -s /usr/share/java/mysql-connector-java.jar
2.配置完之后,从CM启动服务测试
重启成功,异常解决。
总结
在CDP7.1中SMM和SchemaRegistry必须将JDBC驱动放在自己的库目录中,这跟以前默认的地址/usr/share/java不同,需要手动进行配置。