Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql8.0 support error #2042

Closed
zhfish opened this issue Nov 10, 2019 · 14 comments
Closed

mysql8.0 support error #2042

zhfish opened this issue Nov 10, 2019 · 14 comments
Milestone

Comments

@zhfish
Copy link
Contributor

zhfish commented Nov 10, 2019

Issue Description

Type: bug report

Describe what happened (or what feature you want)

mode: standalone
db: mysql8.0
start.out

Describe what you expected to happen

run ok

How to reproduce it (as minimally and precisely as possible)

version: "3"
services:
  nacos:
    image: nacos/nacos-server:1.1.4
    container_name: nacos-standalone-mysql
    environment:
      - PREFER_HOST_MODE=hostname
      - MODE=standalone
      - MYSQL_DATABASE_NUM=1
      - SPRING_DATASOURCE_PLATFORM=mysql
      - MYSQL_MASTER_SERVICE_HOST=mysql
      - MYSQL_MASTER_SERVICE_DB_NAME=nacos
      - MYSQL_MASTER_SERVICE_PORT=3306
      - MYSQL_SLAVE_SERVICE_HOST=
      - MYSQL_SLAVE_SERVICE_PORT=
      - MYSQL_MASTER_SERVICE_USER=root
      - MYSQL_MASTER_SERVICE_PASSWORD=qwer1234
    volumes:
      - ./standalone-logs/:/home/nacos/logs
      - ./custom.properties:/home/nacos/init.d/custom.properties
    ports:
      - "8848:8848"
      - "9555:9555"
    restart: on-failure

i add mysql-connector-java-8.0.18.jar to /home/nacos/plugins/mysql-connector-java-8.0.18.jar

Tell us your environment

centos 8
docker-ce 19
mysql 8.0

Anything else we need to know?

i try to change application.properties 's mysql string
db.url.0=jdbc:mysql://${MYSQL_MASTER_SERVICE_HOST}:${MYSQL_MASTER_SERVICE_PORT:3306}/${MYSQL_MASTER_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
but no ok

@nkorange
Copy link
Collaborator

What's the result of non-docker?

@zhfish
Copy link
Contributor Author

zhfish commented Nov 11, 2019

non-docker

  • add mysql-connector-java-8.0.18.jar to plugins/mysql/mysql-connector-java-8.0.18.jar
  • add config to conf/application.properties
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://localhost:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&serverTimezone=UTC&zeroDateTimeBehavior=convertToNull
db.user=root
db.password=qwer1234
  • mysql8.0 config is default, nacos is utf8
  • the last caused
Caused by: java.lang.NullPointerException
	at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:2983)
	at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1873)
	at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1802)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234)
	at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2085)
	... 28 more

new driver don't load ?

@nkorange
Copy link
Collaborator

Try the solution commented in #855

@zhfish
Copy link
Contributor Author

zhfish commented Nov 11, 2019

i see #855 first�
i forget look the java's version
java8 is ok
java11 is wrong

@zhfish
Copy link
Contributor Author

zhfish commented Nov 11, 2019

java11下
classpath路径也指对了
但是就是加载不了新驱动
把pom升级自己编译倒是没问题

java8下会加载新驱动,并且提示旧驱动废弃

@nkorange
Copy link
Collaborator

java11下
classpath路径也指对了
但是就是加载不了新驱动
把pom升级自己编译倒是没问题

java8下会加载新驱动,并且提示旧驱动废弃

参考下:

JAVA_OPT="${JAVA_OPT} -cp .:${BASE_DIR}/plugins/cmdb/*.jar:${BASE_DIR}/plugins/mysql/*.jar"

有可能是java版本判断错误,还以为是java8,导致加载的方式不对。

@zhfish
Copy link
Contributor Author

zhfish commented Nov 11, 2019

java11下
classpath路径也指对了
但是就是加载不了新驱动
把pom升级自己编译倒是没问题
java8下会加载新驱动,并且提示旧驱动废弃

参考下:

JAVA_OPT="${JAVA_OPT} -cp .:${BASE_DIR}/plugins/cmdb/*.jar:${BASE_DIR}/plugins/mysql/*.jar"

有可能是java版本判断错误,还以为是java8,导致加载的方式不对。

判断没错的,脚本执行的时候输出了最终语句,java11带ext是启动不起来的。

/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java  -Xms512m -Xmx512m -Xmn256m -Dnacos.standalone=true -cp .:/Users/zhfish/docker/nacos/nacos/plugins/mysql -Xlog:gc*:file=/Users/zhfish/docker/nacos/nacos/logs/nacos_gc.log:time,tags:filecount=10,filesize=102400 -Dnacos.home=/Users/zhfish/docker/nacos/nacos -Dloader.path=/Users/zhfish/docker/nacos/nacos/plugins/health -jar /Users/zhfish/docker/nacos/nacos/target/nacos-server.jar  --spring.config.location=classpath:/,classpath:/config/,file:./,file:./config/,file:/Users/zhfish/docker/nacos/nacos/conf/ --logging.config=/Users/zhfish/docker/nacos/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288

@nkorange
Copy link
Collaborator

loader.path

你参考这个,放到loader.path下试试:
https://stackoverflow.com/questions/36921842/springboot-loader-path-unable-to-load-external-jar

@zhfish
Copy link
Contributor Author

zhfish commented Nov 11, 2019

loader.path

你参考这个,放到loader.path下试试:
https://stackoverflow.com/questions/36921842/springboot-loader-path-unable-to-load-external-jar

赞,这个行了
启动脚本改成这样

JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p')
if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then
  JAVA_OPT="${JAVA_OPT} -Dloader.path=${BASE_DIR}/plugins/health,${BASE_DIR}/plugins/mysql,${BASE_DIR}/plugins/cmdb"
  JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${BASE_DIR}/logs/nacos_gc.log:time,tags:filecount=10,filesize=102400"
else
  JAVA_OPT="${JAVA_OPT} -Dloader.path=${BASE_DIR}/plugins/health"
  JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${BASE_DIR}/plugins/cmdb:${BASE_DIR}/plugins/mysql"
  JAVA_OPT="${JAVA_OPT} -Xloggc:${BASE_DIR}/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
fi

JAVA_OPT="${JAVA_OPT} -Dnacos.home=${BASE_DIR}"
JAVA_OPT="${JAVA_OPT} -jar ${BASE_DIR}/target/${SERVER}.jar"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} --spring.config.location=${CUSTOM_SEARCH_LOCATIONS}"
JAVA_OPT="${JAVA_OPT} --logging.config=${BASE_DIR}/conf/nacos-logback.xml"
JAVA_OPT="${JAVA_OPT} --server.max-http-header-size=524288"

@nkorange
Copy link
Collaborator

好的,稍后我再确认下是否loader.path对于java8一样有效。

@zhfish
Copy link
Contributor Author

zhfish commented Nov 13, 2019

我这边,统一用loader.path, java8和11都能加载新驱动

@nkorange
Copy link
Collaborator

我这边,统一用loader.path, java8和11都能加载新驱动

能否提一个PR共享一下?

@zhfish
Copy link
Contributor Author

zhfish commented Nov 13, 2019

可以,没问题,一会得空就提一下
只是脚本的小改动,没好意思提PR

@zhfish
Copy link
Contributor Author

zhfish commented Nov 13, 2019

#2057

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants