Nacos 被用於:
- 服務發現
- 微服務配置信息管理
部署 nacos 時,需要用到如下兩個鏡像,這兩個鏡像均來自於 nacos 官方發布到 docker hub 的鏡像,
nacos/nacos-server:latest https://hub.docker.com/r/nacos/nacos-server
nacos/nacos-mysql:5.7 https://hub.docker.com/r/nacos/nacos-mysql
碰到個奇葩的問題
使用官方的nacos/nacos-server:2.0.1鏡像,會報錯,連接不上數據庫:
org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Caused by: java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
換成官方的nacos/nacos-server:latest鏡像就可以連接上數據庫,但是web頁面訪問后查看nacos版本竟然是2.0.1。
操作步驟
# 需要事先有存儲卷
1.kubectl create -f Namespace.yaml
2.kubectl create -f nacos-mysql.yaml
3.kubectl create -f nacos-mysql-service.yaml
4.kubectl create -f ConfigMap.yaml
5.kubectl create -f StatefulSet.yaml
6.kubectl create -f nacos-service.yaml
yaml文件下載地址
https://files.cnblogs.com/files/sanduzxcvbnm/single_nacos.7z