Mysql&Nacos version

Example Modify the Nacos configuration

Start the nacos

./startup.sh -m standalone

cat /opt/software/nacos/logs/start.out

The error log is as follows

Nacos supports mysQL5 by default. You need to modify the POM.xml file and the class code to recompile nacOS to support mysQL8

org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:371)
	at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:523)
	at com.alibaba.nacos.config.server.service.BasicDataSourceServiceImpl$SelectMasterTask.run(BasicDataSourceServiceImpl.java:317)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.accessThe $301(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.)
	at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
Copy the code

Modify Nacos

Download the NACOS code

Git clone github.com/alibaba/nac…

Modify the POM.xml file

The default mysql-Connector version is 5.1.34

< the dependency > < groupId > mysql < / groupId > < artifactId > mysql connector - Java < / artifactId > < version > 8.0.18 < / version > </dependency>Copy the code

Modify MysqlHealthCheckProcessor. Java file

Modify the naming the project com. Alibaba. Nacos. Naming. Healthcheck package

import com.mysql.cj.jdbc.MysqlDataSource;
Copy the code

compile

Go to the nacos home directory and run the following command

mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
Copy the code

The packaged file is placed under distribution\target\

Start the nacos

Stand-alone mode

startup.sh -m standalone
Copy the code

Access to the address

127.0.0.1:8848 / nacos