- 下載源碼
https://gitee.com/mirrors/Nacos?_from=gitee_search - 修改源碼讓其支持mysql8.0版本(默認(rèn)不支持mysql8.0)
- 修改最外層pom.xml 中 mysql驅(qū)動版本
<!-- JDBC libs -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
2.修改naming這個項目 com.alibaba.nacos.naming.healthcheck 包下的 MysqlHealthCheckProcessor 類的第24行導(dǎo)包為:
import com.mysql.cj.jdbc.MysqlDataSource;
3.修改時區(qū)或渤,所以還需要修改 console這項目 resources/META-INF下 nacos-default.properties這個文件中的db.url 添加serverTimezone=GMT%2B8
db.url.0=jdbc:mysql://11.162.196.161:3306/diamond_devtest?serverTimezone=GMT%2B8&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.url.1=jdbc:mysql://11.163.152.91:3306/diamond_devtest?serverTimezone=GMT%2B8&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=diamond_devtest
db.password=4b9622f3f70c7677835ac5a6719e7caf
4.修改數(shù)據(jù)庫配置項 db.uri 配置 位置:distribution\conf\application.properties
### Connect URL of DB:
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=user
db.password=password
- 創(chuàng)建數(shù)據(jù)庫,數(shù)據(jù)庫腳本目錄distribution/conf/nacos-mysql.sql
- 重新打包 打包后的文件目錄distribution\target\
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
- 單機模式啟動
Linux
sh startup.sh -m standalone
windows
cmd startup.cmd -m standalone
-
訪問地址127.0.0.1:8848/nacos
用戶名:nacos 密碼:nacos
image.png