Apollo配置中心搭建常见报错
Apollo配置中心常见报错
环境:
主机名 | IP地址 | 角色 |
---|---|---|
cka-m2 | 192.168.199.11 | config、admin、portal |
cka-n1 | 192.168.199.12 | mysqlDB |
报错一:数据库连接被拒绝
启动configservice组件时,启动失败,查看日志:(连接数据库被拒绝)
从cka-m2本地测试:
从cka-n1数据库本地测试:
判断可能是MySQL的root用户禁止远程连接,查看mysql库的user表:
果然,将root设置为可以远程连接即可,或新创建一个用户并设为可以远程连接:
报错二:数据库Timezone未设置
2020-08-21 11:35:28.008 ERROR 4743 --- [localhost-startStop-1] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
java.sql.SQLException: The server time zone value 'EDT' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:117)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:123)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:365)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:194)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:460)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:534)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
在对应组件的properties里面加"&serverTimezone=GMT"参数即可
# DataSource
spring.datasource.url = jdbc:mysql://192.168.199.12:3306/ApolloConfigDB?characterEncoding=utf8&serverTimezone=GMT
spring.datasource.username = root
spring.datasource.password = 123
或更改MySQL的Timezone
vim /etc/my.cnf
在[mysqld]下添加:
default-time_zone = '+8:00'
systemctl restart mysqld